Lagged Fibonacci generator: Difference between revisions
Line 1: | Line 1: | ||
'''Inverse transform sampling''' (also known as '''inversion sampling''', the '''inverse probability integral transform''', the '''inverse transformation method''', '''[[Nikolai Smirnov (mathematician)|Smirnov]] transform''', '''golden rule''',<ref name=aalto>Aalto University, N. Hyvönen, Computational methods in inverse problems. Twelfth lecture https://noppa.tkk.fi/noppa/kurssi/mat-1.3626/luennot/Mat-1_3626_lecture12.pdf</ref> etc.) 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]] (cdf). | |||
The basic idea is to uniformly sample a number <math>u</math> between 0 and 1, interpreted as a probability, and then return the largest number <math>x</math> from the domain of the distribution <math>p(X)</math> such that <math>p(-\infty < X < x) \le u</math>. For example, imagine that <math>p(X)</math> is the standard [[normal distribution]] (i.e. with [[mean]] 0, [[standard deviation]] 1). Then if we choose <math>u = 0.5</math>, we would return 0, because 50% of the probability of a normal distribution occurs in the region where <math>X \le 0</math>. Similarly, if we choose <math>u = 0.975</math>, we would return 1.95996...; if we choose <math>u = 0.995</math>, we would return 2.5758...; if we choose <math>u = 0.999999</math>, we would return 4.891638...; etc. Essentially, 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 tails because there is very little area in them: We'd have to pick a number very close to 0 or 1. | |||
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:<ref>{{cite book |author=Luc Devroye |url=http://www.eirene.de/Devroye.pdf |title=Non-Uniform Random Variate Generation |publisher=Springer-Verlag |place=New York |year=1986}}</ref> 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 (programming language)|R]]. | |||
==Definition== | |||
The [[probability integral transform]] states that if <math>X</math> is a [[continuous random variable]] with [[cumulative distribution function]] <math>F_X</math>, then the random variable <math>Y=F_X(X)</math> has a [[uniform distribution (continuous)|uniform distribution]] on [0, 1]. The inverse probability integral transform is just the inverse of this: specifically, if <math>Y</math> has a uniform distribution on [0, 1] and if <math>X</math> has a cumulative distribution <math>F_X</math>, then the cumulative distribution function of the random variable <math>F_X^{-1}(Y)</math> is <math>F_X</math> . | |||
==The method== | |||
The problem that the inverse transform sampling method solves is as follows: | |||
*Let ''X'' be a [[random variable]] whose distribution can be described by the [[cumulative distribution function]] ''F''. | |||
*We want to generate values of ''X'' which are distributed according to this distribution. | |||
The inverse transform sampling method works as follows: | |||
#[[pseudorandom number generator|Generate a random number]] ''u'' from the standard uniform distribution in the interval [0,1]. | |||
#Compute the value ''x'' such that ''F''(''x'') = ''u''. | |||
#Take ''x'' to be the random number drawn from the distribution described by ''F''. | |||
Expressed differently, given a continuous uniform variable ''U'' in [0, 1] and an [[Inverse function|invertible]] cumulative distribution function ''F'', the random variable ''X'' = ''F''<sup> −1</sup>(''U'') has distribution ''F'' (or, ''X'' is distributed ''F''). | |||
A treatment of such inverse functions as objects satisfying differential equations can be given.<ref>Steinbrecher, G., Shaw, W.T. (2008). Quantile mechanics. ''European Journal of Applied Mathematics'' 19 (2): 87–112.</ref> Some such differential equations admit explicit power series solutions, despite their non-linearity. | |||
==Proof of correctness== | |||
Let ''F'' be a continuous [[cumulative distribution function]], and let ''F''<sup>−1</sup> be its inverse function (using the [[infimum]] because CDFs are weakly monotonic and [[Càdlàg|right-continuous]]):<ref>{{cite book |author=Luc Devroye |title=Non-Uniform Random Variate Generation |publisher=Springer-Verlag |place=New York |year=1986 |chapter=Section 2.2. Inversion by numerical solution of ''F''(''X'') = ''U'' |url=http://luc.devroye.org/chapter_two.pdf}}</ref> | |||
:<math>F^{-1}(u) = \inf\;\{x \mid F(x)\geq u, 0<u<1\}.</math> | |||
''Claim:'' If ''U'' is a [[uniform distribution (continuous)|uniform]] random variable on (0, 1) then <math>F^{-1}(U)</math> follows the distribution ''F''. | |||
''Proof:'' | |||
:<math> | |||
\begin{align} | |||
& \Pr(F^{-1}(U) \leq x) \\ | |||
& {} = \Pr(U \leq F(x)) \quad &\text{(applying }F,\text{ which is monotonic, to both sides)} \\ | |||
& {} = F(x)\quad &\text{(because }\Pr(U \leq y) = y,\text{ since }U\text{ is uniform on the unit interval)}. | |||
\end{align} | |||
</math> | |||
== See also == | |||
* [[Probability integral transform]] | |||
* [[Copula (statistics)|Copula]], defined by means of probability integral transform. | |||
* [[Quantile function]], for the explicit construction of inverse CDFs. | |||
* [[Cumulative distribution function#Inverse|Inverse distribution function]] for a precise mathematical definition for distributions with discrete components. | |||
==References== | |||
<references/> | |||
== External links == | |||
{{DEFAULTSORT:Inverse Transform Sampling}} | |||
[[Category:Monte Carlo methods]] | |||
[[Category:Non-uniform random numbers]] |
Revision as of 22:28, 30 October 2013
Inverse transform sampling (also known as inversion sampling, the inverse probability integral transform, the inverse transformation method, Smirnov transform, golden rule,[1] etc.) 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 (cdf).
The basic idea is to uniformly sample a number between 0 and 1, interpreted as a probability, and then return the largest number from the domain of the distribution such that . For example, imagine that is the standard normal distribution (i.e. with mean 0, standard deviation 1). Then if we choose , we would return 0, because 50% of the probability of a normal distribution occurs in the region where . Similarly, if we choose , we would return 1.95996...; if we choose , we would return 2.5758...; if we choose , we would return 4.891638...; etc. Essentially, 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 tails because there is very little area in them: We'd have to pick a number very close to 0 or 1.
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:[2] 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 [0, 1]. The inverse probability integral transform is just the inverse of this: specifically, if has a uniform distribution on [0, 1] and if has a cumulative distribution , then the cumulative distribution function of the random variable is .
The method
The problem that the inverse transform sampling method solves is as follows:
- Let X be a random variable whose distribution can be described by the cumulative distribution function F.
- We want to generate values of X which are distributed according to this distribution.
The inverse transform sampling method works as follows:
- Generate a random number u from the standard uniform distribution in the interval [0,1].
- Compute the value x such that F(x) = u.
- Take x to be the random number drawn from the distribution described by F.
Expressed differently, given a continuous uniform variable U in [0, 1] and an invertible cumulative distribution function F, the random variable X = F −1(U) has distribution F (or, X is distributed F).
A treatment of such inverse functions as objects satisfying differential equations can be given.[3] Some such differential equations admit explicit power series solutions, despite their non-linearity.
Proof of correctness
Let F be a continuous cumulative distribution function, and let F−1 be its inverse function (using the infimum because CDFs are weakly monotonic and right-continuous):[4]
Claim: If U is a uniform random variable on (0, 1) then follows the distribution F.
Proof:
See also
- Probability integral transform
- Copula, defined by means of probability integral transform.
- Quantile function, for the explicit construction of inverse CDFs.
- Inverse distribution function for a precise mathematical definition for distributions with discrete components.
References
- ↑ Aalto University, N. Hyvönen, Computational methods in inverse problems. Twelfth lecture https://noppa.tkk.fi/noppa/kurssi/mat-1.3626/luennot/Mat-1_3626_lecture12.pdf
- ↑ 20 year-old Real Estate Agent Rusty from Saint-Paul, has hobbies and interests which includes monopoly, property developers in singapore and poker. Will soon undertake a contiki trip that may include going to the Lower Valley of the Omo.
My blog: http://www.primaboinca.com/view_profile.php?userid=5889534 - ↑ Steinbrecher, G., Shaw, W.T. (2008). Quantile mechanics. European Journal of Applied Mathematics 19 (2): 87–112.
- ↑ 20 year-old Real Estate Agent Rusty from Saint-Paul, has hobbies and interests which includes monopoly, property developers in singapore and poker. Will soon undertake a contiki trip that may include going to the Lower Valley of the Omo.
My blog: http://www.primaboinca.com/view_profile.php?userid=5889534