where n is a prime number or a power of a prime number, g is an element of high multiplicative order modulo n (e.g., a primitive root modulo n), and is co-prime to .
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 (a Fermat prime ) and g=75 (a primitive root modulo ). The CRAY random number generator RANF uses a Park–Miller RNG with and . 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".
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 logarithms (to base g or any primitive root modulo n) of in represent linear congruential sequence modulo Euler totient .
Using C99 code, this is written as follows:
- include
uint32_t lcg_rand (uint32_t a) {
return ((uint64_t)a * 279470273) % 4294967291;}