Skip to content

Rejection sampling

Generate a target density with accept–reject sampling: a global envelope, an exact triangular example, acceptance probability and the cost of discarded proposals.

Rejection sampling generates a draw from a target distribution by proposing a value from an easier distribution, then accepting it with a carefully chosen probability. Rejected candidates are discarded and the procedure starts again. It is also called the accept–reject algorithm.
In a Monte Carlo simulation, the target might be a modelled loss severity or a bounded risk factor whose density is easy to evaluate but awkward to invert. Rejection sampling supplies the random inputs; it does not establish that the chosen distribution describes market losses.

The envelope does the work

Let ff be the target probability density function, and let qq be a proposal density that we can sample. Choose a finite constant MM satisfying
f(x)≤Mq(x)f(x)\le Mq(x)

throughout the target support. The proposal must cover every region to which the target assigns positive probability. With both densities normalized, necessarily M≥1M\ge1.

For each attempt:

  1. Draw a candidate X∼qX\sim q and an independent U∼Uniform⁡(0,1)U\sim\operatorname{Uniform}(0,1).
  2. Accept XX if U≤f(X)/(Mq(X))U\le f(X)/(Mq(X)).
  3. Otherwise discard the pair and retry with fresh independent inputs.
The continuous uniform distribution converts the density ratio into an acceptance probability. Draw candidates from qq, not from the scaled curve MqMq: the latter integrates to MM and generally is not a density.

A tilted distribution from flat proposals

Consider a synthetic, dimensionless risk factor with
f(x)=2x,0≤x≤1,f(x)=2x,\qquad 0\le x\le1,

and zero density elsewhere. Its density increases toward one. Use a uniform proposal on [0,1][0,1], so q(x)=1q(x)=1 there. The envelope M=2M=2 dominates the entire density, giving

f(x)Mq(x)=x.\frac{f(x)}{Mq(x)}=x.

Thus a candidate near one is more likely to survive than a candidate near zero. The proposal stays uniform; the acceptance filter changes the distribution of retained values.

Fixed candidate xxFixed uniform input uuDecision
0.20.20.10.1Accept 0.20.2
0.60.60.80.8Reject
0.90.90.70.7Accept 0.90.9
These are deliberately chosen pairs, not random samples. Their two acceptances out of three are not an estimate of the algorithm's acceptance probability.
Unit-square accept–reject construction: accept u at or below x. The triangle has area one half. Fixed pairs (0.2,0.1) and (0.9,0.7) are accepted; (0.6,0.8) is rejected. Exact acceptance probability is one half and expected proposals per output is two.
Unit-square accept–reject construction: accept u at or below x. The triangle has area one half. Fixed pairs (0.2,0.1) and (0.9,0.7) are accepted; (0.6,0.8) is rejected. Exact acceptance probability is one half and expected proposals per output is two.
Original deterministic illustration for the synthetic density f(x)=2xf(x)=2x. The marked pairs demonstrate decisions; the area calculation establishes the probability.

The geometry also verifies the output distribution. For 0≤b≤10\le b\le1, the area of the accepted triangle to the left of bb is b2/2b^2/2. Dividing by the whole accepted area, 1/21/2, gives

P(X≤b∣accepted)=b2.\mathbb{P}(X\le b\mid\text{accepted})=b^2.

Its derivative is 2b2b, exactly the target density. For example, only one quarter of the accepted distribution lies at or below 0.50.5, although half of the original uniform proposal distribution does.

Why rejection does not bias the target

For any measurable region AA, the joint probability of proposing a value in AA and accepting is

P(X∈A, accepted)=∫Aq(x)f(x)Mq(x) dx=1M∫Af(x) dx.\mathbb{P}(X\in A,\text{ accepted}) =\int_A q(x)\frac{f(x)}{Mq(x)}\,dx =\frac{1}{M}\int_A f(x)\,dx.
Over the full support this gives P(accepted)=1/M\mathbb{P}(\text{accepted})=1/M. Conditioning on acceptance cancels that factor and leaves the target probability ∫Af(x) dx\int_A f(x)\,dx. With independent attempts, the number of proposals up to and including the next acceptance has a geometric distribution, with mean MM. Fresh independent inputs also give independent retained draws.

For our example, acceptance probability is 1/21/2 and the expected cost is two proposals per accepted output. This is an average, not a promise that every second proposal succeeds. The count includes the successful proposal.

A valid bound is more valuable than a convincing plot

An envelope must dominate everywhere relevant, including the tails. A few plotted points or a large observed acceptance rate cannot certify the bound. Missing proposal support loses target outcomes altogether. Using a bound that is too small, then capping the acceptance ratio at one, generally samples the wrong distribution.

A larger valid bound preserves correctness but wastes attempts. In the same example, choosing M=4M=4 reduces acceptance to 1/41/4 and raises the expected number of proposals to four. Choosing a proposal closer to the target can improve efficiency, provided the global bound remains valid. Cost per proposal matters too: a tighter envelope may require more expensive calculations.

The method can also use an unnormalized target hh, provided 0<Z=∫h(x) dx<∞0<Z=\int h(x)\,dx<\infty and a known bound h(x)≤Cq(x)h(x)\le Cq(x) is available. Accept with probability h(X)/(Cq(X))h(X)/(Cq(X)). The output density is h/Zh/Z, and acceptance probability is Z/CZ/C, not generally 1/C1/C. The unknown normalizing constant cancels from the decision. Luke Tierney's simulation notes develop this envelope formulation and its numerical considerations.
Inverse transform sampling offers a different route when an accurate quantile function is available. For the finance setting and the geometric basis of acceptance–rejection, see Random Number Generation (public preview; full lesson requires membership).

Sources

  • Geoffrey R. Grimmett and David R. Stirzaker, Probability and Random Processes, third edition (Oxford University Press, 2001), §4.11, Example 5, pp. 123–124: the rejection method and its conditional-distribution argument.
  • Luke Tierney, Computer Intensive Statistics, Chapter 9, §§9.4.4.1–9.4.4.3, University of Iowa: sampling under a density, unnormalized envelopes and the accept–reject algorithm.
Last updated
  • simulation
  • random variate generation
  • accept reject
  • envelope density
← Back to the glossaryBack to top ↑