Skip to content

[stats_info] Correct the mathematics and add exercises across the Statistics and Information lectures - #1099

Merged
mmcky merged 3 commits into
mainfrom
oct_nyc
Nov 1, 2026
Merged

mmcky merged 3 commits into
mainfrom
oct_nyc

Conversation

@mmcky

@mmcky mmcky commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

A review of the eighteen lectures in the Statistics and Information part found mathematical, statistical and coding errors, several of which changed published figures. This PR corrects them, harmonizes notation, adds cross-links among the lectures, and adds exercises with solutions, including three each to the seven lectures that had none.

Errors that altered results:

  • navy_captain: under @jit(parallel=True), numba miscompiled the boolean-mask assignment V[wf.π_grid >= A] = wf.L0 inside the if flag == 0 ... else block of V_q, zeroing the Bayesian value function, so the fixed-sample versus sequential comparison was 18 vs 0. (The bug is not a race in the reduction: it reproduces with a serial inner loop and with a single thread.) The rewritten V_q avoids that pattern.
  • merging_of_opinions: the proof of Blackwell-Dubins rested on a false supermartingale claim; replaced by a correct argument.
  • likelihood_ratio_process_2: mu_1 and mu_2 were swapped in the equilibrium allocation; the Pareto weight is pinned down by budgets.
  • pricing_information: the regularity condition was reversed and the best single-item revenue mislabelled.
  • likelihood_var: the observation matrix was off by one period and the steady state was wrong.
  • wald_friedman: the Jensen-Shannon distance was computed incorrectly.
  • divergence_measures, likelihood_ratio_process: sign and direction errors, an invalid KL account of maximum likelihood, and truncated integrals.
  • survival_recursive_preferences, market_diffusion, exchangeable, likelihood_bayes, mix_model, imp_sample, wald_friedman_2, information_market_equilibrium, blackwell_kihlstrom: corrections listed in the review.

Adds 11 bibliography entries.

Follow-up commit cb1f252 renames two exercise labels in likelihood_ratio_process that collided with labels in likelihood_ratio_process_2 (a duplicate-target warning that fails the -W build) and fixes small prose inconsistencies found in review; see the review comment on this PR for details.

🤖 Generated with Claude Code

https://claude.ai/code/session_01WT8bMXuBemTCPescM41mYa

…tistics and Information lectures

A review of the eighteen lectures in the Statistics and Information part
found mathematical, statistical and coding errors, several of which changed
published figures. This commit corrects them, harmonizes notation, adds
cross-links among the lectures, and adds exercises with solutions,
including three each to the seven lectures that had none.

Errors that altered results:
- navy_captain: a parallel numba reduction zeroed the Bayesian value
  function, so the fixed-sample versus sequential comparison was 18 vs 0.
- merging_of_opinions: the proof of Blackwell-Dubins rested on a false
  supermartingale claim; replaced by a correct argument.
- likelihood_ratio_process_2: mu_1 and mu_2 were swapped in the
  equilibrium allocation; the Pareto weight is pinned down by budgets.
- pricing_information: the regularity condition was reversed and the best
  single-item revenue mislabelled.
- likelihood_var: the observation matrix was off by one period and the
  steady state was wrong.
- wald_friedman: the Jensen-Shannon distance was computed incorrectly.
- divergence_measures, likelihood_ratio_process: sign and direction errors,
  an invalid KL account of maximum likelihood, and truncated integrals.
- survival_recursive_preferences, market_diffusion, exchangeable,
  likelihood_bayes, mix_model, imp_sample, wald_friedman_2,
  information_market_equilibrium, blackwell_kihlstrom: corrections listed
  in the review.

Adds 15 bibliography entries.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings October 31, 2026 22:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The change is too large and math- and notebook-heavy, with numerous specific numeric claims that can only be verified through a complete Jupyter Book build beyond this review's scope.

No open issues 🎉

What changed in this PR

This PR revises the eighteen lectures of the QuantEcon "Statistics and Information" part (seven of them appear in this diff) to correct mathematical, statistical, and coding errors, harmonize notation, add cross-links, and add worked exercises with solutions. Several corrections change published figures (e.g., replacing the Jensen–Shannon analysis in wald_friedman with a Kullback–Leibler / average-sample-number treatment).

