Since the r.v. **x** and the cdf are 1-to-1, one can sample **x** by first
sampling and then solving for **x** by inverting , or
.
But Eq. (83) tells us that the cdf is uniformly distributed on
[0,1], which is
denoted .
Therefore, we simply use a random number generator (RNG) that generates
numbers, to generate a sample from the cdf .
Then the value of **x** is determined by inversion, .
This is depicted graphically in
Figure 12.
The inversion is not always possible, but in many important cases
the inverse is readily obtained.

Figure 12: Sampling Using the Inverse of the cdf.

This simple yet elegant sampling rule was first suggested by von Neumann in a letter to Ulam in 1947 [Los Alamos Science, p. 135, June 1987]. It is sometimes called the ``Golden Rule for Sampling''. Since so much use will be made of this result throughout this chapter, we summarize below the steps for sampling by inversion of the cdf:

- Step 1.
- Sample a random number from
- Step 2.
- Equate with the cdf:
- Step 3.
- Invert the cdf and solve for
**x**: