Rejection Sampling
Core Titles
Key headlines and terms for quick recall- Target density , Proposal density
- Envelope constant with for all
- Accept with probability
- Acceptance rate
- Pros / Cons vs inverse transform, MCMC
Basic Idea
What it is, why it matters, how it worksMotivation
Inverse-transform sampling needs in closed form — often impossible. Rejection sampling lets us sample from as long as we can evaluate it (up to a constant) and find a good proposal that we can sample from.
Algorithm
Given:
- target density we want to sample from,
- a proposal density we can sample from,
- a constant with for all .
Steps.
- Sample .
- Sample .
- If , accept . Else reject and go to step 1.
Why it works
The accepted samples have the target distribution . Proof: .
Marginal: .
Conditional CDF of accepted samples: .
So accepted samples follow .
Acceptance rate
We want as small as possible (i.e., should "hug" tightly). Bad choice of ⇒ many rejections ⇒ slow.
Practical tip
Choose in the same family as but easy to sample (e.g., normal, exponential, uniform).
Why this matters in Data Science
Backbone of Monte Carlo methods. Used when target density is awkward but proposals are easy: Bayesian inference (when MCMC is overkill), simulation, generative modelling.
Mind Map
Visual structure of the conceptREJECTION SAMPLING
├── Target f, Proposal g, M (Mg ≥ f)
├── Algorithm
│ ├── Draw X ~ g
│ ├── Draw U ~ Uniform(0,1)
│ ├── Accept if U ≤ f(X)/(M g(X))
│ └── Else reject, repeat
├── Accepted ~ f (proof via CDF)
├── Acceptance rate = 1/M
└── Goal: small M ⇒ g hugs f tightly
Exam Q&A
Part A (2 marks) and Part B (20 marks) style questionsPart A (2 marks each)
Q1. Why rejection sampling? When the target CDF cannot be inverted in closed form but the density can be evaluated.
Q2. State the rejection condition. Accept if , where .
Q3. What is the acceptance probability of rejection sampling? .
Q4. What governs efficiency of rejection sampling? The tightness of the envelope over ; smaller is more efficient.
Part B (20 marks)
Q. Describe the rejection sampling algorithm. Prove that the accepted samples follow the target distribution. Use rejection sampling to sample from the truncated normal on using a uniform proposal.
Algorithm.
- Target density , support .
- Proposal density on from which we can sample.
- Constant so that for all .
loop:
X ~ g
U ~ Uniform(0, 1)
if U ≤ f(X) / (M g(X)):
return X
Proof. Let denote the event "accept on this iteration".
.
Marginal acceptance: .
Conditional on acceptance:
So the accepted has CDF — i.e., distribution . ∎
Truncated normal on .
The truncated standard normal density on is where .
Proposal: on (uniform).
Envelope. is maximised at : .
So take .
Algorithm.
- .
- .
- Accept if .
Acceptance rate — efficient. A poorly-chosen (e.g., wide normal) would give a much higher and many rejections.