Linear congruential generator
A linear congruential generator (LCG) is an algorithm that yields a sequence of pseudorandomized numbers calculated with a discontinuous piecewise linear equation. The method represents one of the oldest and bestknown pseudorandom number generator algorithms. The theory behind them is relatively easy to understand, and they are easily implemented and fast, especially on computer hardware which can provide modular arithmetic by storagebit truncation.
The generator is defined by the recurrence relation:
where is the sequence of pseudorandom values, and
 — the "modulus"
 — the "multiplier"
 — the "increment"
 — 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.^{[1]}^{: 4 }
When c ≠ 0, a mathematician would call the recurrence an affine transformation, not a linear one, but the misnomer is wellestablished in computer science.^{[2]}^{: 1 }
History
[edit]The Lehmer generator was published in 1951^{[3]} and the Linear congruential generator was published in 1958 by W. E. Thomson and A. Rotenberg.^{[4]}^{[5]}
Period length
[edit]A benefit of LCGs is that an appropriate choice of parameters results in a period which is both known and long. Although not the only criterion, too short a period is a fatal flaw in a pseudorandom number generator.^{[6]}
While LCGs are capable of producing pseudorandom numbers which can pass formal tests for randomness, the quality of the output is extremely sensitive to the choice of the parameters m and a.^{[1]}^{[2]}^{[7]}^{[8]}^{[9]}^{[10]} For example, a = 1 and c = 1 produces a simple modulom counter, which has a long period, but is obviously nonrandom. Other values of c coprime to m produce a Weyl sequence, which is better distributed but still obviously nonrandom.
Historically, poor choices for a have led to ineffective implementations of LCGs. A particularly illustrative example of this is RANDU, which was widely used in the early 1970s and led to many results which are currently being questioned because of the use of this poor LCG.^{[11]}^{[8]}^{: 1198–9 }
There are three common families of parameter choice:
m prime, c = 0
[edit]This is the original Lehmer RNG construction. The period is m−1 if the multiplier a is chosen to be a primitive element of the integers modulo m. The initial state must be chosen between 1 and m−1.
One disadvantage of a prime modulus is that the modular reduction requires a doublewidth product and an explicit reduction step. Often a prime just less than a power of 2 is used (the Mersenne primes 2^{31}−1 and 2^{61}−1 are popular), so that the reduction modulo m = 2^{e} − d can be computed as (ax mod 2^{e}) + d ⌊ax/2^{e}⌋. This must be followed by a conditional subtraction of m if the result is too large, but the number of subtractions is limited to ad/m, which can be easily limited to one if d is small.
If a doublewidth product is unavailable, and the multiplier is chosen carefully, Schrage's method^{[12]} may be used. To do this, factor m = qa+r, i.e. q = ⌊m/a⌋ and r = m mod a. Then compute ax mod m = a(x mod q) − r⌊x/q⌋. Since x mod q < q ≤ m/a, the first term is strictly less than am/a = m. If a is chosen so that r ≤ q (and thus r/q ≤ 1), then the second term is also less than m: r⌊x/q⌋ ≤ rx/q = x(r/q) ≤ x < m. Thus, both products can be computed with a singlewidth product, and the difference between them lies in the range [1−m, m−1], so can be reduced to [0, m−1] with a single conditional add.^{[13]}
A second disadvantage is that it is awkward to convert the value 1 ≤ x < m to uniform random bits. If a prime just less than a power of 2 is used, sometimes the missing values are simply ignored.
m a power of 2, c = 0
[edit]Choosing m to be a power of two, most often m = 2^{32} or m = 2^{64}, produces a particularly efficient LCG, because this allows the modulus operation to be computed by simply truncating the binary representation. In fact, the most significant bits are usually not computed at all. There are, however, disadvantages.
This form has maximal period m/4, achieved if a ≡ ±3 (mod 8) and the initial state X_{0} is odd. Even in this best case, the low three bits of X alternate between two values and thus only contribute one bit to the state. X is always odd (the lowestorder bit never changes), and only one of the next two bits ever changes. If a ≡ +3, X alternates ±1↔±3, while if a ≡ −3, X alternates ±1↔∓3 (all modulo 8).
It can be shown that this form is equivalent to a generator with modulus m/4 and c ≠ 0.^{[1]}
A more serious issue with the use of a poweroftwo modulus is that the low bits have a shorter period than the high bits. Its simplicity of implementation comes from the fact that bits are never affected by higherorder bits, so the low b bits of such a generator form a modulo2^{b} LCG by themselves, repeating with a period of 2^{b−2}. Only the most significant bit of X achieves the full period.
m a power of 2, c ≠ 0
[edit]When c ≠ 0, correctly chosen parameters allow a period equal to m, for all seed values. This will occur if and only if:^{[1]}^{: 17–19 }
 and are coprime,
 is divisible by all prime factors of ,
 is divisible by 4 if is divisible by 4.
