# What do you mean?

When calculating the mean of a list of numbers, the obvious approach is to sum them and divide by how many there are.

Suppose I give you a list of two numbers:

• 0
• 359

What is their mean? The obvious answer is 179.5.

If I told you that the numbers were compass bearings in degrees, what would your answer be then? Does 179.5 seem correct?

In the case of compass bearings, 0 is the same direction as 360. When talking about angles in the DSP world, we often talk about angles between -π and +π (in radians).

This conundrum is related to Steve Smith's Nuisance 7.

# Circular Reasoning

This problem is well-studied   and there is a clear solution to the problem : use of vectorial (or phasor) addition for finding the mean. Instead of writing:

μ = x1 + x2

where x1 and x2 are directions between 0 and 360 degrees, we write

μ = arg ( exp[jπ x1 /180] + exp[jπ x2 /180 ] ).

where exp( ) is the exponential function, j is the square root of -1 and arg( ) is the argument (complex angle or phase) of the result.

In effect, this is a phasor average rather than a linear average.

# References

 Kanti V. Mardia and Peter E. Jupp, "Directional Statistics," Wiley, 1999, ISBN-10: 0471953334.

 Lovell, Brian C. and Kootsookos, Peter J. and Williamson, R. C. (1991) The Circular Nature Of Discrete-Time Frequency Estimates. In IEEE International Conference on ASSP, May, 1991, pages 3369-3372, Toronto.

[ - ]
Comment by February 21, 2009 Hi, Neat blog. I've not thought about this subject before. (I don't recall ever having performed averaging on a list of phase angles in my past work.) Thanks for clarifying this "tricky" subject. [-Rick-]
[ - ]
Comment by February 21, 2009 In many applications this discontinuity problem is neatly solved by representing angles on a integer scale which fills the whole number space - i.e. scaling the angles so 0 degrees is all 0s, and just less than 360 degrees is all 1s. Most operations on such a representation "just work", although care must always been taken to ensure the particular operations you are performing are in the "just works" category.
[ - ]
Comment by April 1, 2009 Definitely an important topic for anyone who has to compute statistics on phase (or any circular data). I've also heard this topic referred to as "circular statistics" in a few books and IEEE papers.

To post reply to a comment, click on the 'reply' button attached to each comment. To post a new comment (not a reply to a comment) check out the 'Write a Comment' tab at the top of the comments.