The Lehmer random number generator[1] (named after D. H. Lehmer), sometimes also referred to as the Park–Miller random number generator (after Stephen K. Park and Keith W. Miller), is a type of linear congruential generator (LCG) that operates in multiplicative group of integers modulo n. The general formula is:

\(\displaystyle X_{k+1}=a\cdot X_{k}{\text{ mod } {m}},\)

where the modulus m is a prime number or a power of a prime number, the multiplier a is an element of high multiplicative order modulo m (e.g., a primitive root modulo n), and the seed \(X_0\) is coprime to \(m\).

lcg_parkmiller(seed, n)

Arguments

seed

initial starting value

n

the number of random numbers you want to create.

Details

Other names are multiplicative linear congruential generator (MLCG)[2] and multiplicative congruential generator (MCG).

For more information see the Wikipedia page.

Examples

random_numbers <- lcg_parkmiller(1234, 1000)
# Plot numbers to see that they are random
plot(random_numbers)