When the random walk goes wrong
Chapter 4 · The Metropolis–Hastings random walk of Exercise 4.8 works well when the posterior is one compact, roughly round blob. This page uses a simpler two-weight target so that you can break it on purpose. Two chains run with the same Gaussian proposal of one step size, one starting at the mode and one starting at a random place with non-negligible density. Compare the walk with the true density, and the histograms with both the true marginals and the Laplace approximation (a Gaussian at the highest mode).
The walk in weight space
Blue lines: contours of the true target at log-height drops of 0.5, 2, 4.5 and 8. Dashed red: the Laplace Gaussian at the same drops. ● chain 1 (starts at the highest mode), ● chain 2 (starts elsewhere); lines show the last 150 steps of each, and the large dots are the current points. Diamond: the mode.
Trace plots
Both chains, for each weight. If the chains have converged and mix well they overlap and look like noise around the same level. Dashed vertical line: end of burn-in.
Marginals: true, Laplace and sampled
Bars: pooled samples of both chains after burn-in. Solid grey curve: the true marginal (computed on a grid). Dashed red: the Laplace Gaussian.