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





