liveBook · Manning

Convergence

As explained in Grokking Bayes

MCMC convergence is the property that a Markov chain's distribution approaches its target distribution as the number of iterations increases.

Convergence means that a computational procedure has run far enough for its output to represent the intended result. For MCMC, different chains should reach the same stationary distribution; for variational inference, the optimized objective should flatten near an optimum. section 5.11 section 6.10

Check convergence with diagnostics suited to the method:

  • Compare multiple MCMC chains. An R̂ close to 1 suggests that chains sampled from the same stationary distribution; values above 1.05 indicate that samples should not yet be trusted. section 5.11
  • Inspect effective sample size alongside convergence. A low ESS indicates inefficient, highly correlated sampling even when chains appear to have converged. section 5.11
  • For variational inference, plot the ELBO during gradient descent. A flattened curve suggests convergence; an early stop requires increasing the optimization length. section 6.10
  • Treat warnings as actionable evidence. Longer burn-in, more samples, a higher target_accept value, or model reparameterization may be needed. section 5.8 section 10.3

Inspecting an MCMC run

After sampling a tea-versus-coffee model in PyMC, run `az.summary(samples, var_names=["p"])`. The resulting table reports R̂, effective sample size, means, spreads, and credible intervals, allowing convergence and sampling quality to be inspected together. section 5.11

import matplotlib.pyplot as plt
 
plt.plot(vi_approx.hist)
plt.show()

Plotting `vi_approx.hist` makes optimization progress visible: a plateau in the ELBO indicates that further gradient-descent steps are no longer changing the objective substantially. section 6.10

How Grokking Bayes covers it

How deep it goes
Explains R̂, ESS, burn-in, chain comparison, and ELBO flattening, but does not derive their underlying mathematics.
Examples
Uses a tea-versus-coffee MCMC model, an ArviZ summary table, an ELBO progress plot, and Bayesian neural-network sampling warnings.
What you can do after
Diagnose sampling or optimization runs and choose longer burn-in, more iterations, higher target_accept, or model revision.
How it connects
Connects MCMC with stationary distributions, burn-in, effective sample size, mixing, and posterior predictive checks, and connects VI with gradient descent and ELBO.

Also explained in

Compare how 6 books explain convergence →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Grokking Bayes. The section links point to the parts of the book it draws on.