Open da5nsy opened 2 years ago
@da5nsy thanks for raising the issue.
First, a simple fix: If you remove one data point from t
when ap=500, it will returns the correct result.
It's indeed a bug. The current implementation doesn't cover all the edge cases for even number of samples.
When alpha
has an even number of samples, circstat returns the mean of two potential medians. For well-behaved data (mostly concentrated data), these two potential medians were likely nearby, thus this simplistic approach works well. But for not-so-well-bahaved data (e.g. too spread out, but there are many others...), such as yours, it returns the median and the anti-median, thus the mean of them would be 90 degrees off.
I think @hmselwyn and myself have found a bug while working with the code. For two almost identical vectors, one returns a median value 90 degrees offset from the other (with one being visually much more believable).
Here is code to reproduce: