Sunteți pe pagina 1din 4

This chapter gives an overview o f the main techniques and algorithms fo r gener

ating
uniform random numbers, including those based on linear recurrences, modulo 2
arithmetic, and combinations o f these. A range o f theoretical and empirical te
sts
is provided to assess the quality o f a uniform random number generator. We refe
r
t o Chapter 3 for a discussion on methods for random variable generation from " 43
arbitrary distributions
such methods are invariably based on uniform random
number generators.
1.1 RANDOM NUMBERS
At the heart o f any Monte Carlo method is a random number generator: a
procedure tha t produces an infinite stream
/ 1 ,[/ 2 ,[/ 3 ,...~Dis t
o f random variables tha t are independent and identically distributed (iid) acc
ording
to some probability distribution Dist. When this distribution is the uniform dis
tribution on the interval (0,1) (that is, Dist = U(0,1)), the generator is said
to be
a uniform random number generator. Most computer languages already contain a bui
lt-in uniform random number generator. The user is typically requested
only to input an initial number, called the seed , and upon invocation the rando
m
Handbook of Monte Carlo Methods. By D. P. Kroese, T. Taimre, Z. I. Botev 1 Copy
right 2011 John Wiley & Sons, Inc. 2 UNIFORM RANDOM NUMBER GENERATION
number generato r produce s a sequenc e of independen t uniform rando m variable
s on
th e interval (0,1) . In MATLAB , for example, thi s is provide d by th e ran d
function.
The concept of a n infinite iid sequence of rando m variables is a mathematical
abstractio n tha t may b e impossible t o implemen t on a computer . Th e bes t
one can
hope to achieve in practice is t o produce a sequence of "random" numbers with
statistica l properties tha t are indistinguishable from those of a tru e sequen
ce of
iid rando m variables. Although physical generation method s based on universal
background radiatio n or quantu m mechanics seem t o offer a stabl e source of s
uch
tru e randomness , th e vas t majorit y of curren t rando m numbe r generator s
ar e base d
on simple algorithms tha t can be easily implemented on a computer. Following
L'Ecuyer [10], such algorithm s can b e represente d as a tupl e (S,f^,U,g), whe
re
iS is a finite set of states ,
/ is a function from S t o <S ,
is a probabilit y distributio n on S,
U is th e outpu t space; for a uniform random number generator U is th e
interva l (0,1) , and we will assume so from now on, unless otherwise specified,
g is a function from S t o U.
A rando m numbe r generator the n ha s th e following structure :
Algorith m 1.1 (Generi c Rando m Numbe r Generator )
1. Initialize : Draw the seed SQ from the distribution on S. Set t = 1.
2. Transition : Set St
= f{St
-i).
3. Output : SetUt = g(St
).
4- Repeat : Set t = t + 1 and return to Step 2.

The algorith m produce s a sequence U\, U2, U3,... of pseudorando m number s


we will refer t o the m simply as rando m numbers . Starting from a certain
seed, th e sequence of state s (and hence of rando m numbers) must repeat itself
,
because th e stat e space is finite. Th e smallest numbe r of step s take n befo
re entering a previously visited stat e is called th e perio d lengt h of th e r
ando m number
generator.
1.1.1 Properties of a Good Random Number Generator
What constitutes a good rando m number generator depends on man y factors. It
is always advisable t o have a variety of rando m number generators available, a
s
different applications may require different properties of th e random generator
.
Below are some desirable, or indeed essential, propertie s of a goo d uniform ra
ndom
number generator; see also [39].
1. Pass statistical tests: Th e ultimat e goal is tha t th e generato r should p
roduce
a strea m of uniform rando m number s tha t is indistinguishabl e from a genuine
uniform iid sequence . Although from a theoretica l poin t of view thi s criteri
on
is to o imprecise an d even infeasible (see Remar k 1.1.1), from a practica l po
in t RANDOM NUMBERS 3
of view thi s mean s tha t th e generato r should pass a batter y of simple stat
is tica l test s designed t o detec t deviations from uniformity and independenc
e.
We discuss such test s in Section 1.5.2.
2. Theoretical support: A good generator should b e based on sound mathemat ical
principles, allowing for a rigorous analysis of essential properties of th e
generator. Examples ar e linear congruentia l generator s an d multiple-recursiv
e
generators discussed in Sections 1.2.1 an d 1.2.2.
3. Reproducible: An importan t propert y is tha t th e strea m of rando m number
s
is reproducibl e withou t having t o stor e th e complet e strea m in memory . T
his
is essentia l for testin g an d varianc e reductio n techniques. Physical genera
tion
methods canno t be repeate d unless th e entire strea m is recorded.
4. Fast and efficient: The generator should produc e rando m number s in a fast
an d efficient manner, and require little storage in compute r memory. Many
Monte Carlo techniques for optimization and estimation require billions or
more rando m numbers. Current physical generation method s are no matc h
for simple algorithmic generator s in term s of speed.
5. Large period: Th e perio d of a rando m numbe r generato r should b e extreme
ly
on th e order of 10
larg e
50
in order t o avoid problem s wit h duplication
an d dependence. Evidence exists [36] tha t in order t o produce N random
numbers, th e perio d lengt h need s t o b e a t least lOiV
2
. Most early algorithmic
rando m number generators were fundamentall y inadequate in thi s respect.
6. Multiple streams: In man y applications it is necessary t o run multiple inde
pendent random streams in parallel. A good rando m number generator
should have easy provisions for multiple independen t streams.
7. Cheap and easy: A good rando m numbe r generator should b e chea p an d not

requir e expensiv e externa l equipment . In addition , it shoul d b e easy t o


install ,
implement , an d run . In general such a rando m numbe r generato r is also mor
e
easily portabl e over different computer platforms an d architectures.
8. Not produce 0 or 1: A desirable propert y of a rando m numbe r generator is
tha t bot h 0 an d 1 ar e excluded from th e sequence of rando m numbers . This
is t o avoid division by 0 or othe r numerical complications.
Remar k 1.1.1 (Computationa l Complexity ) From a theoretical point of
view, a finite-state random number generator can always be distinguished from
a tru e iid sequence, after observing th e sequence longer tha n its period. How
ever, from a practica l point of view thi s ma y not be feasible withi n a "reas
onable"
amoun t of time . This idea ca n b e formalized throug h th e notio n of computa
tional
complexity; see, for example , [33].
1.1.2 Choosing a Good Random Number Generator
As Pierr e L'Ecuye r put s it [12], choosing a goo d rando m generato r is like
choosing
a new car: for some people or applications speed is preferred, while for others
robustnes s and reliability are more important . For Monte Carlo simulation the
distributional properties of rando m generators are paramount , whereas in codin
g
an d cryptograph y unpredictabilit y is crucial. 4 UNIFORM RANDOM NUMBER GENERAT
ION
Nevertheless, as wit h cars, ther e are man y poorly designed an d outdate d mod
els available tha t should be avoided. Indeed several of th e standar d generato
rs
tha t come wit h popular programming languages an d computing packages can be
appallingly poor [13].
Two classes of generator s tha t have overall good performance are:
1. Combined multiple recursive generators, some of which have excellent statisti
ca l properties , are simple, have large period , suppor t multiple streams , an
d
are relatively fast. A popula r choice is L'Ecuyer' s MRG32k3a (see Section 1.3)
,
which ha s been implemente d as on e of th e core generator s in MATLA B (from
version 7), VSL , SAS , an d th e simulatio n packages SSJ , Arena , an d Automo
d .
2. Twisted general feedback shift register generators, some of which have very
good equidistributiona l properties , ar e amon g th e fastest generators availa
ble
(du e t o thei r essentially binar y implementation) , an d ca n hav e extremel
y long
periods. A popula r choice is Matsumot o and Nishimura's Mersenne twister
MT19937ar (see Section 1.2.4), which is currently th e default generator in
MATLAB.
I n general, a good uniform number generator has overall good performance, in
term s of th e criteria mentioned above, bu t is not usually th e to p performer
over
all these criteria. In choosing an appropriat e generator it pays t o remember t
he
following.
Faster generators are not necessarily better (indeed, often th e contrary is
true) .
A small perio d is in general bad , bu t a larger perio d is no t necessarily be
tter .
Good equidistribution is a necessary requirement for a good generator but
not a sufficient requirement.
1.2 GENERATORS BASED ON LINEAR RECURRENCES

Th e most common methods for generating pseudorandom sequences use simple


linea r recurrence relations.
1.2.1 Linear Congruential Generators
A linea r congruentia l generato r (LCG) is a rando m number generator of th e
form of Algorith m 1.1, wit h stat e St = Xt G {0,... , m
1} for some strictl y
positive
intege r m called th e modulus , an d stat e transition

S-ar putea să vă placă și