Inverse transform sampling

1

Inverse transform sampling (also known as inversion sampling, the inverse probability integral transform, the inverse transformation method, or the Smirnov transform) 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 u between 0 and 1, interpreted as a probability, and then returns the smallest number such that F(x)\ge u for the cumulative distribution function F of a random variable. For example, imagine that F 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. 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 (CDF) of the distribution (which maps a number in the domain to a probability between 0 and 1) 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 (PDF) of the distribution, which is impossible to do analytically for most distributions (including the normal distribution). 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 (e.g. the Box–Muller transform) 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.

Formal statement

For any random variable, the random variable F_X^{-1}(U) has the same distribution as X, where F_X^{-1} is the generalized inverse of the cumulative distribution function F_X of X and U is uniform on [0,1]. For continuous random variables, the inverse probability integral transform is indeed the inverse of the probability integral transform, which states that for a continuous random variable X with cumulative distribution function F_X, the random variable U=F_X(X) is uniform on [0,1].

Intuition

From, we want to generate X with CDF F_X(x). We assume F_X(x) to be a continuous, 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 U is uniform on [0,1]. So we got F_X to be the inverse function of T, or, equivalently Therefore, we can generate X from

The method

The problem that the inverse transform sampling method solves is as follows: The inverse transform sampling method works as follows: Expressed differently, given a cumulative distribution function F_X and a uniform variable U\in[0,1], the random variable has the distribution F_X. In the continuous case, 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

Proof of correctness

Let F be a cumulative distribution function, and let F^{-1} be its generalized inverse function (using the infimum because CDFs are weakly monotonic and right-continuous): Claim: If U is a uniform random variable on [0,1] then F^{-1}(U) has F as its CDF. Proof:

Truncated distribution

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

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 (SCMC 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.

Software implementations

There are software implementations available for applying the inverse sampling method by using numerical approximations of the inverse in the case that it is not available in closed form. For example, an approximation of the inverse can be computed if the user provides some information about the distributions such as the PDF or the CDF.

This article is derived from Wikipedia and licensed under CC BY-SA 4.0. View the original article.

Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc.
Bliptext is not affiliated with or endorsed by Wikipedia or the Wikimedia Foundation.

View original