29
Generating Random Numbers
29.1 Overview
In several of the option chapters of this book we have used randomly
generated stock prices to simulate and price options (see in particular
Chapter 18 on the lognormal distribution, Chapter 20 on option Greeks,
Chapter 21 on portfolio insurance, and Chapters 22–23 on Monte Carlo
methods). In all these chapters, the stock price simulations are based on
the generation of random numbers. In this chapter we discuss techniques
for computing these numbers.
A random-number generator on a computer is a function that
produces a seemingly unrelated set of numbers. The question of what
is a random number is a philosophical one.
1
In this chapter we will
ignore philosophy and concentrate on some simple random-number
generators—primarily the Excel random-number generator Rand( ) and
the VBA random-number generator Rnd.
2
To imagine a set of uniformly distributed random numbers, think of
an urn fi lled with 1,000 little balls, numbered 000, 001, 002, . . . , 999.
Suppose we perform the following experiment: Having shaken the urn
to mix up the balls, we draw one ball out of the urn and record the ball’s
number. Next we put the ball back into the urn, shake the urn thoroughly
so that the balls are mixed up again, and then draw out a new ball. The
series of numbers produced by repeating this procedure many times
should be uniformly distributed between 000 and 999.
A random number generator on a computer is a function that imitates
this procedure. The random-number generators considered in this chapter
are sometimes termed pseudo-random-number generators, since they are
actually deterministic functions whose values are indistinguishable from
random numbers. All pseudo-random-number generators have cycles
(that is, they eventually start to repeat themselves). The trick is to fi nd a
random-number generator with a long cycle. The Excel Rand( ) function
has very long cycles and is a respectable random-number generator.
1. Knuth (1981, p. 142) gives the following quote: “A random sequence is a vague notion
embodying the idea of a sequence in which each term is unpredictable to the uniniti-
ated and whose digits pass a certain number of tests, traditional with statisticians and
depending somewhat on the uses to which the sequence is to be put” (attributed to
D. H. Lehmer, 1951).
2. In this book we usually write Excel functions in boldface without the parentheses. In
this chapter we generally write Rand( ) with the parentheses to emphasize (a) that the
parentheses are necessary and (b) that they are empty.