# linear congruential generator

(algorithm)

**Definition:**
A class of *algorithms* that are *pseudo-random number generators*. The next number is generated from the current one by r_{n+1} = (A × r_{n} + B) mod M, where A and M are relatively prime numbers.

**Generalization** (I am a kind of ...)

*pseudo-random number generator*.

*Note:
When implemented in software, A and B may be chosen so as to have integer overflow on nearly every step, and therefore have a less predictable sequence and avoid the mod operation. The low-order bits tend to be less random than high-order bits. This is improved by discarding some of the low-order bits. Therefore, the range of random numbers is less than the range of the integer used in the computation. *

*
** Better algorithms are available, but they are more complex.*

Author: BB

## More information

Karl Entacher's thorough review and comparison of many linear congruential generators.

Go to the
Dictionary of Algorithms and Data
Structures home page.

If you have suggestions, corrections, or comments, please get in touch
with Paul Black.

Entry modified 1 February 2012.

HTML page formatted Fri Feb 23 10:06:08 2018.

Cite this as:

Bob Bockholt, "linear congruential generator", in
*Dictionary of Algorithms and Data Structures* [online], Vreda Pieterse and Paul E. Black, eds. 1 February 2012. (accessed TODAY)
Available from: https://www.nist.gov/dads/HTML/linearCongruentGen.html