Skip to content

Tidy and strengthen ar1_bayes lecture#927

Open
jstac wants to merge 3 commits into
mainfrom
tidy-ar1-bayes
Open

Tidy and strengthen ar1_bayes lecture#927
jstac wants to merge 3 commits into
mainfrom
tidy-ar1-bayes

Conversation

@jstac

@jstac jstac commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

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 to bayes_nonconj.md so the NUTS explanation can be linked rather than duplicated.

Changes

Bug fixes

  • :tag::tags: on hide-output cells (the typo meant install/sampling output was never actually hidden).
  • Summary cell used with AR1_model: to summarise trace_y0 → corrected to AR1_model_y0.
  • Stationary-variance typo $\frac{\sigma_x^2}{(1-\rho)^2}$$\frac{\sigma_x^2}{1-\rho^2}$.
  • "Monte Carlo Markov Chain" → "Markov Chain Monte Carlo"; "kernal" → "kernel".

Styleguide alignment

  • Unicode Greek variable names (ρ, σ, ε); np.random.default_rng instead of legacy RNG; plain N for the normal distribution; "IID"; sentence-case headings; {cite:t} for the in-text Hurwicz citation; ax-style plotting with lw=2 and lowercase axis labels.
  • Added an ## Overview section and a roadmap to each section; every code block is now introduced by a sentence of prose.

Teaching improvements

  • New Comparing the two posteriors section overlays the posterior for $\rho$ under both assumptions (true value marked) — the main point is now visible in one figure.
  • Paid off the two-library setup with an explicit PyMC vs NumPyro agreement plot.
  • Fixed terminology once and used it throughout: the conditioning assumption vs the stationary assumption, defined by whether the density of $y_0$ depends on the parameters.
  • Rewrote the conclusion with a plain-English rule of thumb.
  • Linked to the intro AR(1) lecture; linked the NUTS explanation to bayes_nonconj instead of re-explaining it.

Note for reviewers

Switching to np.random.default_rng changes the simulated series (PCG64 vs MT19937), so the figures and posterior numbers will differ from the live site. The qualitative story is preserved ($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.

🤖 Generated with Claude Code

jstac and others added 2 commits June 22, 2026 05:56
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>
@github-actions

github-actions Bot commented Jun 22, 2026

Copy link
Copy Markdown

📖 Netlify Preview Ready!

Preview URL: https://pr-927--sunny-cactus-210e3e.netlify.app

Commit: 989d406

📚 Changed Lectures


Build 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant