[Numpy-discussion] random number facilities in numarray and main Python libs

Robert Kern rkern at ucsd.edu
Tue Sep 7 16:36:01 CDT 2004


Faheem Mitha wrote:
[snip]
> Are the random number facilities provided by numarray.random_array 
> superior to those provided to those provided by the random module in the 
> Python library? They certainly seem more extensive, and I like the 
> interface better.
> 
> If so, why not replace the random module by the equivalent functionality 
> from numarray.random_array, and have everyone use the same random number 
> generator? Or is this impossible for practical reasons?

numarray.random_array can generate arrays full of random numbers. 
Standard Python's random does not and will not until numarray is part of 
the standard library. Standard Python's random also uses the Mersenne 
Twister algorithm which is, by most accounts, superior to RANLIB's 
algorithm, so I for one would object to replacing it with numarray's 
code.  :-)

I do intend to implement the Mersenne Twister algorithm for SciPy's PRNG 
facilities (on some unspecified weekend). I will also try to code 
something up for numarray, too.

> By the way, what is the name of the pseudo-random number generator being 
> used? I see that the code is in Packages/RandomArray2/Src, but could not 
> see where the name of the generator is mentioned.

<URL:http://orion.math.iastate.edu/burkardt/c_src/ranlib/ranlib_base.txt>
documents the base algorithm.

>                                                                 Faheem.

-- 
Robert Kern
rkern at ucsd.edu

"In the fields of hell where the grass grows high
  Are the graves of dreams allowed to die."
   -- Richard Harter




More information about the Numpy-discussion mailing list