Lably
Skip to content

Linear congruential generator

Algorithm for generating pseudo-randomized numbers

  • 17 min read
  • 7 chapters

Related on Lably

Through Algorithm, Modular arithmetic and Recurrence relation

The generator is defined by the recurrence relation:

Xn+1=(aXn+c)modm

where X is the sequence of pseudo-random values, and

m,0<m — the "modulus"
a,0<a<m — the "multiplier"
c,0≤c<m — the "increment"
X0,0≤X0<m — the "seed" or "start value"

are integer constants that specify the generator. If c = 0, the generator is often called a multiplicative congruential generator (MCG), or Lehmer RNG. If c ≠ 0, the method is called a mixed congruential generator.

When c ≠ 0, a mathematician would call the recurrence an affine transformation, not a linear one, but the misnomer is well-established in computer science.

History

The Lehmer generator was published in 1951 and the Linear congruential generator was published in 1958 by W. E. Thomson and A. Rotenberg.

Sign in to keep reading

6 more chapters are free with a Lably account.

More in Computing and communication