In numerical analysis and
computational statistics, rejection sampling is a basic technique used to generate observations from a
distribution. It is also commonly called the acceptance-rejection method or "accept-reject algorithm" and is a type of exact simulation method. The method works for any distribution in
with a
density.
Rejection sampling is based on the observation that to sample a
random variable
A random variable (also called random quantity, aleatory variable, or stochastic variable) is a Mathematics, mathematical formalization of a quantity or object which depends on randomness, random events. The term 'random variable' in its mathema ...
in one dimension, one can perform a uniformly random sampling of the two-dimensional Cartesian graph, and keep the samples in the region under the graph of its density function.
Note that this property can be extended to ''N''-dimension functions.
Description
To visualize the motivation behind rejection sampling, imagine graphing the
probability density function (PDF) of a random variable onto a large rectangular board and throwing darts at it. Assume that the darts are uniformly distributed around the board. Now remove all of the darts that are outside the area under the curve. The remaining darts will be distributed uniformly within the area under the curve, and the
‑positions of these darts will be distributed according to the random variable's density. This is because there is the most room for the darts to land where the curve is highest and thus the probability density is greatest.
The visualization just described is equivalent to a particular form of rejection sampling where the "proposal distribution" is uniform. Hence its graph is a rectangle. The general form of rejection sampling assumes that the board is not necessarily rectangular but is shaped according to the density of some proposal distribution (not necessarily normalized to
) that we know how to sample from (for example, using
inversion sampling). Its shape must be at least as high at every point as the distribution we want to sample from, so that the former completely encloses the latter. Otherwise, there would be parts of the curved area we want to sample from that could never be reached.
Rejection sampling works as follows:
#Sample a point on the
‑axis from the proposal distribution.
#Draw a vertical line at this
‑position, up to the y-value of the probability density function of the proposal distribution.
#Sample uniformly along this line. If the sampled value is greater than the value of the desired distribution at this vertical line, reject the
‑value and return to step 1; else the
‑value is a sample from the desired distribution.
This algorithm can be used to sample from the area under any curve, regardless of whether the function integrates to 1. In fact, scaling a function by a constant has no effect on the sampled . Thus, the algorithm can be used to sample from a distribution whose
normalizing constant is unknown, which is common in
computational statistics.
Theory
The rejection sampling method generates sampling values from a target distribution
with an arbitrary
probability density function by using a proposal distribution
with probability density
. The idea is that one can generate a sample value from
by instead sampling from
and accepting the sample from
with probability
, repeating the draws from
until a value is accepted.
here is a constant, finite bound on the likelihood ratio
, satisfying
over the
support of
; in other words, M must satisfy
for all values of
. Note that this requires that the support of
must include the support of
—in other words,
whenever
.
The validation of this method is the envelope principle: when simulating the pair
, one produces a uniform simulation over the subgraph of
. Accepting only pairs such that