This section describes how the computer uses a random number generator to sample in an unbiased fashion values of a parameter x from a particular probability density function, p(x). In other words, if a large number of rnd values were used to choose a large number of x values and these choices of x were plotted as a histogram, the shape of the original p(x) would be reconstructed.
The computer has a random number generator which can yield a random number, rnd, between 0 and 1 each time the computer calls that subroutine. This rnd is the computer's dice. The probability density function, p(rnd), is uniformly distributed between 0 and 1 with an assigned value of 1. The probability distribution function, F(rnd_{1}), is defined as the integral of p(rnd) over the range of 0 <= rnd <= rnd_{1}, and linearly increases from 0 to 1 as rnd_{1} increases from 0 to 1.
Suppose that we are interested in a probability density function, p(x), that describes the likelihood of the parameter x taking on a specific value, perhaps the specific value x_{1}, between the limits a and b: a <= x <= b. The probability distribution function, F(x_{1}), is defined as the integral of p(x) over the range of a <= x <= x_{1}, and increases from 0 to 1 as x_{1} increases from a to b.
The key to the Monte Carlo technique is to recognize that if one lets F(rnd_{1}) equal F(x_{1}), then a point of connection is made between p(rnd_{1}) and p(x_{1}). Random selection of rnd maps into a distributed selection of x that mimics the original p(x).
The following figure illustrates the connection between p(rnd_{1}) and p(x_{1}) via the equation of F(rnd_{1}) equal F(x_{1}):
Mathematically, the equivalence of F(rnd_{1}) equal F(x_{1}) can be stated as:
or more simply:
After evaluation of the integral above, the expression can be rearranged to solve for x_{1} in terms of rnd:
This expression function(rnd) can then be used to specify a choice of x for each random number, rnd, generated by the computer's random number generator. That's it!