NEW: Markov Chain Monte Carlo lecture#332
Merged
Merged
Conversation
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>
✅ Deploy Preview for lustrous-melomakarona-3ee73e ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
…njugate 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>
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a new lecture, Markov Chain Monte Carlo (
mcmc.md), placed immediately afterstationary_densitiesin the Tools and Techniques section of the TOC.The first part is a translation of an existing set of LaTeX notes on Bayesian inference via Metropolis-Hastings sampling; the second part adds a worked numerical example in JAX.
Theory (translation)
Numerical example (JAX)
jax.lax.scan+jitwith explicit PRNG keys and the log acceptance ratio; draws validated against the closed-form posterior (moments agree to 3 decimals)vmapensemble of 10,000 chains launched from a deliberately bad initial condition, whose cross-section densities march to the posterior (the TV-convergence conclusion) — visually echoing the density-sequence figures instationary_densitiesConventions
prf:definition, 4prf:theorem(withprf:proof), 1prf:example, 1prf:algorithm— all labels prefixedmcmc_\mathrm{Uniform}, no\tagnumberingmystnbfigure captions on main-text figures; none inside exercise/solution directives (PDF constraint)!pip install jaxfollowing the precedent indovis_accounting_mf.md, with a note admonition saying CPU is sufficient (the examples are small — no GPU needed)stationary_densitieslecture; citesMeynTweedie2009(already inquant-econ.bib)Verification
!piplexer notice; every{eq}/{prf:ref}/{ref}/{cite}target resolves; all 11 numbered directives render correctlyjupytext --to py: clean run, all 7 figures inspected; seeds chosen so the figures match the narrative (sample mean lands near the true value; the first two mixture observations are genuinely ambiguous so the n=2 posterior is visibly bimodal)🤖 Generated with Claude Code