Ratio of uniforms explained

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

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]

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,\ldots,

1
1+rd
x
d)
and

xif(x1,x2,\ldots,

r
1+rd
x
d)
for all

i

are bounded),

Af,r

is bounded. One can define the rectangular bounding box

\tilde{A}f,r

such thatA_ \subset \tilde_ = \left[0, \sup_{x_1, \ldots, x_d}{f(x_1, \ldots, x_d)^{\frac{1}{1+rd}}}\right]\times\prod_i \left[\inf_{x_1, \ldots, x_d}{x_i f(x_1, \ldots, x_d)^{\frac{r}{1+rd}}}, \sup_{x_1, \ldots, x_d}{x_i f(x_1, \ldots, x_d)^{\frac{r}{1+rd}}}\right]This allows to sample uniformly the set

Af,r

by rejection sampling inside

\tilde{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\left(x_1, x_2, \ldots, x_d \right)^\frac\quad\text\quad\forall i \in [|1, n|], v_i = x_i u^ror for the common case where

X

is a 1-dimensional variable,

(u,v)=

1
1+r
\left(f(x)

,

r
1+r
xf(x)

\right)

.

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:R+ → R+

is a strictly increasing and differentiable function such that

g(0)=0

, then we can define

Af,g

such that

A_ = \left\

If

(U,V)

is a random variable uniformly distributed in

Af,g

, then
V
g'(U)
is distributed with the density

p

.

Examples

The exponential distribution

Assume that we want to sample the exponential distribution,

p(x)=λe

with the ratio of uniforms method. We will take here

r=1

.

We can start constructing the set

Af,1

:

Af,1=\left\{(u,v)\inR2:0\lequ\leq\sqrt{p\left(

v
u

\right)}\right\}

The condition

0\lequ\leq\sqrt{p\left(

v
u

\right)}

is equivalent, after computation, to

0\leqv\leq-

uln
λ
u2
λ
, which allows us to plot the shape of the set (see graph).

This inequality also allows us to determine the rectangular bounding box

\tilde{A}f,1

where

Af,1

is included. Indeed, with

g(u)=-

uln
λ
u2
λ
, we have

g\left(\sqrt{λ}\right)=0

and
g'\left(2
e\sqrt{λ
}\right) = 0, from where

\tilde{A}f,1=\left[0,\sqrt{λ}\right] x \left[0,g\left(

2
e\sqrt{λ
}\right)\right].

From here, we can draw pairs of uniform random variables

U\simUnif\left(0,\sqrt{λ}\right)

and

V\simUnif\left(0,g\left(

2
e\sqrt{λ
}\right)\right) until

u\leq

v
u
\sqrt{λe
}, and when that happens, we return
v
u
, which is exponentially distributed.

A mixture of normal distributions

Consider the mixture of two normal distributions

l{D}=0.6N(\mu=-1,\sigma=2)+0.4N(\mu=3,\sigma=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

\tilde{A}f,r

enclosing the set

Af,r

. This can be done numerically, by computing the minimum and maximum of

u(x)=

1
1+r
f(x)
and

v(x)=

r
1+r
xf(x)
on a grid of values of

x

. Then, one can draw uniform samples

(u,v)\in\tilde{A}f,r

, only keep those that fall inside the set

Af,r

and return them as
v
ur
.

It is possible to optimize the acceptance ratio by adjusting the value of

r

, as seen on the graphs.

Software

See also

Notes and References

  1. Kinderman. A. J.. Monahan. J. F.. September 1977. Computer Generation of Random Variables Using the Ratio of Uniform Deviates. ACM Transactions on Mathematical Software. 3. 3. 257–260. 10.1145/355744.355750. 12884505. free.
  2. Book: Robert . Christian . Casella . George . Monte Carlo Statistical Methods . 2004 . Springer-Verlag . 978-0-387-21239-5 . 47 . 2 . en.
  3. Martino. Luca. Luengo. David. Míguez. Joaquín. 16 July 2013. On the Generalized Ratio of Uniforms as a Combination of Transformed Rejection and Extended Inverse of Density Sampling. 1205.0482. 13. stat.CO.
  4. Book: GOBET, EMMANUEL. MONTE-CARLO METHODS AND STOCHASTIC PROCESSES : from linear to non-linear.. 2020. CRC PRESS. 978-0-367-65846-5. [S.l.]. 1178639517.
  5. Wakefield . J. C. . Gelfand . A. E. . Smith . A. F. M. . Efficient generation of random variates via the ratio-of-uniforms method . Statistics and Computing . 1 December 1991 . 1 . 2 . 129–133 . 10.1007/BF01889987 . 119824513 . en . 1573-1375.