2.1 Random Number Generator

This section discusses how to random number generation is implemented within the JSL. The purpose is to present how these concepts can be put into practice.

The random number generator used within the JSL is described in L’Ecuyer, Simard, and Kelton (2002) and has excellent statistical properties. It is based on the combination of two multiple recursive generators resulting in a period of approximately \(3.1 \times 10^{57}\). This is the same generator that is now used in many commercial simulation packages. The generator used in the JSL is defined by the following equations.

\[ \begin{aligned} R_{1,i} & = (1,403,580 R_{1,i-2} - 810,728 R_{1,i-3})\bmod (2^{32}-209)\\ R_{2,i} & = (527,612R_{2,i-1} - 1,370,589 R_{2,i-3})\bmod (2^{32}-22,853)\\ Y_i & = (R_{1,i}-R_{2,i})\bmod(2^{32}-209)\\ U_i & = \frac{Y_i}{2^{32}-209} \end{aligned} \]

To illustrate how this generator works, consider generating an initial sequence of pseudo-random numbers from the generator. The generator takes as its initial seed a vector of six initial values \((R_{1,0}, R_{1,1}, R_{1,2}, R_{2,0}, R_{2,1}, R_{2,2})\). The first initially generated value, \(U_{i}\), will start at index \(3\). To produce five pseudo random numbers using this generator we need an initial seed vector, such as: \[\lbrace R_{1,0}, R_{1,1}, R_{1,2}, R_{2,0}, R_{2,1}, R_{2,2} \rbrace = \lbrace 12345, 12345, 12345, 12345, 12345, 12345\rbrace\]

Using the recursive equations, the resulting random numbers are as follows:

i=3 i=4 i=5 i=6 i=7
\(Z_{1,i-3}=\) 12345 12345 12345 3023790853 3023790853
\(Z_{1,i-2}=\) 12345 12345 3023790853 3023790853 3385359573
\(Z_{1,i-1}=\) 12345 3023790853 3023790853 3385359573 1322208174
\(Z_{2,i-3}=\) 12345 12345 12345 2478282264 1655725443
\(Z_{2,i-2}=\) 12345 12345 2478282264 1655725443 2057415812
\(Z_{2,i-1}=\) 12345 2478282264 1655725443 2057415812 2070190165
\(Z_{1,i}=\) 3023790853 3023790853 3385359573 1322208174 2930192941
\(Z_{2,i}=\) 2478282264 1655725443 2057415812 2070190165 1978299747
\(Y_i=\) 545508589 1368065410 1327943761 3546985096 951893194
\(U_i=\) 0.127011122076 0.318527565471 0.309186015655 0.82584686312 0.221629915834

While it is beyond the scope of this document to explore the theoretical underpinnings of this generator, it is important to note that the generator allows multiple independent streams to be defined along with sub-streams.

The fantastic thing about this generator is the sheer size of the period. Based on their analysis, L’Ecuyer, Simard, and Kelton (2002) state that it will be “approximately 219 years into the future before average desktop computers will have the capability to exhaust the cycle of the (generator) in a year of continuous computing.” In addition to the period length, the generator has an enormous number of streams, approximately \(1.8 \times 10^{19}\) with stream lengths of \(1.7 \times 10^{38}\) and sub-streams of length \(7.6 \times 10^{22}\) numbering at \(2.3 \times 10^{15}\) per stream. Clearly, with these properties, you do not have to worry about overlapping random numbers when performing simulation experiments. The generator was subjected to a rigorous battery of statistical tests and is known to have excellent statistical properties.

References

L’Ecuyer, P., R. Simard, and W. D. Kelton. 2002. “An Object-Oriented Random Number Package with Many Long Streams and Substreams.” Operations Research 50: 1073–75.