Random numbers

Ivan Frohne frohne at gci.net
Tue May 23 09:53:15 CEST 2000


"Tim Peters" <tim_one at email.msn.com> wrote in message news:000401bfc45d$882e46c0$9ea2143f at tim...
> [Russell Wallace]
> > Is there any difference between the random number generator in the
> > 'random' module and that in the 'whrandom' one?
> 
> No, but you shouldn't use whrandom:  whrandom is an interal implementation
> detail of random.py.  whrandom.py should probably be renamed to _whrandom.py
> (or something) to stop people from tripping over it.
> 
> > What's the quality

You can find the algorithm used in whrandom.py and random.py (in Fortran 77) at
http://lib.stat.cmu.edu/apstat/183 .  It was published in the Journal of Applied
Statistics in 1982, and is now a little long in the tooth.  The period is about 7e12, 
which you might think is large, but, when you get right down to it, it's not large enough. 
In fact, an alternative algorithm with period 2e18 is now recommended at the site listed above.
But the truth of the matter is, random.py will give you perfectly fine uniform random numbers
for most purposes, if you're not too fussy, and don't need hundreds of millions of them.
  
> If you know enough about random numbers to understand an answer to that
> question, then telling you it's the standard Wichman-Hill (that's where "wh"
> comes from) generator is all the answer you need <wink>.  Seriously, test it
> and determine whether it's adequate for your application; if you can't test
> it objectively, then you have no way of knowing whether any other package is
> adequate either (and neither does anyone else, so don't ask).
> 
> Ivan Frohne wrote a very nice package of stronger generators, which should
> be available from his Starship page.  But unless you're doing extreme work,
> WH should be adequate for a start.  Any serious program relying on random
> numbers should be tested with at least two distinct generators, though, and
> Ivan's pkg is great for that.

Thanks for the plug, Tim.  I got lazy, though, and didn't move the module when the Starship
was born again.  I'll have it up again in a few days, though, and will publish
the new location then.  There's a new package in the works with some new stuff.

--Ivan Frohne 







More information about the Python-list mailing list