286 Monte Carlo
exists a variable transformationr=g(x) whereg(x) is a nondecreasing function of
x. This function maps the intervalx∈[a,b] onto the intervalr∈[0,1]. In this case,
by eqn. (7.3.3), the cumulative probabilities can be equated in the intervalξ∈[0,1],
yielding the relation
P(X) =ξ. (7.3.6)
Thus, a sampling of the distribution functionf(x) can be achieved by randomly choos-
ing a probability between 0 and 1 and then solving eqn. (7.3.6) for the corresponding
probability thatxchosen fromf(x) lies in the intervalx∈[a,X]. The invertibility of
eqn. (7.3.6) to yieldXas a function ofξguarantees the existence of the transformation
r=g(x). Therefore, for a set ofMrandom numbersξ 1 ,...,ξM, eqn. (7.3.6) yieldsM
valuesX 1 ,...,XM. We simply setxi=Xi, and we have a sampling ofMvalues from
the distributionf(x).
As an example, consider the distribution functionf(x) =ce−cxon the interval
x∈[0,∞). Clearly,f(x) satisfies the conditions of a properly normalized probability
distribution function. In order to samplef(x), we first needP(X):
P(X) =
∫X
0
ce−cxdx= 1−e−cX. (7.3.7)
Next, we equate 1−exp(−cX) to the random numberξ, i.e.,
1 −e−cX=ξ, (7.3.8)
and solve forX, which can be done straightforwardly to yield
X=−
1
c
ln(1−ξ). (7.3.9)
The example from Section 3.8.3 using the Box–Muller method to sample the Gaus-
sian distribution illustrates that a single-variable distribution can be sampled by turn-
ing it into a two-variable distributionF(x,y) that could be factorized into a product
of two identical single-variable distributionsf(x)f(y). A simple change of variables
to polar coordinates yielded another separable distributiong(r)h(θ), each factor of
which could be sampled straightforwardly using eqn. (7.3.6) (see eqns. (3.8.14) to
(3.8.20)). In general, the problem of sampling a multi-variable distributionf(x), where
x = (x 1 ,...,xn) is ann-dimensional vector, is nontrivial and will be discussed below.
However, let us consider the special case thatf(x) is separable into a product ofn
single-variable distributions,
f(x) =
∏n
α=1
fα(xα). (7.3.10)
If there exists a general transformationyα=gα(x) such that the new distribution
f ̃(y), y = (y 1 ,...,yn), is separable in the transformed variables
f ̃(y) =
∏n
α=1
f ̃α(yα), (7.3.11)
then eqn. (7.3.6) can be applied to each individual distributionfα(xα) orf ̃α(yα) to
yield variablesX 1 ,...,XnorY 1 ,...,Ynand hence a complete sampling of the multi-
variable distribution.