These three requirements are referred to as the Hull–Dobell Theorem.^{[14]}^{[15]}
This form may be used with any m, but only works well for m with many repeated prime factors, such as a power of 2; using a computer's word size is the most common choice. If m were a squarefree integer, this would only allow a ≡ 1 (mod m), which makes a very poor PRNG; a selection of possible fullperiod multipliers is only available when m has repeated prime factors.
Although the Hull–Dobell theorem provides maximum period, it is not sufficient to guarantee a good generator.^{[8]}^{: 1199 } For example, it is desirable for a − 1 to not be any more divisible by prime factors of m than necessary. If m is a power of 2, then a − 1 should be divisible by 4 but not divisible by 8, i.e. a ≡ 5 (mod 8).^{[1]}^{: §3.2.1.3 }
Indeed, most multipliers produce a sequence which fails one test for nonrandomness or another, and finding a multiplier which is satisfactory to all applicable criteria^{[1]}^{: §3.3.3 } is quite challenging.^{[8]} The spectral test is one of the most important tests.^{[16]}
Note that a powerof2 modulus shares the problem as described above for c = 0: the low k bits form a generator with modulus 2^{k} and thus repeat with a period of 2^{k}; only the most significant bit achieves the full period. If a pseudorandom number less than r is desired, ⌊rX/m⌋ is a much higherquality result than X mod r. Unfortunately, most programming languages make the latter much easier to write (X % r
), so it is very commonly used.
The generator is not sensitive to the choice of c, as long as it is relatively prime to the modulus (e.g. if m is a power of 2, then c must be odd), so the value c=1 is commonly chosen.
The sequence produced by other choices of c can be written as a simple function of the sequence when c=1.^{[1]}^{: 11 } Specifically, if Y is the prototypical sequence defined by Y_{0} = 0 and Y_{n+1} = aY_{n} + 1 mod m, then a general sequence X_{n+1} = aX_{n} + c mod m can be written as an affine function of Y:
More generally, any two sequences X and Z with the same multiplier and modulus are related by
In the common case where m is a power of 2 and a ≡ 5 (mod 8) (a desirable property for other reasons), it is always possible to find an initial value X_{0} so that the denominator X_{1} − X_{0} ≡ ±1 (mod m), producing an even simpler relationship. With this choice of X_{0}, X_{n} = X_{0} ± Y_{n} will remain true for all n.^{[2]}^{: 1011 } The sign is determined by c ≡ ±1 (mod 4), and the constant X_{0} is determined by 1 ∓ c ≡ (1 − a)X_{0} (mod m).
As a simple example, consider the generators X_{n+1} = 157X_{n} + 3 mod 256 and Y_{n+1} = 157Y_{n} + 1 mod 256; i.e. m = 256, a = 157, and c = 3. Because 3 ≡ −1 (mod 4), we are searching for a solution to 1 + 3 ≡ (1 − 157)X_{0} (mod 256). This is satisfied by X_{0} ≡ 41 (mod 64), so if we start with that, then X_{n} ≡ X_{0} − Y_{n} (mod 256) for all n.
For example, using X_{0} = 233 = 3×64 + 41:
 X = 233, 232, 75, 2, 61, 108, ...
 Y = 0, 1, 158, 231, 172, 125, ...
 X + Y mod 256 = 233, 233, 233, 233, 233, 233, ...
Parameters in common use
[edit]The following table lists the parameters of LCGs in common use, including builtin rand() functions in runtime libraries of various compilers. This table is to show popularity, not examples to emulate; many of these parameters are poor. Tables of good parameters are available.^{[10]}^{[2]}
Source  modulus m 
multiplier a 
increment c 
output bits of seed in rand() or Random(L) 

