Skip to main content

Come analyze HEASARC, IRSA, and MAST data in the cloud! The Fornax Initiative is now welcoming all interested beta users.

Xspec Home Page

Metropolis–Hastings (chain type mh)

Metropolis–Hastings (MH) is the classical MCMC algorithm: at each step a candidate parameter vector is drawn from a proposal distribution centered on the current point, the candidate is accepted with probability $\min(1, p(\bm{\theta}_\mathrm{new}\vert D)/p(\bm{\theta}_\mathrm{old}\vert D))$, and either the candidate or a repeat of the current point is added to the chain. XSPEC's implementation lets the user choose the proposal shape (Gaussian, Cauchy, or uniform) and the source of its covariance matrix (the fit covariance, an explicit diagonal, or a previously loaded chain).

Strengths.    MH is robust and well-understood. Every acceptance step costs one likelihood evaluation, so the per-iteration cost is the cheapest of the four samplers. It handles arbitrarily shaped posteriors and is the only sampler that lets the user supply a fully custom proposal class through the initpackage mechanism (see Appendix G).

Weaknesses.    The proposal scale and shape must roughly match the posterior or mixing collapses. Acceptance rates well below $\sim 20\%$ or well above $\sim 60\%$ indicate the scale is off. For highly correlated parameters a Gaussian proposal derived from the fit covariance is essential; a diagonal proposal will accept almost nothing in narrow valleys.

Tips.    Always run a fit before the chain so the proposal covariance is drawn from a meaningful Hessian. Examine chain stat for each free parameter — the Rubin–Gelman statistic should be below $1.1$ and the Geweke statistic should be within $\pm 2$ before the chain is trusted. The fraction-of-repeats line is the easiest way to spot a proposal that is much too wide. When proposals from the Hessian are rejected because the covariance matrix has temporarily-frozen parameters, fall back to proposal gaussian deltas <value> with <value> of order unity.