Combined linear congruential generator

Last updated

A combined linear congruential generator (CLCG) is a pseudo-random number generator algorithm based on combining two or more linear congruential generators (LCG). A traditional LCG has a period which is inadequate for complex system simulation. [1] By combining two or more LCGs, random numbers with a longer period and better statistical properties can be created. [1] The algorithm is defined as: [2]

Contents

where:

with:

where is a uniformly distributed random number between 0 and 1.

Derivation

If Wi,1, Wi,2, ..., Wi,k are any independent, discrete, random-variables and one of them is uniformly distributed from 0 to m1  2, then Zi is uniformly distributed between 0 and m1  2, where: [2]

Let Xi,1, Xi,2, ..., Xi,k be outputs from k LCGs. If Wi,j is defined as Xi,j  1, then Wi,j will be approximately uniformly distributed from 0 to mj  1. [2] The coefficient "(1)j1" implicitly performs the subtraction of one from Xi,j. [1]

Properties

The CLCG provides an efficient way to calculate pseudo-random numbers. The LCG algorithm is computationally inexpensive to use. [3] The results of multiple LCG algorithms are combined through the CLCG algorithm to create pseudo-random numbers with a longer period than is achievable with the LCG method by itself. [3]

The period of a CLCG is the least common multiple of the periods of the individual generators, which are one less than the moduli. Since all the moduli are odd primes, the periods are even and thus share at least a common divisor of 2, but if the moduli are chosen so that 2 is the greatest common divisor of each pair, this will result in a period of: [1]

Example

The following is an example algorithm designed for use in 32-bit computers: [2]

LCGs are used with the following properties:

The CLCG algorithm is set up as follows:

  1. The seed for the first LCG, , should be selected in the range of [1, 2147483562]. The seed for the second LCG, , should be selected in the range of [1, 2147483398]. Set:
  2. The two LCGs are evaluated as follows:
  3. The CLCG equation is solved as shown below:
  4. Calculate the random number:
  5. Increment the counter (i := i + 1) then return to step 2 and repeat.

The maximum period of the two LCGs used is calculated using the formula: [1]

This equates to 2.1×109 for the two LCGs used.

This CLCG shown in this example has a maximum period of:

This represents a tremendous improvement over the period of the individual LCGs. It can be seen that the combined method increases the period by 9 orders of magnitude.

Surprisingly the period of this CLCG may not be sufficient for all applications. [1] Other algorithms using the CLCG method have been used to create pseudo-random number generators with periods as long as 3×1057. [4] [5] [6]

The former of the two generators, using b = 40,014 and m = 2,147,483,563, is also used by the Texas Instruments TI-30X IIS scientific calculator.

See also

Related Research Articles

<span class="mw-page-title-main">Chinese remainder theorem</span> Theorem for solving simultaneous congruences

In mathematics, the Chinese remainder theorem states that if one knows the remainders of the Euclidean division of an integer n by several integers, then one can determine uniquely the remainder of the division of n by the product of these integers, under the condition that the divisors are pairwise coprime.

A pseudorandom number generator (PRNG), also known as a deterministic random bit generator (DRBG), is an algorithm for generating a sequence of numbers whose properties approximate the properties of sequences of random numbers. The PRNG-generated sequence is not truly random, because it is completely determined by an initial value, called the PRNG's seed. Although sequences that are closer to truly random can be generated using hardware random number generators, pseudorandom number generators are important in practice for their speed in number generation and their reproducibility.

<span class="mw-page-title-main">Linear congruential generator</span> Algorithm for generating pseudo-randomized numbers

A linear congruential generator (LCG) is an algorithm that yields a sequence of pseudo-randomized numbers calculated with a discontinuous piecewise linear equation. The method represents one of the oldest and best-known 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 storage-bit truncation.

The Mersenne Twister is a general-purpose pseudorandom number generator (PRNG) developed in 1997 by Makoto Matsumoto and Takuji Nishimura. Its name derives from the fact that its period length is chosen to be a Mersenne prime.

A Lagged Fibonacci generator is an example of a pseudorandom number generator. This class of random number generator is aimed at being an improvement on the 'standard' linear congruential generator. These are based on a generalisation of the Fibonacci sequence.

<span class="mw-page-title-main">RANDU</span>

RANDU is a linear congruential pseudorandom number generator (LCG) of the Park–Miller type, which was used primarily in the 1960s and 1970s. It is defined by the recurrence:

In number theory, Dixon's factorization method is a general-purpose integer factorization algorithm; it is the prototypical factor base method. Unlike for other factor base methods, its run-time bound comes with a rigorous proof that does not rely on conjectures about the smoothness properties of the values taken by a polynomial.

