[Numpy-discussion] von mises distribution in numpy.random biased
Travis E. Oliphant
Sat Sep 8 23:44:36 CDT 2007
killian koepsell wrote:
> the von mises distribution in numpy.random seems to be biased towards
> a higher concentration (kappa). given a concentration of 2, it
> produces data that has a concentration of 2.36. i compared the
> distribution to the one produced by the CircStats package of R
> using RPy  and created a figure here:
> the script i used is attached to this email. i don't know what
> algorithm NumPy uses, so i can't tell if it is a real bug or some sort
> of rounding error. the CircStats package uses the algorithm by Best
> and Fisher .
The algorithm in NumPy is basically the same algorithm. However, two
things are different about it and the one used in R (and in Python
itself by the way).
1) The two random variates used in the rejection algorithm are drawn
from a uniform on [-1,1]
2) The testing for the sign is done with the same random variable
instead of a new one.
I've updated the source to change both of these behaviors. I suspect
the bias is coming from 1)
Perhaps you could re-run your tests.
More information about the Numpy-discussion