NUMERICAL METHODS
on (0,1) and then take as the random numberythe value ofF−^1 (ξ). We now
illustrate this with a worked example.
Find an explicit formula that will generate a random numberydistributed on(−∞,∞)
according to the Cauchy distribution
f(y)dy=
(a
π
) dy
a^2 +y^2
,
given a random numberξuniformly distributed on(0,1).
The first task is to determine the indefinite integral:
F(y)=
∫y
−∞
(a
π
) dt
a^2 +t^2
=
1
π
tan−^1
y
a
+
1
2
.
Now, ifyis distributed as we wish thenF(y) is uniformly distributed on (0,1). This follows
from the fact that the derivative ofF(y)isf(y). We therefore setF(y)equaltoξand
obtain
ξ=
1
π
tan−^1
y
a
+
1
2
,
yielding
y=atan[π(ξ−^12 )].
This explicit formula shows how to change a random numberξdrawn from a population
uniformly distributed on (0,1) into a random numberydistributed according to the
Cauchy distribution.
Look-up tables operate as described below for cumulative distributionsF(y)
that are non-invertible, i.e.F−^1 (y) cannot be expressed in closed form. They
are especially useful if many random numbers are needed but great sampling
accuracy is not essential. The method for anN-entry table can be summarised as
follows. DefinewmbyF(wm)=m/Nform=1, 2 ,...,N, and store a table of
y(m)=^12 (wm+wm− 1 ).
As each random numberyis needed, calculatekas the integral part ofNξand
takeyas given byy(k).
Normally, such a look-up table would have to be used for generating random
numbers with a Gaussian distribution, as the cumulative integral of a Gaussian is
non-invertible. It would be, in essence, table 30.3, with the roles of argument and
value interchanged. In this particular case, an alternative, based on the central
limit theorem, can be considered.
Withξigenerated in the usual way, i.e. uniformly distributed on the interval
0 ≤ξ<1, the random variable
y=
∑n
i=1
ξi−^12 n (27.55)
is normally distributed with mean 0 and variancen/12 whennis large. This
approach does produce a continuous spectrum of possible values fory, but needs