Tidy and strengthen ar1_bayes lecture#927
Open
jstac wants to merge 3 commits into
Open
Conversation
Style and correctness pass on the AR(1) Bayesian posteriors lecture,
aligned with the QuantEcon styleguide:
- Fix bugs: :tags: directive typo (output was never hidden), wrong model
in a summary cell, stationary-variance typo, "kernal", MCMC wording.
- Adopt Unicode Greek variable names, np.random.default_rng, plain N for
the normal distribution, IID, sentence-case headings, {cite:t}, and
ax-style plotting with lw=2.
- Add an Overview section and a roadmap to each section; introduce every
code block with a sentence of prose.
- Link to intro AR(1) lecture; link NUTS explanation to bayes_nonconj
(add a (nuts) anchor there) instead of re-explaining.
- Teach the main point: add a "Comparing the two posteriors" section that
overlays the two posteriors for rho, and pay off the two-library setup
with an explicit PyMC vs NumPyro agreement check.
- Fix terminology once and use it throughout: the "conditioning
assumption" vs the "stationary assumption", defined by whether the
density of y0 depends on the parameters.
- Rewrite the conclusion with a plain-English rule of thumb.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
arviz 1.x (the arviz_plots backend) no longer accepts the figsize kwarg on plot_trace and raises ValueError, breaking notebook execution in CI (which pip-installs the latest arviz). Remove figsize from the two az.plot_trace calls; arviz uses its default size, which is also more consistent with the styleguide. Verified against arviz 1.2.0 that plot_trace(idata), summary(round_to=...), and posterior[...] access all work; only the figsize kwarg was the problem. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This was referenced Jun 22, 2026
📖 Netlify Preview Ready!Preview URL: https://pr-927--sunny-cactus-210e3e.netlify.app Commit: 📚 Changed LecturesBuild Info
|
- Restructure the Overview into Setting / Libraries / Imports subsections and move the likelihood factorization down to where it is used. - Explain how the PyMC model is declared (priors, vectorized likelihood as the product of one-step densities) so the setup is less opaque. - Highlight, with notes and code comments, exactly how each assumption is imposed: the conditioning assumption drops f(y0); the stationary assumption restores it via the single y0_obs term. - For NumPyro, add a short PyMC->NumPyro syntax mapping (function vs with block, numpyro.sample, obs= vs observed=) instead of repeating the explanation, and mirror the assumption code comments. - Fix a typo and use "stationary distribution" consistently. 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.
What
A tidy-up and pedagogical strengthening of the Posterior Distributions for AR(1) Parameters lecture (
ar1_bayes.md), plus a one-line anchor added tobayes_nonconj.mdso the NUTS explanation can be linked rather than duplicated.Changes
Bug fixes
:tag:→:tags:onhide-outputcells (the typo meant install/sampling output was never actually hidden).with AR1_model:to summarisetrace_y0→ corrected toAR1_model_y0.Styleguide alignment
ρ,σ,ε);np.random.default_rnginstead of legacy RNG; plainNfor the normal distribution; "IID"; sentence-case headings;{cite:t}for the in-text Hurwicz citation;ax-style plotting withlw=2and lowercase axis labels.## Overviewsection and a roadmap to each section; every code block is now introduced by a sentence of prose.Teaching improvements
bayes_nonconjinstead of re-explaining it.Note for reviewers
Switching to$y_0=10$ is fixed far in the tail), but please eyeball the rendered preview to confirm the conditioning posterior sits near $0.5$ , the stationary one is pushed toward $1$ , and the two libraries agree.
np.random.default_rngchanges the simulated series (PCG64 vs MT19937), so the figures and posterior numbers will differ from the live site. The qualitative story is preserved (🤖 Generated with Claude Code