HOME

TheInfoList



OR:

RANDUCompaq Fortran Language Reference Manual (Order Number: AA-Q66SD-TK) September 1999 (formerly DIGITAL Fortran and DEC Fortran 90) is a linear congruential
pseudorandom number generator 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-generate ...
(LCG) of the Park–Miller type, which was used primarily in the 1960s and 1970s. It is defined by the
recurrence Recurrence and recurrent may refer to: *''Disease recurrence'', also called relapse *''Eternal recurrence'', or eternal return, the concept that the universe has been recurring, and will continue to recur, in a self-similar form an infinite number ...
: :V_ = 65539\cdot V_j\, \bmod\, 2^\, with the initial seed number, V_0 as an
odd number In mathematics, parity is the property of an integer of whether it is even or odd. An integer is even if it is a multiple of two, and odd if it is not.. For example, −4, 0, 82 are even because \begin -2 \cdot 2 &= -4 \\ 0 \cdot 2 &= 0 \\ 41 ...
. It generates pseudorandom
integers An integer is the number zero (), a positive natural number (, , , etc.) or a negative integer with a minus sign (−1, −2, −3, etc.). The negative numbers are the additive inverses of the corresponding positive numbers. In the language o ...
V_j which are uniformly distributed in the interval , but in practical applications are often mapped into pseudorandom
rationals In mathematics, a rational number is a number that can be expressed as the quotient or fraction of two integers, a numerator and a non-zero denominator . For example, is a rational number, as is every integer (e.g. ). The set of all rationa ...
X_j in the interval , by the formula: :X_j = \frac. IBM's RANDU is widely considered to be one of the most ill-conceived random number generators ever designed, and was described as "truly horrible" by
Donald Knuth Donald Ervin Knuth ( ; born January 10, 1938) is an American computer scientist, mathematician, and professor emeritus at Stanford University. He is the 1974 recipient of the ACM Turing Award, informally considered the Nobel Prize of computer sc ...
. It fails the
spectral test 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, ...
badly for dimensions greater than 2 as will be seen below. The reason for choosing these particular values for the multiplier and modulus had been that with a 32-bit-integer word size, the arithmetic of mod 231 and 65539 (\text2^ + 3) calculations could be done quickly, using bitwise operators in hardware, but the values were chosen for computational convenience, not statistical quality.


Problems with multiplier and modulus

For any
linear congruential generator 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 generat ...
with modulus ''m'' used to generate points in ''n''- dimensional space, the points fall in no more than (n!\times m)^ parallel hyperplanes. This indicates that low-modulus LCGs are unsuited to high-dimensional
Monte Carlo simulation Monte Carlo methods, or Monte Carlo experiments, are a broad class of computational algorithms that rely on repeated random sampling to obtain numerical results. The underlying concept is to use randomness to solve problems that might be determini ...
. For ''m'' = 2^31 and ''n'' = 3, an LCG could have up to 2344 planes, theoretical maximum. A much tighter upper bound is proved in the same Marsaglia paper to be the sum of the absolute values of all the coefficients of the hyperplanes in standard form. That is, if the hyperplanes are of the form Ax1 + Bx2 + Cx3 = some integer such as 0, 1, 2 etc, then the maximum number of planes is , A, +, B, +, C, . Now we examine the values of multiplier 65539 and modulus 231 chosen for RANDU. Consider the following calculation where every term should be taken mod 231. Start by writing the recursive relation as: :x_=(2^+3) x_=(2^+3 )^2 x_\, which becomes, after expanding the quadratic factor: :x_=(2^+6 \cdot2^ +9 )x_= \cdot (2^+3)-9_\, :because and allows us to show the correlation between three points as: :x_=6x_-9x_\, Summing the absolute values of the coefficients, we get no more than 16 planes in 3D, becoming only 15 planes on closer examination as shown in the diagram above. Even by the standards of LCGs, this shows that RANDU is terrible: using RANDU for sampling a
unit cube A unit cube, more formally a cube of side 1, is a cube whose sides are 1 unit long.. See in particulap. 671. The volume of a 3-dimensional unit cube is 1 cubic unit, and its total surface area is 6 square units.. Unit hypercube The term '' ...
will only sample 15 parallel planes, not even close to the upper limit of 2344 planes. As a result of the wide use of RANDU in the early 1970s, many results from that time are seen as suspicious. This misbehavior was already detected in 1963 on a 36-bit computer, and carefully reimplemented on the 32-bit
IBM System/360 The IBM System/360 (S/360) is a family of mainframe computer systems that was announced by IBM on April 7, 1964, and delivered between 1965 and 1978. It was the first family of computers designed to cover both commercial and scientific applica ...
. It was believed to have been widely purged by the early 1990sInterview with Donald Knuth
!-- DEAD LINK. use https://web.archive.org/web/20220328201420/http://tex.loria.fr/litte/knuth-interview -->
but there were still FORTRAN compilers using it as late as 1999.


Sample output

The start of the RANDU's output period for the initial seed V_0 = 1 is: : 1, 65539, 393225, 1769499, 7077969, 26542323, …


References


External links

{{Wikiquote Pseudorandom number generators