On 1/23/2010 1:09 AM, Steve Howell wrote:
On Jan 22, 5:12 pm, MRAB<pyt...@mrabarnett.plus.com> wrote:
I like this implementation, and it would probably work 99.9999% of the time for my particular use case. The only (very contrived) edge case that I can think of is when you have 10 bearings to SSW, 10 bearings to SSE, and the two outliers are unfortunately in the NE and NW quadrants. It seems like the algorithm above would pick one of the outliers. Maybe the refinement to the algorithm above would be to find the mean first, by summing sines and cosines of the bearings, taking the quotient, and applying the arctangent. Then use the resulting angle as the equivalent of "due north" and adjust angles to be within (-180, 180) respect to the mean, pretty much as you do in the code above, with minor modifications.
I was going to suggest this. Let us know if it seems to work.
I realize the problem as I stated it as sort of ill-defined.
Yes, I think this one reason stat books typically ignore directional data. I think it is an unfortunate omission.
Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list