Back

MCMC Sampler Comparator

What you are seeing: three different random-walk algorithms trying to sample from the same probability density π(x,y)\pi(x, y). The grey shading on the left is the density itself (darker = higher probability). Each colored trail is one sampler laying down points: it tries to walk in a way that, in the long run, spends time at each (x,y)(x, y) in proportion to π\pi.

A "good" sampler explores the whole region quickly and decorrelates; a "bad" sampler gets stuck. The right panels are live trace plots of the xx coordinate of each chain, plus its acceptance rate and effective sample size NeffN_\text{eff}. Switch the target to the banana or the funnel to see HMC pull ahead; switch to the mixture to see samplers getting trapped in one mode.

Figure 1. Three MCMC samplers running simultaneously on a 2D target. Method: shared/js/engine/mcmc-harness.js; ESS via the initial monotone sequence estimator from shared/js/invariants/ess.js.
Target
Sampler A
Sampler B
Sampler C
HMC L
Sample N

WHAT TO TRY

  • Switch the target to the banana: a curved ridge that trips up samplers tuned for round Gaussians, so the chains struggle to follow the bend.
  • Compare the chains: too small a step gives high acceptance but a slow crawl, too large a step is rejected constantly. The sweet spot sits around 25 percent acceptance.
  • Read the effective sample size: a thousand correlated samples are not a thousand independent draws, and that autocorrelation is what really limits how much each chain learns.