Inversive congruential generators are a type of nonlinear congruential pseudorandom number generator, which use the modular multiplicative inverse to generate the next number in a sequence. The standard formula for an inversive congruential generator, modulo some prime q is:

Pollard's rho algorithm for logarithms is an algorithm introduced by John Pollard in 1978 to solve the discrete logarithm problem, analogous to Pollard's rho algorithm to solve the integer factorization problem.

The ElGamal signature scheme is a digital signature scheme which is based on the difficulty of computing discrete logarithms. It was described by Taher Elgamal in 1985.

In mathematics, a covering system is a collection

In modular arithmetic, Thue's lemma roughly states that every modular integer may be represented by a "modular fraction" such that the numerator and the denominator have absolute values not greater than the square root of the modulus.

In mathematics, particularly in the area of arithmetic, a modular multiplicative inverse of an integer a is an integer x such that the product ax is congruent to 1 with respect to the modulus m. In the standard notation of modular arithmetic this congruence is written as

In computer science, multiply-with-carry (MWC) is a method invented by George Marsaglia for generating sequences of random integers based on an initial set from two to many thousands of randomly chosen seed values. The main advantages of the MWC method are that it invokes simple computer integer arithmetic and leads to very fast generation of sequences of random numbers with immense periods, ranging from around to .

The Lehmer random number generator, sometimes also referred to as the Park–Miller random number generator, is a type of linear congruential generator (LCG) that operates in multiplicative group of integers modulo n. The general formula is

In sequence design, a Feedback with Carry Shift Register is the arithmetic or with carry analog of a linear-feedback shift register (LFSR). If is an integer, then an N-ary FCSR of length is a finite state device with a state consisting of a vector of elements in and an integer . The state change operation is determined by a set of coefficients and is defined as follows: compute . Express s as with in . Then the new state is . By iterating the state change an FCSR generates an infinite, eventually periodic sequence of numbers in .

An approach to nonlinear congruential methods of generating uniform pseudorandom numbers in the interval [0,1) is the Inversive congruential generator with prime modulus. A generalization for arbitrary composite moduli with arbitrary distinct primes will be present here.

<span class="mw-page-title-main">Spectral test</span>

The spectral test is a statistical test for the quality of a class of pseudorandom number generators (PRNGs), the linear congruential generators (LCGs). LCGs have a property that when plotted in 2 or more dimensions, lines or hyperplanes will form, on which all possible outputs can be found. The spectral test compares the distance between these planes; the further apart they are, the worse the generator is. As this test is devised to study the lattice structures of LCGs, it can not be applied to other families of PRNGs.

Wichmann–Hill is a pseudorandom number generator proposed in 1982 by Brian Wichmann and David Hill. It consists of three linear congruential generators with different prime moduli, each of which is used to produce a uniformly distributed number between 0 and 1. These are summed, modulo 1, to produce the result.

The ACORN or ″Additive Congruential Random Number″ generators are a robust family of pseudorandom number generators (PRNGs) for sequences of uniformly distributed pseudo-random numbers, introduced in 1989 and still valid in 2019, thirty years later.

References

  1. 1 2 3 4 5 6 Banks, Jerry; Carson, John S.; Nelson, Barry L.; Nicol, David M. (2010). Discrete-Event System Simulation (5th ed.). Prentice Hall. § 7.3.2. ISBN   978-0-13-606212-7.
  2. 1 2 3 4 L'Ecuyer, Pierre (1988). "Efficient and Portable Combined Random Number Generators" (PDF). Communications of the ACM . 31 (6): 742–749, 774. CiteSeerX   10.1.1.72.88 . doi:10.1145/62959.62969. S2CID   9593394.
  3. 1 2 Pandey, Niraj (6 August 2008). Implementation of Leap Ahead Function for Linear Congruental and Lagged Fibonacci Generators (PDF) (MSc. thesis). Florida State University. § 2.2. Archived from the original (PDF) on 12 July 2011. Retrieved 13 April 2012.
  4. L'Ecuyer, Pierre (September–October 1996). "Combined Multiple Recursive Number Generators". Operations Research . 44 (5): 816–822. doi:10.1287/opre.44.5.816.
  5. L'Ecuyer, Pierre (January–February 1999). "Good Parameters and Implementations for Combined Multiple Recursive Random Number Generators". Operations Research . 47 (1): 159–164. CiteSeerX   10.1.1.48.1341 . doi:10.1287/opre.47.1.159.
  6. L'Ecuyer, Pierre; R. Simard; E.J. Chen; W.D. Kelton (November–December 2002). "An Object-Oriented Randon-Number Package with Many Long Streams and Substreams" (PDF). Operations Research . 50 (6): 1073–1075. CiteSeerX   10.1.1.25.22 . doi:10.1287/opre.50.6.1073.358.