MS&E 223
Lecture Notes #6
Simulation
Uniform Variate Generation
Peter J. Haas
Spring Quarter 2009-10
Uniform Variate Generation
Refs
: Law Ch. 7;
Simulation
(Ed. Henderson et al.) Ch
.
3.; Knuth,
The Art of Computer
Programming
, Vol. 2, Ch. 3.
We now discuss the question of how to generate i.i.d. uniform random variables on a computer.
As we
have seen, uniform randomness is the basis of all the randomness that one simulates on a computer.
1.
Pseudo-Random Numbers
Perhaps surprisingly, the basis of most RNG algorithms is a deterministic recurrence relation: the
sequence starts with an initial “seed”, and then each “random number” in the sequence is a deterministic
function of the previous random number. Although these numbers form a deterministic dependent
sequence, if the generation algorithm is well designed the numbers will
appear
to be random and
independently distributed. For this reason such numbers are called
pseudo-random
numbers.
An important property of pseudo-random numbers is that a given sequence can be repeated again at a
later time. This repeatability property is useful because
•
it
facilitates debugging of simulation programs
•
it permits an efficiency improvement technique called “common random numbers” (to be
discussed later)
2.
Linear Congruential Generators
The most commonly used generators, in practice, are linear congruential generators (LCG’s).
A sequence
of integers is generated via the recursion
01
x,x,
…
n1
n
x
(ax
c)
mod
m
+
=+
where a, c, and m are integers also known, respectively, as the multiplier, increment and modulus.
Remark
:
k mod m is the integer obtained by dividing k by m and computing the remainder (e.g., 14 mod
5 = 4, 26 mod 21 = 5).
It follows that the
are integers in the set {0, 1, .
.., m
−1
}.
To obtain the
pseudo-random uniform sequence
, one sets
n
x'
s
U,U,
…
nn
Ux
/
m
=
.
Clearly, a LCG produces periodic output, with period
≤
m.
Full period is desirable because:
•
It increases the potential number of random variates one can reliably use in a simulation.
•
If the generator is not of full period, then there are gaps in the output sequence.
The nature of
such gaps for an LCG is not well understood, and may create distinctly non-random behavior
in the output.
Page 1 of 8