Inverse transform sampling


Inverse transform sampling is a basic method for pseudo-random number sampling, i.e., for generating sample numbers at random from any probability distribution given its cumulative distribution function.
Inverse transformation sampling takes uniform samples of a number between 0 and 1, interpreted as a probability, and then returns the largest number from the domain of the distribution such that. For example, imagine that is the standard normal distribution with mean zero and standard deviation one. The table below shows samples taken from the uniform distribution and their representation on the standard normal distribution.
.50
.9751.95996
.9952.5758
.9999994.75342
1-2^8.12589

We are randomly choosing a proportion of the area under the curve and returning the number in the domain such that exactly this proportion of the area occurs to the left of that number. Intuitively, we are unlikely to choose a number in the far end of tails because there is very little area in them which would require choosing a number very close to zero or one.
Computationally, this method involves computing the quantile function of the distribution — in other words, computing the cumulative distribution function of the distribution and then inverting that function. This is the source of the term "inverse" or "inversion" in most of the names for this method. Note that for a discrete distribution, computing the CDF is not in general too difficult: we simply add up the individual probabilities for the various points of the distribution. For a continuous distribution, however, we need to integrate the probability density function of the distribution, which is impossible to do analytically for most distributions. As a result, this method may be computationally inefficient for many distributions and other methods are preferred; however, it is a useful method for building more generally applicable samplers such as those based on rejection sampling.
For the normal distribution, the lack of an analytical expression for the corresponding quantile function means that other methods may be preferred computationally. It is often the case that, even for simple distributions, the inverse transform sampling method can be improved on: see, for example, the ziggurat algorithm and rejection sampling. On the other hand, it is possible to approximate the quantile function of the normal distribution extremely accurately using moderate-degree polynomials, and in fact the method of doing this is fast enough that inversion sampling is now the default method for sampling from a normal distribution in the statistical package R.

Definition

The probability integral transform states that if is a continuous random variable with cumulative distribution function, then the random variable has a uniform distribution on . The inverse probability integral transform is just the inverse of this: specifically, if has a uniform distribution on and if has a cumulative distribution , then the random variable has the same distribution as .

Intuitions

From, we want to generate with CDF We assume to be a strictly increasing function, which provides good intuition.
We want to see if we can find some strictly monotone transformation, such that. We will have
where the last step used that when is uniform on.
So we got to be the inverse function of, or, equivalently
Therefore, we can generate from

The method

The problem that the inverse transform sampling method solves is as follows:
The inverse transform sampling method works as follows:
  1. Generate a random number from the standard uniform distribution in the interval, e.g. from
  2. Find the inverse of the desired CDF, e.g..
  3. Compute. The computed random variable has distribution.
Expressed differently, given a continuous uniform variable in and an invertible cumulative distribution function, the random variable has distribution .
A treatment of such inverse functions as objects satisfying differential equations can be given. Some such differential equations admit explicit power series solutions, despite their non-linearity.

Examples

Let F be a continuous cumulative distribution function, and let F−1 be its inverse function :
Claim: If U is a uniform random variable on then has F as its CDF.
Proof:

Truncated distribution

Inverse transform sampling can be simply extended to cases of truncated distributions on the interval without the cost of rejection sampling: the same algorithm can be followed, but instead of generating a random number uniformly distributed between 0 and 1, generate uniformly distributed between and, and then again take.

Reduction of the number of inversions

In order to obtain a large number of samples, one needs to perform the same number of inversions of the distribution.
One possible way to reduce the number of inversions while obtaining a large number of samples is the application of the so-called Stochastic Collocation Monte Carlo sampler within a polynomial chaos expansion framework. This allows us to generate any number of Monte Carlo samples with only a few inversions of the original distribution with independent samples of a variable for which the inversions are analytically available, for example the standard normal variable.