The degree of averaging is a little more complicated than it seems. I had to do this at work the other day and I want to share my findings.
- Adding 360 to any of your values ββshould not change on average.
e.g. avg (2 4 18) = avg (362,4,18) = 8 - A shift of all values ββin a constant value should shift the average value equally.
e.g. avg (2-3,4-3,18-3) = avg (359,1,15) = 8-3 - If your degrees are "undo", for example, 0.120,240, the average value is undefined
(i.e. there are several equally good answers).
I see no way to handle this except for the error message.
After falling into several traps, I got the following definition: The average value that minimizes the variance.
After setting the average value, the variance can be calculated using:
- Shift all values ββby the same angle, so the average is 180.
(This is equivalent to "cutting" a circle on the opposite side of the middle.) - Normalization of all angles between 0 and 360.
- Calculation of the normal average.
- Shift the average backward by the angle by which you shifted the values ββto (step 1).
It takes O time (n ^ 2).
However, if all your values ββare within the range of 180 degrees, you can shift the values, such that 0 is in the largest gap of values, and then calculate the normal average value. This takes O (n) time.
Martin Vatshelle Oct 24 '14 at 21:12 2014-10-24 21:12
source share