Random Numbers

Scott Robert Ladd coyote@coyotegulch.com
Sat Apr 24 17:45:00 GMT 2004


Tobias Schlüter wrote:
> We can't serve everybody, can we? :-) I don't even think a thread-safe 
> RNG is something we should care that much about, if people care they'll 
> write it themselves as the Fortran standard doesn't guarantee anything 
> like this. I only meant to point out that this goal can most likely be 
> easier attained with Andy's (Marsaglia's) algorithm than with the 
> Mersenne twister.

Agreed -- although, as my other message points out, there may be several 
"Marsaglia" generators we should consider. Much as I've found the 
Mersenne Twister appealing in the past, I've determined that some of 
Marsaglia's generators perform faster (especially on 64-bit systems) 
with simpler implementations.

Andy implements one of Marsaglia's short-period generators. His 
statement that "It is difficult to imagine a better random number 
generator" is somewhat naive, since what you want from a PRNG depends on 
your goals. Passing DIEHARD is not the only test.

Is Andy's routine good enough? Probably. Is it better than the Mersenne 
Twister? Possibly, especially in terms of simplicity. Could another 
generator be a better choice? Perhaps.

The design of Fortran 90's RANDOM_SEED function suggests that the 
RANDOM_NUMBER routine implements an algorithm that requires an array of 
seeds. In terms of xorshf96 (Andy's algorithm), using only three values 
may not fit that model. Your mileage may vary, depending on how much 
stock you put in the implications of RANDOM_SEED's optional array argument.

-- 
Scott Robert Ladd
Coyote Gulch Productions (http://www.coyotegulch.com)
Software Invention for High-Performance Computing



More information about the Fortran mailing list