ZX81  2^{16} + 1  75  74  
Numerical Recipes ranqd1 , Chapter 7.1, §An Even Quicker Generator, Eq. 7.1.6parameters from Knuth and H. W. Lewis 
2^{32}  1664525  1013904223  
Borland C/C++  2^{31}  22695477  1  bits 30..16 in rand(), 30..0 in lrand() 
glibc (used by GCC)^{[17]}  2^{31}  1103515245  12345  bits 30..0 
ANSI C: Watcom, Digital Mars, CodeWarrior, IBM VisualAge C/C++^{[18]} C90, C99, C11: Suggestion in the ISO/IEC 9899,^{[19]} C17 
2^{31}  1103515245  12345  bits 30..16 
Borland Delphi, Virtual Pascal  2^{32}  134775813  1  bits 63..32 of (seed × L) 
Turbo Pascal 4.0 et seq.^{[20]}  2^{32}  134775813 (8088405_{16})  1  
Microsoft Visual/Quick C/C++  2^{31}  214013 (343FD_{16})  2531011 (269EC3_{16})  bits 30..16 
Microsoft Visual Basic (6 and earlier)^{[21]}  2^{24}  16598013 (FD43FD_{16})  12820163 (C39EC3_{16})  
RtlUniform from Native API^{[22]}^{[23]}  2^{31} − 1  −18 (7FFFFFED_{16})  −60 (7FFFFFC3_{16})  
Apple CarbonLib, C++11's minstd_rand0 ,^{[24]} MATLAB's v4 legacy generator mcg16807^{[25]} 
2^{31} − 1  16807  0  see MINSTD 
C++11's minstd_rand ^{[24]} 
2^{31} − 1  48271  0  see MINSTD 
MMIX by Donald Knuth  2^{64}  6364136223846793005  1442695040888963407  
Newlib^{[26]}  2^{63}  6364136223846793005  1  bits 62..32 (46..32 for 16bit int) 
Musl  2^{64}  6364136223846793005  1  bits 63..33 
VMS's MTH$RANDOM,^{[27]} old versions of glibc  2^{32}  69069 (10DCD_{16})  1  
Java's java.util.Random, POSIX [ln]rand48, glibc [ln]rand48[_r]  2^{48}  25214903917 (5DEECE66D_{16})  11  bits 47..16 

