What is Rejection Sampling?
Rejection sampling is a technique used to generate samples from a target probability distribution when direct sampling is difficult or impossible. It works by sampling from a simpler proposal distribution and accepting or rejecting samples based on specific criteria.
The fundamental idea of rejection sampling can be visualized as throwing darts uniformly at a two-dimensional graph and keeping only those darts that land under the curve of the target density function[1]. This creates a uniform distribution of points under the curve, which corresponds to samples from the desired distribution.
Basic Algorithm
The rejection sampling algorithm works as follows:
- Choose a proposal distribution g(x) that is easy to sample from
- Find a constant M such that f(x) ≤ M·g(x) for all x, where f(x) is the target distribution
- Sample a point X from the proposal distribution g(x)
- Sample a uniform random variable U from U[0,1]
- Accept X if U ≤ f(X)/(M·g(X)), otherwise reject X and return to step 3[1][2]
This process continues until the desired number of samples is obtained. The accepted samples follow the target distribution f(x).
Key Requirements
For rejection sampling to work properly:
- The support of the target distribution f must be a subset of the support of the proposal distribution g[2]
- There must exist a finite value M such that f(x) ≤ M·g(x) for all x[2]
- Typically, the proposal distribution should have heavier tails than the target distribution[2]
Efficiency Considerations
The efficiency of rejection sampling depends on the constant M. The probability of accepting a sample is 1/M, which means that on average, M samples are needed to accept one sample[1][2]. Therefore, choosing a proposal distribution g(x) that closely resembles the target distribution f(x) minimizes M and improves efficiency[2].
Proof of Rejection Sampling
To prove that rejection sampling works, we need to show that the accepted samples follow the target distribution f(x). We can do this by analyzing the cumulative distribution function (CDF) of the accepted samples.
Let Z be a random variable representing an accepted sample. We want to prove that Z follows the distribution with density f(x).
Step 1: Define the CDF of the accepted samples
The CDF of Z at point y is:
[P(Z \leq y) = P(X \leq y | \text{X is accepted})]
Step 2: Apply Bayes' rule
Using Bayes' rule:
[P(Z \leq y) = \frac{P(X \leq y \text{ and X is accepted})}{P(\text{X is accepted})}]
Step 3: Express the acceptance condition
A sample X is accepted when U ≤ f(X)/(M·g(X)), where U is uniform on [0,1].
Step 4: Expand the numerator
[P(X \leq y \text{ and X is accepted}) = \int_{-\infty}^{y} P(X = t \text{ and X is accepted}) dt]
[= \int_{-\infty}^{y} g(t) \cdot P(\text{X is accepted} | X = t) dt]
[= \int_{-\infty}^{y} g(t) \cdot \frac{f(t)}{M \cdot g(t)} dt]
[= \frac{1}{M} \int_{-\infty}^{y} f(t) dt]
Step 5: Calculate the denominator
The probability that any sample is accepted is:
[P(\text{X is accepted}) = \int_{-\infty}^{\infty} g(t) \cdot \frac{f(t)}{M \cdot g(t)} dt = \frac{1}{M} \int_{-\infty}^{\infty} f(t) dt = \frac{1}{M}]
Since f(t) is a probability density function, its integral over the entire domain equals 1.
Step 6: Combine the results
[P(Z \leq y) = \frac{\frac{1}{M} \int_{-\infty}^{y} f(t) dt}{\frac{1}{M}} = \int_{-\infty}^{y} f(t) dt]
This is exactly the CDF of the target distribution with density f(t), which proves that the accepted samples follow the target distribution[5][8].
Applications and Limitations
Applications
- Bayesian inference when sampling from posterior distributions
- Generating random variables from complex distributions
- Statistical modeling and machine learning algorithms[4][7]
Limitations
- Inefficient for high-dimensional problems (curse of dimensionality)[1]
- Wasteful when the proposal distribution doesn't closely match the target distribution[2]
- Can be computationally expensive when the acceptance probability is low[7]
For high-dimensional problems, more advanced techniques like Markov Chain Monte Carlo (MCMC) methods may be more appropriate[1].