Changes:

  • Fixes math/coding errors and standardizes terminology (e.g., "uniformly most powerful" → "most powerful", corrected KL direction/entropy sign in divergence_measures, garbling notation M→Q and normalization fixes in pricing_information, noise-free vs. mean-path distinction in market_diffusion).
  • Replaces internal fragile numeric helpers with closed forms (closed-form Beta KL/Chernoff via betaln/digamma) and replaces hard-coded external URLs with {doc}/{ref} cross-references.
  • Adds exercises with solutions across the lectures and adds 11 new bibliography entries.
File Description
lectures/​wald_friedman.md Swaps JS-divergence analysis for KL/average-sample-number, adds Wald bounds/identity derivations and three exercises (incl. VAR misspecification)
lectures/​wald_friedman_2.md Adds SPRT-equivalence section, deterministic seeding (seed_numba, seed= arg), ≤/≥ threshold rule, and three exercises
lectures/​pricing_information.md Corrects garbling notation/regularity conditions, two_type_revenue pricing logic, solve_menu density normalization, adds ironing exercises
lectures/​market_diffusion.md Clarifies equilibrium-value convexity, adds static_equilibrium, renames mean→noise-free path, adds first-passage/generator exercises
lectures/​imp_sample.md Clarifies notation (p/q, h), infinite-variance/tail-index discussion, adds effective-sample-size, Hill-estimator, and tilting exercises
lectures/​gallant_tauchen.md Aligns MLE/cross-entropy wording with divergence_measures
lectures/​divergence_measures.md Fixes entropy sign and KL direction, adds closed forms, data-processing inequality, Chernoff bounds, MLE pseudo-true-value section and three exercises
lectures/​_static/​quant-econ.bib Fixes Bucklew_2004 indentation and adds new references (Wald–Wolfowitz, Chernoff, Goodfellow, Hill, etc.)

Review effort: Balanced

…ncies

Rename the two exercise labels added to likelihood_ratio_process (lr_ex3,
lr_ex4) to lr_ex_markov and lr_ex_lmean, since likelihood_ratio_process_2
already defines and references lr_ex3 and lr_ex4; duplicate explicit
targets fail the -W build.

Prose fixes found in review:
- survival_recursive_preferences: figure text said 20 sample paths; code uses 50.
- blackwell_kihlstrom: summary-table row for Chentsov's theorem now matches
  the corrected body text (invariance under Markov embeddings).
- pricing_information: theta* is the type least sure what to do, not the
  least-informed type, consistent with the note earlier in the lecture.
- information_market_equilibrium: lemma hypothesis strengthened to strictly
  quasi-concave, matching the lemma it relies on.
- imp_sample: describe the h_3 estimates as more dispersed rather than more
  skewed; sample skewness is not informative with infinite variance.
- likelihood_var: soften two seed-dependent numbers (alpha_50 about 0.4,
  error probabilities roughly 0.1).
- navy_captain: note that the value-iteration Bayesian loss 11.36 rests on
  1,000 Monte Carlo draws and that the simulated loss is near 12.3; drop a
  code comment implying the old bug was a parallel reduction.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WT8bMXuBemTCPescM41mYa

mmcky commented Oct 31, 2026

Copy link
Copy Markdown
Contributor Author

Review summary

I reviewed all 17 lectures in this PR by re-deriving every claimed correction, executing every code cell (16 of 17 lectures ran with zero cell failures; imp_sample ran cleanly in isolation but was too slow to finish in a 25-minute concurrent run), and checking labels, cross-references and bibliography keys across the whole lecture set.

Bottom line: the mathematics holds up. Every error named in the description was reproduced on main and is fixed on this branch, and every number quoted in the new prose reproduces from the code. One build-breaking issue was found; it and the small prose issues below are fixed in cb1f252, pushed to this branch.

Blocking (fixed in cb1f252)

  • Duplicate exercise labels across lectures. The PR added exercises labelled lr_ex3 and lr_ex4 to likelihood_ratio_process.md, but likelihood_ratio_process_2.md already defines both labels and links to them (lines ~593, ~997, ~1747). Sphinx warns on duplicate explicit targets, and CI builds with -W, so the build would fail. The new labels are now lr_ex_markov and lr_ex_lmean, with their three references updated. No other duplicate labels exist across the 155 lectures.

