Bayesian Machine Learning · Markov chain Monte CarloThe Metropolis algorithm

Metropolis on Two Humps

The target p(θ) = ½ N(θ; −1, 0.5²) + ½ N(θ; 1, 0.5²) has two humps. We can compute p(θ) anywhere, but we can't sample from it. Start somewhere; propose θp from q(θ; θc) = N(θc, σ²); move with probability pmove = min(1, p(θp) / p(θc)), otherwise stay. Where the walk has been is the sample, and the width σ is the knob.

1 · Targetp(θ), two humps
2 · Proposal
3 · Samples ≈ p(θ)
4 · Trace of θc, the last 400 iterations
N = 0