Bayesian Monte Carlo and MCMCLesson 72 of 76 · 10 min
Correct an asymmetric proposal
Include the reverse-to-forward proposal ratio in Metropolis–Hastings.
Let x be current and y proposed. is the density of proposing y from x; is the reverse density. For target density π, Metropolis–Hastings uses target ratio π(y)/π(x) times reverse/forward proposal density, capped at one. In a symmetric walk those proposal densities cancel.
An independence proposal draws from fixed q regardless of x. Then the forward density is q(y) and reverse density q(x); they can differ even though the draw does not depend on x. Omitting the correction generally changes the stationary distribution, the distribution preserved by a transition. Here proposal beta(3,3) is corrected back to target beta(20,14).
Retain rejections and set aside a starting segment as before. Irreducibility means the transition can reach relevant target regions, possibly over several steps; a density ratio cannot repair an unreachable region. One matching mean is an implementation check, not proof that the sampler explored the whole target.
The vertical bar reads ‘given’. Here is target density, not the circle constant; q is proposal density. An independence proposal uses q(x)/q(y) as its reverse/forward factor.
- Propose a candidate
- Correct the asymmetry
- Accept or retain the old state
Does drawing an independence proposal make the proposal-density correction unnecessary?
Write a prediction (optional)
Seeded teaching simulation
Select Run Python below with the code unchanged.
A saved draft is open. To run the published example, open Tools and select Restore example. Recover draft brings your code back.
Execution error
Technical error details
Your result
Published example output
This result comes from the original Python. Your runs appear above. Build environment ↗
Acceptance fraction: 0.448 Kept mean: 0.5919 exact: 0.5882352941176471
Read the first result
The proposal correction uses current over proposed density for an independence sampler. Reversing that ratio implements a different algorithm.
Try an edit
Replace stats.beta.logpdf(p,3,3) with stats.beta.logpdf(p,10,10) and proposal = rng.beta(3,3) with proposal = rng.beta(10,10). Select Run Python again. Compare Acceptance fraction and Kept mean with the first run. Change default_rng(2071) to default_rng(72) and run again. What is still the exact target mean across both proposals?
Scope. Support and irreducibility still matter. A density ratio cannot rescue a proposal that never reaches relevant target regions.
Try a fresh case
For q(y|x), what proposal factor belongs in the acceptance ratio?
Need a hint?
Hint 1
Identify the proposed forward move x to y.
Hint 2
The correction is reverse density divided by forward density.