[Numpy-discussion] random and RandomArray

Robert Kern rkern at ucsd.edu
Wed Feb 16 20:06:17 EST 2005

Bruce Southey wrote:
> Hi, 
> I was browsing through some of the code and realized that certain random number 
> generators occur in both the Python random module and RandomArray.  
> The random module uses C code to get a scalar uniform random number that is 
> modified in Python by other generators to get random numbers from other 
> distributions. In RandomArray everything is done in the C code - obviously this 
> is way faster especially for arrays. 
> In the long term, would it make sense to get use the same random number 
> generators in both random and RandomArray? 

I think that it is certainly feasible and desirable that when/if a 
multiarray object enters the standard library that the standard random 
module be extended to produce arrays as well.

I don't think it's terribly worthwhile to hack the random module to 
expose its PRNG so that we use it's implementation without duplicating 
code. I think the result will be quite fragile, and won't be useful 
until Python 2.5.

I do think it would be extremely worthwhile to implement the Mersenne 
Twister for numarray/scipy. I promised some time ago to look into this, 
but I have not gotten around to it, unfortunately.

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