- Park–Miller random number generator
The Park–Miller random number generator (or the Lehmer random number generator) is a variant of
linear congruential generator that operates inmultiplicative group of integers modulo n . A general formula of a random generator (RNG) of this type is::
where "n" is a
prime number or a power of a prime number, "g" is an element of highmultiplicative order modulo "n" (e.g., aprimitive root modulo n ), and isco-prime to .Parameters in common use
Park and Miller suggested particular values (a
Mersenne prime ) and (a primitive root modulo ). The Park–Miller RNG with these parameters (known as "MINSTD") is a build-in RNG in Apple CarbonLib.ZX Spectrum uses the Park–Miller RNG with parameters (aFermat prime ) and "g=75" (a primitive root modulo ). The CRAY random number generator RANF uses a Park–Miller RNG with and . [http://www.gnu.org/software/gsl/manual/html_node/Other-random-number-generators.html GNU Scientific Library: Other random number generators] ] Another popular pair of parameters is and .The
GNU Scientific Library includes several random number generators of the Park-Miller form, including Park-Miller random number generator "MINSTD", the CRAY random number generator "RANF", and the infamous IBM random number generator "RANDU ".Relation to LCG
While the Park–Miller RNG can be viewed as a particular case of the
linear congruential generator with , it is a special case that implies certain restrictions and properties. In particular, for the Park–Miller RNG, the initial seed must be co-prime to the modulus "n" that is not required for LCGs in general. The choice of the modulus "n" and the multiplier "g" is also more restrictive for the Park–Miller RNG. In difference from LCG, the maximum period of the Park–Miller RNG equals "n-1" and it is such when "n" is prime and "g" is a primitive root modulo "n".On the other hand, the
discrete logarithm s (to base "g" or any primitive root modulo "n") of in represent linear congruential sequence moduloEuler totient .Sample C99 code
Using C99 code, this is written as follows:
#includeuint32_t lcg_rand (uint32_t a){ return ((uint64_t)a * 279470273) % 4294967291;}
References
* ( [http://www.firstpr.com.au/dsp/rand31/p85-payne.pdf alternative link to PDF] )
* ( [http://www.firstpr.com.au/dsp/rand31/p1192-park.pdf alternative link to PDF] )
* Steve Park [http://www.cs.wm.edu/~va/software/park/ Random Number Generators]
* [http://www.firstpr.com.au/dsp/rand31/ Park-Miller-Carta Pseudo-Random Number Generator]
Wikimedia Foundation. 2010.