Small prose issues (fixed in cb1f252)

  • navy_captain.md ~925: V_Bayes = 11.36 is quoted to two decimals, but V_q approximates expectations with the 1,000 draws in wf.z0/wf.z1. Reseeding gives 11.8 to 13.9 for the same thresholds; a 200,000-path simulation of the same rule gives 12.25 ± 0.03. Added a sentence saying so where the value is first quoted (the lecture already admits it at ~1263). A larger mc_size would also work.
  • survival_recursive_preferences.md ~1483 and ~1744: text said 20 sample paths, code uses n_paths=50.
  • blackwell_kihlstrom.md ~1319: the summary-table row for Chentsov's theorem still had the old "unique coarse-graining-contracting metric" wording that the body text corrected.
  • pricing_information.md ~923: "θ* = 1/2, the least-informed type" contradicted the PR's own new note at ~142-149.
  • information_market_equilibrium.md ~482: lemma assumed "quasi-concave" while the lemma it relies on (~425) was strengthened to "strictly quasi-concave".
  • imp_sample.md ~664: "more skewed than ... under g" was not supported (sample skewness 21.7 vs 20.1 with infinite variance); now "more dispersed".
  • likelihood_var.md ~1186, ~1242: "α₅₀ exceeds 0.4" and "near 0.1" were seed-fragile (0.38 to 0.43 across seeds); softened.

Still open (description only)

  • The description attributes the old V_q zeroing to a parallel numba reduction. The zeroing reproduces (V1 identically 0, so V_Bayes = 0 vs V_fre = 18.33) and the new code is correct, but replacing prange by range still gives zeros, and the bare V[wf.π_grid >= A] = wf.L0 inside the if/else miscompiles under parallel=True even with one thread. The fix works because it avoids that pattern. I dropped the # local to iteration i comment that implied the reduction story.
  • The description says 15 new bibliography entries; the diff adds 11 (all cited, no key collisions).

Verified corrections (highlights)

  • navy_captain: new V_q gives 11.36, matching the old code compiled serially. Also fixed: ROC column off-by-one, PD mislabel, find_cutoff_rule off by one grid point (A 0.9397 → 0.9447).
  • merging_of_opinions: the old "d_n is a Q-supermartingale by convexity of TV" is false (five-point counterexample, E_Q[d_1] = 0.233 > d_0 = 0.2); the new truncation/Lévy argument checks line by line.
  • likelihood_ratio_process_2: FOC gives c¹ = μ₂ l/(μ₁ + μ₂ l); the old formula had μ₁ and μ₂ swapped and disagreed with its own exercise solution. λ = E²/(1 − E¹ + E²) = 10/17 from budgets.
  • pricing_information: regularity direction was reversed (U-shaped Beta populations with a, b ≤ 1 are regular); the old "best single item" was a particular posted price (0.143), not the best one (0.155).
  • likelihood_var: every row of the old observation matrix was one period ahead; steady state is (γ+G)/(1−a) = 1000, not −22.7.
  • wald_friedman: old js_dist used KL(M‖f) instead of KL(f‖M); its outputs (1.09, 1.61, 2.73) exceed the JS-distance bound √ln2 ≈ 0.83.
  • divergence_measures: Beta(0.1, 0.2) has 25% of its mass outside the old quadrature range (KL 1.00 vs exact 4.98); the MLE-as-KL-from-empirical argument was invalid since that KL is infinite for densities.
  • likelihood_ratio_process: α̃/β̃ captions were swapped, the second root near w = 1 was ignored, and the "equidistant" h was not (K_f 0.117 vs K_g 0.168; now 0.13523 vs 0.13521).
  • market_diffusion: the base compared p2 with itself; the S-shape proposition now correctly describes the noise-free path (E[α_t] ≠ α̂(t), 0.38 vs 0.64 at t = 4).
  • mix_model: closed-form α* = 0.3116; "limit is 0 or 1" was false at α*; the data array had 1,000 draws while sizes went to 25,000.
  • wald_friedman_2: the density was plotted against the array index; "6.6 draws" was stale (2.82 reproduces).
  • exchangeable, likelihood_bayes, blackwell_kihlstrom, information_market_equilibrium, survival_recursive_preferences, imp_sample: all re-derived corrections and exercises check out.

Build time

navy_captain adds roughly three minutes (Exercise 3 solves the model 12 times), mix_model adds five NUTS runs, and imp_sample gains an 80-second exercise cell.

Not verified

Paper attributions (Borovička proposition numbers, Bergemann–Bonatti–Smolin corollary wording, DeGroot 1962 axioms, Wald/Wallis quotations) and rendered figures.


