Averaging angles... Again

algorithm, geometry, math

Solution

Thank you all for helping me see my problem more clearly.

I found what I was looking for. It is called Mitsuta method.

The inputs and output are in the range [0..360).

This method is good for averaging data that was sampled using constant sampling intervals.

The method assumes that the difference between successive samples is less than 180 degrees (which means that if we won't sample fast enough, a 330 degrees change in the sampled signal would be incorrectly detected as a 30 degrees change in the other direction and will insert an error into the calculation). Nyquist–Shannon sampling theorem anybody ?

Here is a c++ code:

double AngAvrg(const vector<double>& Ang)
{
    vector<double>::const_iterator iter= Ang.begin();
    
    double fD   = *iter;
    double fSigD= *iter;

    while (++iter != Ang.end())
    {
        double fDelta= *iter - fD;

             if (fDelta < -180.) fD+= fDelta + 360.;
        else if (fDelta >  180.) fD+= fDelta - 360.;
        else                     fD+= fDelta       ;

        fSigD+= fD;
    }

    double fAvrg= fSigD / Ang.size();

    if (fAvrg >= 360.) return fAvrg -360.;
    if (fAvrg <  0.  ) return fAvrg +360.;
                       return fAvrg      ;
}

It is explained on page 51 of Meteorological Monitoring Guidance for Regulatory Modeling Applications (PDF)(171 pp, 02-01-2000, 454-R-99-005)

Thank you MaR for sending the link as a comment.

If the sampled data is constant, but our sampling device has an inaccuracy with a Von Mises distribution, a unit-vectors calculation will be appropriate.

Problem

I want to calculate the average of a set of angles, which represents source bearing (0 to 360 deg) - (similar to wind-direction) I know it has been discussed before (several times). The accepted answer was Compute unit vectors from the angles and take the angle of their average. However this answer defines the average in a non intuitive way. The average of 0, 0 and 90 will be atan( (sin(0)+sin(0)+sin(90)) / (cos(0)+cos(0)+cos(90)) ) = atan(1/2)= 26.56 deg I would expect the average of 0, 0 and 90 to be 30 degrees. So I think it is fair to ask the question again: How would you calculate the average, so such examples will give the intuitive expected answer. Edit 2014: After asking this question, I've posted an article on CodeProject which offers a thorough analysis. The article examines the following reference problems: - Given time-of-day [00:00-24:00) for each birth occurred in US in the year 2000 - Calculate the mean birth time-of-day - Given a multiset of direction measurements from a stationary transmitter to a stationary receiver, using a measurement technique with a wrapped normal distributed error – Estimate the direction. - Given a multiset of azimuth estimates between two points, made by “ordinary” humans (assuming to subject to a wrapped truncated normal distributed error) – Estimate the direction.

Original source

Related problems