Ratio of uniforms

From testwiki
Revision as of 22:45, 26 November 2024 by imported>YukonJan (The exponential distribution: There was a small mistake in calculating the maxima of $g$, the maximum value was mistakenly put as the argument of $g$ instead of the result. This also affected the bounds on V)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

The ratio of uniforms is a method initially proposed by Kinderman and Monahan in 1977[1] for pseudo-random number sampling, that is, for drawing random samples from a statistical distribution. Like rejection sampling and inverse transform sampling, it is an exact simulation method. The basic idea of the method is to use a change of variables to create a bounded set, which can then be sampled uniformly to generate random variables following the original distribution. One feature of this method is that the distribution to sample is only required to be known up to an unknown multiplicative factor, a common situation in computational statistics and statistical physics.

Motivation

The pdf of a bimodal statistical distribution is plotted on a graph. The distribution is only defined between −1.5 and 1.5. A rectangular bounding box is drawn around the graph of the function between the abscisses −1.5 and 1.5, and the y coordinates 0 and the maximum of the function. The box is split into two zones by the curve: below the curve is the acceptance region, and above it is the rejection region.
Rejection sampling of a bounded statistical distribution with finite support.

A convenient technique to sample a statistical distribution is rejection sampling. When the probability density function of the distribution is bounded and has finite support, one can define a bounding box around it (a uniform proposal distribution), draw uniform samples in the box and return only the x coordinates of the points that fall below the function (see graph). As a direct consequence of the fundamental theorem of simulation,[2] the returned samples are distributed according to the original distribution.

When the support of the distribution is infinite, it is impossible to draw a rectangular bounding box containing the graph of the function. One can still use rejection sampling, but with a non-uniform proposal distribution. It can be delicate to choose an appropriate proposal distribution,[3] and one also has to know how to efficiently sample this proposal distribution.

The method of the ratio of uniforms offers a solution to this problem, by essentially using as proposal distribution the distribution created by the ratio of two uniform random variables.

Statement

The statement and the proof are adapted from the presentation by Gobet[4]

Template:Math theorem

Template:Math proof

Complements

Rejection sampling in Af,r

The above statement does not specify how one should perform the uniform sampling in Af,r. However, the interest of this method is that under mild conditions on f (namely that f(x1,x2,,xd)11+rd and xif(x1,x2,,xd)r1+rd for all i are bounded), Af,r is bounded. One can define the rectangular bounding box A~f,r such thatAf,rA~f,r=[0,supx1,,xdf(x1,,xd)11+rd]×i[infx1,,xdxif(x1,,xd)r1+rd,supx1,,xdxif(x1,,xd)r1+rd]This allows to sample uniformly the set Af,r by rejection sampling inside A~f,r. The parameter r can be adjusted to change the shape of Af,r and maximize the acceptance ratio of this sampling.

Parametric description of the boundary of Af,r

The definition of Af,r is already convenient for the rejection sampling step. For illustration purposes, it can be interesting to draw the set, in which case it can be useful to know the parametric description of its boundary:u=f(x1,x2,,xd)11+rdandi[|1,n|],vi=xiuror for the common case where X is a 1-dimensional variable, (u,v)=(f(x)11+r,xf(x)r1+r).

Generalized ratio of uniforms

Above parameterized only with r, the ratio of uniforms can be described with a more general class of transformations in terms of a transformation g.[5] In the 1-dimensional case, if g:++ is a strictly increasing and differentiable function such that g(0)=0, then we can define Af,g such that

Af,g={(u,v)2:0ug1[f(vg(u))]}

If (U,V) is a random variable uniformly distributed in Af,g, then Vg(U) is distributed with the density p.

Examples

Exponential distribution before and after change of variables by the ratio of uniforms method. Top: graph of the exponential distribution on +. Bottom: the set Af,1 is represented in the space (u,v), inscribed in the bounding box A~f,1. The colored domains, of equal probability, were added to help the visual association of the corresponding domains of the transformed sets.

The exponential distribution

Assume that we want to sample the exponential distribution, p(x)=λeλx with the ratio of uniforms method. We will take here r=1.

We can start constructing the set Af,1:

Af,1={(u,v)2:0up(vu)}

The condition 0up(vu) is equivalent, after computation, to 0vuλlnu2λ, which allows us to plot the shape of the set (see graph).

This inequality also allows us to determine the rectangular bounding box A~f,1 where Af,1 is included. Indeed, with g(u)=uλlnu2λ, we have g(λ)=0 and g(λe)=0, from where A~f,1=[0,λ]×[0,2eλ].

From here, we can draw pairs of uniform random variables UUnif(0,λ) and VUnif(0,2eλ) until uλeλvu, and when that happens, we return vu, which is exponentially distributed.

Normal mixture distribution before and after change of variables by the ratio of uniforms method. Top: graph of the mixture distribution on . Bottom: the set Af,r is represented for two different values of r. The solid lines on the top represent the de-transformation of the bounding boxes on the bottom. The solid lines on the bottom represent the locations of different values of x in the set.

A mixture of normal distributions

Consider the mixture of two normal distributions 𝒟=0.6N(μ=1,σ=2)+0.4N(μ=3,σ=1). To apply the method of the ratio of uniforms, with a given r, one should first determine the boundaries of the rectangular bounding box A~f,r enclosing the set Af,r. This can be done numerically, by computing the minimum and maximum of u(x)=f(x)11+r and v(x)=xf(x)r1+r on a grid of values of x. Then, one can draw uniform samples (u,v)A~f,r, only keep those that fall inside the set Af,r and return them as vur.

It is possible to optimize the acceptance ratio by adjusting the value of r, as seen on the graphs.

Software

  • The rust[6] and Runuran[7] contributed packages in R.

See also

References

Template:Reflist