Inverse transform sampling can be used to transform samples from the uniform distribution to another by inverting the target distribution’s CDF (a.k.a. computing the quantile function). It is one of the most important techniques to generate samples from a distribution.

The Algorithm

  1. Compute the CDF1 .
  2. Compute the inverse .
  3. Obtain a uniformly distributed random number
  4. Compute .

Derivation

For a distribution , we want to find a transformation of the canonical uniform distribution such that . Let the CDF of be . By the definition of CDF,

Substitute in:

For the canonical uniform distribution, , so we have

Intuition

Footnotes

  1. Assuming the PDF is zero for . Otherwise we need to integrate from