[Numpy-discussion] On the quality of the numpy.random.normal() distribution

Matthieu Brucher matthieu.brucher at gmail.com
Wed Dec 10 14:13:52 EST 2008


I think the use of a correct uniform generator will allow a good
normal distribution. Congruental generators are very basic generators,
everyone knows they should not be used. I think Numpy uses a Mersenne
Twisted generator, for which you can generate "independant" vectors
with several hundred values.

Matthieu

2008/12/10 Michael Gilbert <michael.s.gilbert at gmail.com>:
> Hello,
>
>  I have been reading that there may be potential issues with the
>  Box-Muller transform, which is used by the numpy.random.normal()
>  function.  Supposedly, since f*x1 and f*x2 are not independent variables, then
>  the individual elements (corresponding to f*x1 and f*x2 ) of the
>  distribution also won't be independent.  For example, see "Stochastic
>  Simulation" by Ripley, pages 54-59, where the random values end up
>  distributed on a spiral.  Note that they mention that they only looked
>  at "congruential generators."  Is the random number generator used
>  by numpy congruential?
>
>  I have tried to generate plots that demonstrate this problem, but have
>  come up short.  For example:
>
>   import numpy , pylab
>   nsamples = 10**6
>   n = numpy.random.normal( 0.0 , 1.0 , nsamples )
>   pylab.scatter( n[0:-1:2] , n[1:-1:2] , 0.1 )
>   pylab.show()
>
>  I can zoom in and out, and the scatter still looks random (white
>  noise -- almost like tv static).  Does this prove that there is no
>  problem?  And if so, why does numpy do a better job than as
>  demonstrated by Ripley?
>
>  Regards,
>  Mike Gilbert
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
>



-- 
Information System Engineer, Ph.D.
Website: http://matthieu-brucher.developpez.com/
Blogs: http://matt.eifelle.com and http://blog.developpez.com/?blog=92
LinkedIn: http://www.linkedin.com/in/matthieubrucher



More information about the NumPy-Discussion mailing list