How to average cyclic quantities?
Solution 1:
Like all averages, the answer depends upon the choice of metric. For a given metric $M$, the average of some angles $a_j \in [-\pi,\pi]$ for $j \in [1,N]$ is that angle $\bar{a}_M$ which minimizes the sum of squared distances $d^2_M(\bar{a}_M,a_j)$. For a weighted mean, one simply includes in the sum the weights $w_j$ (such that $\sum_j w_j = 1$). That is,
$$\bar{a}_M = \mathop{\rm arg\,min}_{x} \sum_{j=1}^{N}\, w_j\, d^2_M(x,a_j)$$
Two common choices of metric are the Frobenius and the Riemann metrics. For the Frobenius metric, a direct formula exists that corresponds to the usual notion of average bearing in circular statistics. See "Means and Averaging in the Group of Rotations", Maher Moakher, SIAM Journal on Matrix Analysis and Applications, Volume 24, Issue 1, 2002, for details. http://lcvmwww.epfl.ch/new/publications/data/articles/63/simaxpaper.pdf
Solution 2:
The problem with expecting the mean of 90°, −90°, and 40° to be (90°−90°+40°)/3 = 13.33° is that you would then expect the mean of 10° and 350° to be (10°+350°)/2 = 180°, and not 0° which is the more reasonable answer. It only gets worse when you have more than two angles (What is the mean of 340°, 350°, 360°, 10°, and 20°? What about 340°, 350°, 0°, 10°, and 20°?). Essentially, what you're doing there is equivalent to setting $z_n = e^{i\theta_n}$ and computing $$\bar z = (z_1 z_2 \cdots z_N)^{1/N},$$ and the problem is of course that it's not obvious a priori which of the $N$ possible roots of that equation is the right one, if any.
The "circular mean" definition is not so bad. In fact, it corresponds to the point which minimizes the sum of its squared distances to the points corresponding to the data, $$\bar z = \underset{\lvert z \rvert = 1}{\arg\min} \sum_{n=1}^N \lvert z - z_n \rvert^2.$$ So this is almost the same as the formula you like to use; you only have to define the "distance" between angles as the distance between the corresponding points on the unit circle. That is, $d(\theta, \phi) = \sqrt{2 - 2\cos(\theta-\phi)} = 2 \sin(\lvert\theta-\phi\rvert/2)$. This metric is close to $\lvert\theta-\phi\rvert$ when $\theta$ and $\phi$ are close, and has the advantage of being really easy to find the solution to.