Generated by Claude Code

- Use {cite:t} where the cited authors are the subject of the
  sentence (15 places in 6 lectures). With author_year citations the
  hand-typed names rendered twice.
- Replace quoted section names with {ref} links, adding labels to the
  five target headings, and drop the redundant {doc} titles in the
  navy_captain sentences touched.
- likelihood_var: write transposes as ^\top and drop bold x_t, y_t
  (qe-math-002, qe-math-004).
- exchangeable: one sentence per paragraph in the exercise hint.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mmcky

mmcky commented Oct 31, 2026

Copy link
Copy Markdown
Contributor Author

Style-guide pass

I checked the PR against the QuantEcon style guide. I ran the deterministic scanner from compliance-lecture-style on all 18 lectures at main and at the PR head, kept only issues on lines this PR adds, and checked each by hand. The new material is in good shape: exercises and solutions, headings, figures, packages and links all pass. Commit 9242534 applies the simple fixes below.

Pushed in 9242534

Change Rule Where
Use {cite:t} where the cited authors are the subject of the sentence. The repo uses author_year citations, so "Wald and Wolfowitz {cite}…" showed the names twice: "Wald and Wolfowitz [Wald and Wolfowitz, 1948] proved". It now reads "Wald and Wolfowitz [1948] proved". qe-ref-001 15 places: navy_captain (3), wald_friedman_2 (4), exchangeable (3), mix_model (3), wald_friedman, divergence_measures
Turn quoted section names ("the section "…" of …") into {ref} links, adding a label to each target heading. Also drop the hand-typed {doc} titles in the two navy_captain sentences touched. qe-link-001 Labels bk_data_processing, bk_lr_learning (blackwell_kihlstrom), lrp_model_selection (likelihood_ratio_process), dm_kl_mle (divergence_measures), lb_bayes_law (likelihood_bayes). Links in divergence_measures, likelihood_ratio_process, likelihood_var, mix_model and navy_captain (2)
Write transposes as ^\top instead of ', and drop bold \mathbf{x}_t, \mathbf{y}_t (including two plot legends). All 21 primes in the lecture's math were transposes, and plain x_t is used nowhere else in that section. qe-math-002, qe-math-004 likelihood_var
One sentence per paragraph in the exercise hint for part 4. qe-writing-001 exchangeable (exchangeable_ex2)

Rendering note: for three or more authors, {cite:t} shortens to "et al.", so "Arrow, Blackwell, and Girshick" now renders as "Arrow et al. [1949]" (4 places in navy_captain and wald_friedman_2). If you'd rather keep all three names, {cite:ts} does that.

How this was checked: the scanner now reports zero issues for these rules on the edited lines. A full jb build lectures -n with notebook execution turned off reports no warnings from these changes: all five {ref} links resolve and the citations render as described above. The only warnings in the edited lectures are artefacts of skipping execution (figure names that come from cell outputs, and !pip lines that can't be lexed as Python). Code cells were not changed apart from the two legend strings in likelihood_var, so outputs are unaffected.

Left for the author (optional)

  • "IID" versus "i.i.d." (proposed rule qe-writing-009): information_market_equilibrium goes from 2 to 7 uses of "i.i.d.". likelihood_ratio_process_2 and wald_friedman_2 mix both forms within the lecture.
  • Expectation notation in blackwell_kihlstrom: it uses \mathbb{E} at roughly L329–837 but plain E at roughly L550–598 (proposed rule qe-math-010).
  • Unexplained ones vector in pricing_information: the \mathbf{1} at roughly L292 has no "vector of ones" sentence (qe-math-004, qe-math-008). L103 already uses \mathbb{1}[i=j] as an indicator, so switching to \mathbb{1} would need that sentence.
  • Multi-sentence footnotes: exchangeable ([^condind]) and navy_captain ([^t0]) each have one. Splitting them is a judgement call.
  • ASCII Greek names in code: pricing_information (theta, phi) and market_diffusion (alpha, mu) use them, following each lecture's existing ASCII style. Switching to Unicode names (qe-code-002) would be a separate whole-lecture change.

Checked and fine: line widths and figure sizes follow each lecture's own convention; new main-text figures are captioned and named where their lecture does that; and set_title appears only in solutions.


🤖 Generated with Claude Code

@mmcky

mmcky commented Oct 31, 2026

Copy link
Copy Markdown
Contributor Author

thanks @thomassargent30!

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.

4 participants