[Numpy-discussion] von mises distribution in numpy.random biased

killian koepsell koepsell@gmail....
Sun Sep 9 21:47:03 CDT 2007


On 9/8/07, Travis E. Oliphant <oliphant@enthought.com> wrote:
> killian koepsell wrote:
> > hi,
> >
> > 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[1] package of R[2]
> > using RPy [3] and created a figure here:
> >
> >   http://redwood.berkeley.edu/kilian/vonmises.png
> >
>
> Interesting.
>
> 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.
>
> -Travis

hi travis,

thanks for fixing this so fast. it looks very good now:

  http://redwood.berkeley.edu/kilian/vonmises_new.png

kilian


More information about the Numpy-discussion mailing list