Commit f2447ab
NEW: Markov Chain Monte Carlo lecture (#332)
* NEW: Markov Chain Monte Carlo lecture
Translation of mh_notes.tex (Bayesian inference via Metropolis-
Hastings) into a MyST lecture, placed after stationary_densities
in the TOC.
- Theorems, definitions, examples, proofs and the algorithm use
sphinx-proof (prf:) directives with mcmc_-prefixed labels
- One sentence per paragraph throughout, per the style manual
- Bold for defined terms, sentence-case headings, \mathrm{Uniform},
US spelling, no \tag equation numbering
- Cross-link to the stationary_densities lecture in the Markov
kernels section
- Cites MeynTweedie2009 (already in quant-econ.bib)
Verified with a standalone jupyter-book build: no warnings, all
eq/prf/ref/cite targets resolve, all 11 directives render with
correct titles and numbering.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* [mcmc] Add JAX numerical example: conjugate check, ergodicity, non-conjugate priors
Extends the MCMC lecture with worked numerical sections:
- A numerical example: Gaussian model with conjugate prior; MH
sampler in JAX (lax.scan, jit, log acceptance ratio, explicit
PRNG keys); draws validated against the closed-form posterior
- Ergodicity in action: running mean of one trajectory (LLN part)
and a vmap ensemble of 10,000 chains from a bad initial condition
showing total variation convergence (echoing the density-sequence
figures in stationary_densities)
- Losing conjugacy: quadrature ground truth on a grid, then
(i) Student-t prior under prior-data conflict (heavy tails let
the data overrule the prior), and (ii) a bimodal Gaussian mixture
prior with ambiguous data (posterior inherits the two-regime
structure, modes pulled toward the evidence)
- Exercises: proposal-scale tuning with trace plots; sample size
sweep resolving the bimodal posterior
Seeds chosen so figures match the narrative (sample mean near the
true value; first two mixture observations genuinely ambiguous).
Verified by executing the full lecture via jupytext --to py
(all figures inspected) and a standalone jupyter-book build.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* [mcmc] Editorial pass + parallel-chains restructure
Editorial edits by John: new introductory passage, tightened Overview
and roadmap, dθ' notation alongside μ(dθ') with explanatory note,
TV-convergence remark moved out of the ergodic theorem statement,
softened phrasing in the non-conjugate sections. Plus typo fixes on
top (Some/essence/produces/case, heavy-tailed double hyphen) and
trailing whitespace removal.
Ensemble figure: replace dates (10,...,499) with (1,5,15,25,40,80)
so the cross-section densities show the full journey to the
posterior instead of stacking on it; trim T_short to 100.
Parallel-chains restructure: scalar mh_chain is sequential and
wastes accelerators, so add a vmap-based mh_ensemble helper and run
all sampling workloads as 4,096 parallel chains (500 burn-in, pooled
to ~4M draws). Burn-in is now discussed explicitly and justified by
the TV-convergence result. Running mean uses a single ensemble row,
as the ergodic theorem requires; exercise 1 keeps single chains
(mixing is the point) and is self-contained. New passage ties the
pattern to NumPyro/BlackJAX: this is what runs under the hood of the
libraries used in later lectures.
Side effects: total runtime ~9s on CPU (was ~30s), posterior moments
match to 4 decimals, smoother histograms.
Verified by full execution via jupytext --to py with all seven
figures inspected; all references resolve.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 17fd093 commit f2447ab
2 files changed
Lines changed: 1232 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
0 commit comments