134456 = 2^{3}7^{5}  8121  28411  
POSIX^{[33]} [dejm]rand48, glibc [dejm]rand48[_r]  2^{48}  25214903917 (5DEECE66D_{16})  11  bits 47..0 or bits 47..15, as required 
cc65^{[34]}  2^{23}  65793 (10101_{16})  4282663 (415927_{16})  bits 22..8 
cc65  2^{32}  16843009 (1010101_{16})  826366247 (31415927_{16})  bits 31..16 
cc65  2^{32}  16843009 (1010101_{16})  3014898611 (B3B3B3B3_{16})  previously bits 31..16, current bits 31..16 xor bits 14..0 
Formerly common: RANDU^{[11]}  2^{31}  65539  0 
As shown above, LCGs do not always use all of the bits in the values they produce. In general, they return the most significant bits. For example, the Java implementation operates with 48bit values at each iteration but returns only their 32 most significant bits. This is because the higherorder bits have longer periods than the lowerorder bits (see below). LCGs that use this truncation technique produce statistically better values than those that do not. This is especially noticeable in scripts that use the mod operation to reduce range; modifying the random number mod 2 will lead to alternating 0 and 1 without truncation.
Contrarily, some libraries use an implicit poweroftwo modulus but never output or otherwise use the most significant bit, in order to limit the output to positive two's complement integers. The output is as if the modulus were one bit less than the internal word size, and such generators are described as such in the table above.
Advantages and disadvantages
[edit]This section needs additional citations for verification. (July 2021) 
LCGs are fast and require minimal memory (one modulom number, often 32 or 64 bits) to retain state. This makes them valuable for simulating multiple independent streams. LCGs are not intended, and must not be used, for cryptographic applications; use a cryptographically secure pseudorandom number generator for such applications.
Although LCGs have a few specific weaknesses, many of their flaws come from having too small a state. The fact that people have been lulled for so many years into using them with such small moduli can be seen as a testament to the strength of the technique. A LCG with large enough state can pass even stringent statistical tests; a modulo2^{64} LCG which returns the high 32 bits passes TestU01's SmallCrush suite,^{[citation needed]} and a 96bit LCG passes the most stringent BigCrush suite.^{[35]}
For a specific example, an ideal random number generator with 32 bits of output is expected (by the Birthday theorem) to begin duplicating earlier outputs after √m ≈ 2^{16} results. Any PRNG whose output is its full, untruncated state will not produce duplicates until its full period elapses, an easily detectable statistical flaw.^{[36]} For related reasons, any PRNG should have a period longer than the square of the number of outputs required. Given modern computer speeds, this means a period of 2^{64} for all but the least demanding applications, and longer for demanding simulations.
One flaw specific to LCGs is that, if used to choose points in an ndimensional space, the points will lie on, at most, ^{n}√n!⋅m hyperplanes (Marsaglia's theorem, developed by George Marsaglia).^{[7]} This is due to serial correlation between successive values of the sequence X_{n}. Carelessly chosen multipliers will usually have far fewer, widely spaced planes, which can lead to problems. The spectral test, which is a simple test of an LCG's quality, measures this spacing and allows a good multiplier to be chosen.
The plane spacing depends both on the modulus and the multiplier. A large enough modulus can reduce this distance below the resolution of double precision numbers. The choice of the multiplier becomes less important when the modulus is large. It is still necessary to calculate the spectral index and make sure that the multiplier is not a bad one, but purely probabilistically it becomes extremely unlikely to encounter a bad multiplier when the modulus is larger than about 2^{64}.
Another flaw specific to LCGs is the short period of the loworder bits when m is chosen to be a power of 2. This can be mitigated by using a modulus larger than the required output, and using the most significant bits of the state.
Nevertheless, for some applications LCGs may be a good option. For instance, in an embedded system, the amount of memory available is often severely limited. Similarly, in an environment such as a video game console taking a small number of highorder bits of an LCG may well suffice. (The loworder bits of LCGs when m is a power of 2 should never be relied on for any degree of randomness whatsoever.) The low order bits go through very short cycles. In particular, any fullcycle LCG, when m is a power of 2, will produce alternately odd and even results.
LCGs should be evaluated very carefully for suitability in noncryptographic applications where highquality randomness is critical. For Monte Carlo simulations, an LCG must use a modulus greater and preferably much greater than the cube of the number of random samples which are required. This means, for example, that a (good) 32bit LCG can be used to obtain about a thousand random numbers; a 64bit LCG is good for about 2^{21} random samples (a little over two million), etc. For this reason, in practice LCGs are not suitable for largescale Monte Carlo simulations.
Sample code
[edit]Python code
[edit]The following is an implementation of an LCG in Python, in the form of a generator:
from collections.abc import Generator
def lcg(modulus: int, a: int, c: int, seed: int) > Generator[int, None, None]:
"""Linear congruential generator."""
while True:
seed = (a * seed + c) % modulus
yield seed
Free Pascal
[edit]Free Pascal uses a Mersenne Twister as its default pseudo random number generator whereas Delphi uses a LCG. Here is a Delphi compatible example in Free Pascal based on the information in the table above. Given the same RandSeed value it generates the same sequence of random numbers as Delphi.
unit lcg_random;
{$ifdef fpc}{$mode delphi}{$endif}
interface
function LCGRandom: extended; overload; inline;
function LCGRandom(const range:longint): longint; overload; inline;
implementation
function IM: cardinal; inline;
begin
RandSeed := RandSeed * 134775813 + 1;
Result := RandSeed;
end;
function LCGRandom: extended; overload; inline;
begin
Result := IM * 2.32830643653870e10;
end;
function LCGRandom(const range: longint): longint; overload; inline;
begin
Result := IM * range shr 32;
end;
Like all pseudorandom number generators, a LCG needs to store state and alter it each time it generates a new number. Multiple threads may access this state simultaneously causing a race condition. Implementations should use different state each with unique initialization for different threads to avoid equal sequences of random numbers on simultaneously executing threads.
LCG derivatives
[edit]There are several generators which are linear congruential generators in a different form, and thus the techniques used to analyze LCGs can be applied to them.
One method of producing a longer period is to sum the outputs of several LCGs of different periods having a large least common multiple; the Wichmann–Hill generator is an example of this form. (We would prefer them to be completely coprime, but a prime modulus implies an even period, so there must be a common factor of 2, at least.) This can be shown to be equivalent to a single LCG with a modulus equal to the product of the component LCG moduli.
Marsaglia's addwithcarry and subtractwithborrow PRNGs with a word size of b=2^{w} and lags r and s (r > s) are equivalent to LCGs with a modulus of b^{r} ± b^{s} ± 1.^{[37]}^{[38]}
Multiplywithcarry PRNGs with a multiplier of a are equivalent to LCGs with a large prime modulus of ab^{r}−1 and a powerof2 multiplier b.
A permuted congruential generator begins with a powerof2modulus LCG and applies an output transformation to eliminate the short period problem in the loworder bits.
Comparison with other PRNGs
[edit]The other widely used primitive for obtaining longperiod pseudorandom sequences is the linearfeedback shift register construction, which is based on arithmetic in GF(2)[x], the polynomial ring over GF(2). Rather than integer addition and multiplication, the basic operations are exclusiveor and carryless multiplication, which is usually implemented as a sequence of logical shifts. These have the advantage that all of their bits are fullperiod; they do not suffer from the weakness in the loworder bits that plagues arithmetic modulo 2^{k}.^{[39]}
Examples of this family include xorshift generators and the Mersenne twister. The latter provides a very long period (2^{19937}−1) and variate uniformity, but it fails some statistical tests.^{[40]} Lagged Fibonacci generators also fall into this category; although they use arithmetic addition, their period is ensured by an LFSR among the leastsignificant bits.
It is easy to detect the structure of a linearfeedback shift register with appropriate tests^{[41]} such as the linear complexity test implemented in the TestU01 suite; a boolean circulant matrix initialized from consecutive bits of an LFSR will never have rank greater than the degree of the polynomial. Adding a nonlinear output mixing function (as in the xoshiro256** and permuted congruential generator constructions) can greatly improve the performance on statistical tests.
Another structure for a PRNG is a very simple recurrence function combined with a powerful output mixing function. This includes counter mode block ciphers and noncryptographic generators such as SplitMix64.
A structure similar to LCGs, but not equivalent, is the multiplerecursive generator: X_{n} = (a_{1}X_{n−1} + a_{2}X_{n−2} + ··· + a_{k}X_{n−k}) mod m for k ≥ 2. With a prime modulus, this can generate periods up to m^{k}−1, so is a useful extension of the LCG structure to larger periods.
A powerful technique for generating highquality pseudorandom numbers is to combine two or more PRNGs of different structure; the sum of an LFSR and an LCG (as in the KISS or xorwow constructions) can do very well at some cost in speed.
See also
[edit] List of random number generators – other PRNGs including some with better statistical qualitites
 ACORN generator – not to be confused with ACG which term appears to have been used for variants of LCG and LFSR generators
 Permuted congruential generator
 Full cycle
 Inversive congruential generator
 Multiplywithcarry
 Lehmer RNG (sometimes called the Park–Miller RNG)
 Combined linear congruential generator
Notes
[edit] ^ ^{a} ^{b} ^{c} ^{d} ^{e} ^{f} ^{g} Knuth, Donald (1997). Seminumerical Algorithms. The Art of Computer Programming. Vol. 2 (3rd ed.). Reading, MA: AddisonWesley Professional. pp. 10–26.
 ^ ^{a} ^{b} ^{c} ^{d} Steele, Guy L. Jr.; Vigna, Sebastiano (February 2022) [15 January 2020]. "Computationally easy, spectrally good multipliers for congruential pseudorandom number generators" (PDF). Software: Practice and Experience. 52 (2): 443–458. arXiv:2001.05304. doi:10.1002/spe.3030.
these denominations, by now used for half a century, are completely wrong from a mathematical viewpoint.... At this point it is unlikely that the nowtraditional names will be corrected.
Associated software and data at https://github.com/vigna/CPRNG.  ^ Lehmer, Derrick H. (1951). "Mathematical methods in largescale computing units". Proceedings of 2nd Symposium on LargeScale Digital Calculating Machinery: 141–146.
 ^ Thomson, W. E. (1958). "A Modified Congruence Method of Generating Pseudorandom Numbers". The Computer Journal. 1 (2): 83. doi:10.1093/comjnl/1.2.83.
 ^ Rotenberg, A. (1960). "A New PseudoRandom Number Generator". Journal of the ACM. 7 (1): 75–77. doi:10.1145/321008.321019. S2CID 16770825.
 ^ L'Ecuyer, Pierre (13 July 2017). Chan, W. K. V.; D'Ambrogio, A.; Zacharewicz, G.; Mustafee, N.; Wainer, G.; Page, E. (eds.). History of Uniform Random Number Generation (PDF). Proceedings of the 2017 Winter Simulation Conference (to appear). Las Vegas, United States. hal01561551.
 ^ ^{a} ^{b} Marsaglia, George (September 1968). "Random Numbers Fall Mainly in the Planes" (PDF). PNAS. 61 (1): 25–28. Bibcode:1968PNAS...61...25M. doi:10.1073/pnas.61.1.25. PMC 285899. PMID 16591687.
 ^ ^{a} ^{b} ^{c} ^{d} Park, Stephen K.; Miller, Keith W. (October 1988). "Random Number Generators: Good Ones Are Hard To Find" (PDF). Communications of the ACM. 31 (10): 1192–1201. doi:10.1145/63039.63042. S2CID 207575300.
In a sense it is unfortunate that this test for full period is so trivial as it falsely encourages nonspecialists to build their own generators.
 ^ Hörmann, Wolfgang; Derflinger, Gerhard (1993). "A Portable Uniform Random Number Generator Well Suited for the Rejection Method" (PDF). ACM Transactions on Mathematical Software. 19 (4): 489–495. CiteSeerX 10.1.1.52.3811. doi:10.1145/168173.168414. S2CID 15238956.
a multiplier about as small as √m, produces random numbers with a bad onedimensional distribution.
 ^ ^{a} ^{b} L'Ecuyer, Pierre (January 1999). "Tables of Linear Congruential Generators of Different Sizes and Good Lattice Structure" (PDF). Mathematics of Computation. 68 (225): 249–260. Bibcode:1999MaCom..68..249L. CiteSeerX 10.1.1.34.1024. doi:10.1090/S0025571899009965. Be sure to read the Errata as well.
 ^ ^{a} ^{b} Press, William H.; et al. (1992). Numerical Recipes in Fortran 77: The Art of Scientific Computing (2nd ed.). p. 268. ISBN 9780521430647.
 ^ Jain, Raj (9 July 2010). "Computer Systems Performance Analysis Chapter 26: RandomNumber Generation" (PDF). pp. 19–20. Retrieved 20171031.
 ^ Fenerty, Paul (11 September 2006). "Schrage's Method". Retrieved 20171031.
 ^ Hull, T. E.; Dobell, A. R. (July 1962). "Random Number Generators" (PDF). SIAM Review. 4 (3): 230–254. Bibcode:1962SIAMR...4..230H. doi:10.1137/1004061. hdl:1828/3142. Retrieved 20160626.
 ^ Severance, Frank (2001). System Modeling and Simulation. John Wiley & Sons, Ltd. p. 86. ISBN 9780471496946.
 ^ Austin, David (March 2008). "Random Numbers: Nothing Left to Chance". Feature Column. American Mathematical Society.
 ^ Implementation in glibc2.26 release. See the code after the test for "TYPE_0"; the GNU C library's rand() in stdlib.h uses a simple (single state) linear congruential generator only in case that the state is declared as 8 bytes. If the state is larger (an array), the generator becomes an additive feedback generator (initialized using minstd_rand0) and the period increases. See the simplified code that reproduces the random sequence from this library.
 ^ K. Entacher (21 August 1997). A collection of selected pseudorandom number generators with linear structures. CiteSeerX 10.1.1.53.3686. Retrieved 16 June 2012.
 ^ "Last public Committee Draft from April 12, 2011" (PDF). p. 346f. Retrieved 21 Dec 2014.
 ^ Dohmann, Birgit; Falk, Michael; Lessenich, Karin (August 1991). "The random number generators of the Turbo Pascal family". Computational Statistics & Data Analysis. 12 (1): 129–132. doi:10.1016/01679473(91)90108E.
 ^ "How Visual Basic Generates PseudoRandom Numbers for the RND Function". Microsoft. 24 June 2004. Archived from the original on 17 April 2011. Retrieved 17 June 2011.
 ^ In spite of documentation on MSDN, RtlUniform uses LCG, and not Lehmer's algorithm, implementations before Windows Vista are flawed, because the result of multiplication is cut to 32 bits, before modulo is applied
 ^ "WINE source identifier search: RtlUniform". Retrieved 20240113.
 ^ ^{a} ^{b} "ISO/IEC 14882:2011". ISO. 2 September 2011. Retrieved 3 September 2011.
 ^ "Creating and Controlling a Random Number Stream". MathWorks. Retrieved 7 June 2021.
 ^ "
rand
,srand
—pseudorandom numbers". Newlib git repository. Retrieved 20240113.  ^ "GNU Scientific Library: gsl_rng_vax".
 ^ Stephen J. Chapman. "Example 6.4 – Random Number Generator". "MATLAB Programming for Engineers". 2015. pp. 253–256.
 ^ Stephen J. Chapman. "Example 6.4 – Random Number Generator". "MATLAB Programming with Applications for Engineers". 2012. pp. 292–295.
 ^ S. J. Chapman. random0. 2004.
 ^ Stephen J. Chapman. "Introduction to Fortran 90/95". 1998. pp. 322–324.
 ^ Wuting Tsai. "'Module': A Major Feature of the Modern Fortran" Archived 20210224 at the Wayback Machine. pp. 6–7.
 ^ The Open Group Base Specifications Issue 7 IEEE Std 1003.1, 2013 Edition
 ^ Cadot, Sidney. "rand.s". cc65. Retrieved 8 July 2016.
 ^ O'Neill, Melissa E. (5 September 2014). PCG: A Family of Simple Fast SpaceEfficient Statistically Good Algorithms for Random Number Generation (PDF) (Technical report). Harvey Mudd College. pp. 6–7. HMCCS20140905.
 ^ Heath, David; Sanchez, Paul (June 1986). "On the adequacy of pseudorandom number generators (or: How big a period do we need?)". Operations Research Letters. 5 (1): 3–6. doi:10.1016/01676377(86)900921.
 ^ Tezuka, Shu; L'Ecuyer, Pierre (October 1993). On the Lattice Structure of the AddwithCarry and SubtractwithBorrow Random Number Generators (PDF). Workshop on Stochastic Numerics. Kyoto University.
 ^ Tezuka, Shi; L'Ecuyer, Pierre (December 1992). Analysis of AddwithCarry and SubtractwithBorrow Generators (PDF). Proceedings of the 1992 Winter Simulation Conference. pp. 443–447.
 ^ Gershenfeld, Neil (1999). "Section 5.3.2: Linear Feedback". The Nature of Mathematical Modeling (First ed.). Cambridge University Press. p. 59. ISBN 9780521570954.
 ^ Matsumoto, Makoto; Nishimura, Takuji (January 1998). "Mersenne twister: a 623dimensionally equidistributed uniform pseudorandom number generator" (PDF). ACM Transactions on Modeling and Computer Simulation. 8 (1): 3–30. CiteSeerX 10.1.1.215.1141. doi:10.1145/272991.272995. S2CID 3332028. Archived from the original (PDF) on 20171107.
 ^ Eastlake, Donald E. 3rd; Schiller, Jeffrey I.; Crocker, Steve (June 2005). "Traditional Pseudorandom Sequences". Randomness Requirements for Security. IETF. sec. 6.1.3. doi:10.17487/RFC4086. BCP 106. RFC 4086.
References
[edit] Press, WH; Teukolsky, SA; Vetterling, WT; Flannery, BP (2007), "Section 7.1.1. Some History", Numerical Recipes: The Art of Scientific Computing (3rd ed.), New York: Cambridge University Press, ISBN 9780521880688, archived from the original on 20110811, retrieved 20110810
 Gentle, James E., (2003). Random Number Generation and Monte Carlo Methods, 2nd edition, Springer, ISBN 0387001786.
 Joan Boyar (1989). "Inferring sequences produced by pseudorandom number generators" (PDF). Journal of the ACM. 36 (1): 129–141. doi:10.1145/58562.59305. S2CID 3565772. (in this paper, efficient algorithms are given for inferring sequences produced by certain pseudorandom number generators).
External links
[edit] The simulation Linear Congruential Generator visualizes the correlations between the pseudorandom numbers when manipulating the parameters.
 Security of Random Number Generation: An Annotated Bibliography
 Linear Congruential Generators post to sci.math
 The "Death of Art" computer art project at Goldstein Technologies LLC, uses an LCG to generate 33,554,432 images
 P. L'Ecuyer and R. Simard, "TestU01: A C Library for Empirical Testing of Random Number Generators", May 2006, revised November 2006, ACM Transactions on Mathematical Software, 33, 4, Article 22, August 2007.
 Article about another way of cracking LCG