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

Michael Gilbert michael.s.gilbert@gmail....
Wed Dec 10 13:03:39 CST 2008


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


More information about the Numpy-discussion mailing list