olg_adaptive_money#

  • Series: lecture-python.myst

  • File: lectures/olg_adaptive_money.md

  • Audit date: 2026-08-26

  • Corpus snapshot: e25fdf2345

  • Categories audited: writing, math, code, figures, references, links, admonitions (JAX out of scope)

  • Overall score: 7.6 / 10

  • Priority: HIGH

Score breakdown#

Category

Score

One-line note

Writing

3.5/10

qe-writing-005 ×9; qe-writing-002 ×5; qe-writing-004 ×2, +3 more.

Math

7.5/10

qe-math-010 (proposed) ×1; qe-math-009 ×5.

Code

6.5/10

qe-code-001 ×5; qe-code-002 ×4.

JAX

out of scope

JAX rules target lecture-jax.

Figures

6/10

qe-fig-005 ×2; qe-fig-004 ×3; qe-fig-003 ×1, +1 more.

References

10/10

no mechanical violations detected.

Links

10/10

no mechanical violations detected.

Admonitions

10/10

no mechanical violations detected.

Issues#

Critical#

None found.

High severity#

  • [qe-code-001] (reviewer) — Follow PEP8 unless closer to mathematical notation. Count: 5. Lines: 345, 357, 372, 977, 1074. Example: flake8 (90-character limit, --extend-select=E226,E228) reports nine over-long lines - 357, 444, 547, 976, 977, 1054, 1074, 1361, 1406, the worst at 100 characters - and 37 lines over PEP8’s own 79; the E226 hits are all s[j]*N-style tight multiplication inside a lower-priority expression, which PEP8 endorses and which is closer to the algebra, so they are not findings. The remaining items a linter cannot see: 345 names the initial visit count tau0 in Roman while 356 writes the same object τ eleven characters later, so one variable has two spellings in one function (the file otherwise uses Unicode Greek consistently - τ, π, β, α, γ_b, θ_pc, σ_η, η); 372 binds g to the Robbins-Monro gain in a file where g_map (541) is the inflation map and g at 1060/1067 is target inflation, matching the same collision in the algebra; 977 is an f-string with no placeholders (print(f"optimal (Ramsey) outcome: ... g = 0"), flake8 F541); and docstring quoting is split between triple quotes (346-351, 656-659, 1054) and bare single-line double quotes (211, 951, 1004). Also worth a look: simulate_constant_gain (1251-1271) is simulate (345-381) copied line for line with gain substituted for 1/(τ+tau0), so a change to the projection facility now has to be made twice.

  • [qe-fig-001] — Do not set figure size unless necessary. Count: 7. Lines: 410, 564, 702, 1018, 1072, 1285, 1348. Example: figsize=.

  • [qe-math-009] (reviewer) — Choose simplicity in mathematical notation. Count: 5. Lines: 164, 523, 629, 813, 918. Example: the lecture carries three models under one alphabet and five letters do double or triple duty; the notation is otherwise admirably plain (no calligraphic or bold decoration anywhere, one \(\mathbb{E}\) at 933), so these are all changes of letter, not of style. (1) \(\pi\) is the transition probability \(\pi(i,j)\) in Part 1 (164, 178, 186, 198) and the gross inflation rate \(\pi_t\) from 509 onward - and the code writes the transition matrix as P (222, 235, 249) and reserves π for inflation (541-547), so the algebra and the implementation disagree about which object \(\pi\) names. (2) \(g\) is the inflation map \(g(\pi_t)\) (523), the Brock government expenditure \(g > 0\) (814, 816, 820) and the government’s target inflation \(g_{t-1}\), \(g_t\) (906, 909, 939, 942, 970, 1029, 1077); in code g is additionally the Robbins-Monro gain (372) and the loop variable over Brock deficits (833-835). (3) \(U\) is realized lifetime utility \(U(s)\), \(U'\), \(U''\) (276-284, 306-307, 314) and unemployment \(U_t\), \(U^*\) (918, 930, 963, 983); the code carries both as U_prime/U_double (338, 341) and U_star/U (947, 1063). (4) \(\beta\) is the OLS slope \(\beta_t\) (629, 643, 662), the Brock discount factor (813) and the limiting gross inflation of the deflationary equilibria (840, 842) - three meanings in 200 lines. (5) \(\gamma_\tau\) is the gain sequence (298, 306, 307, 1233) and \(\gamma\) the money-in-utility weight (813, 816); the code disambiguates with γ_b at 826 but the prose does not.

  • [qe-math-010 (proposed)] — Blackboard \mathbb{P}, \mathbb{E}, \mathbb{V} with braces. Count: 1. Lines: 164. Example: non-blackboard \operatorname{Prob}.

  • [qe-writing-002] (reviewer) — Keep writing clear, concise, and valuable. Count: 5. Lines: 45, 84, 875, 1092, 1116. Example: the file is otherwise disciplined about one sentence per paragraph, so the problems are a handful of overlong sentences and one duplicated section. 44-45 is 51 words with a 14-word em-dash aside inside it (“This lecture takes one of them - Samuelson’s overlapping generations model of fiat money, used by Bryant, Wallace and others to study inflationary finance - and replaces Samuelson’s agents who forecast according to the equilibrium law of motion for the price level with ‘‘adaptive’’ ones who do not”) and also carries the typo ''adaptive'', two apostrophes for each quotation mark. 82-84 is 41 words with two stacked appositives (“tempered by a counterexample, due to Benjamin Bental, warning against …”); 872-875 is 46 words with three citations and a {doc} link; 1089-1092 is 48 words. The larger cost is duplication: 1104-1127 restates 877-897 and 1082-1102 (1116-1118 says again what 872-873 already said about Sims and Chung nesting the two stories), and the exercise-4 solution at 1450-1465 restates 1097-1102 and 1155-1163 a third time.

  • [qe-writing-005] (reviewer) — Use bold for definitions, italic for emphasis. Count: 9. Lines: 151, 552, 691, 781, 841, 912, 1084, 319, 67. Example: bold is doing the work of italic through most of the file, and twice the same term is marked both ways. self-referential is italic at 151 where it is introduced and defined (“it is what makes this a self-referential system”) and bold at 942 (“The system is self-referential”); the low-inflation equilibrium is low in italic at 552 and low in bold at 691 and 781, in three sentences making the same emphasis. Pure emphasis is set in bold at 67 (two stationary equilibria), 73 (unstable), 76 (reversed), 86 (third application), 90 (escape), 623 (run a regression), 841 (deflation), 912 (the surprise), 1084 (escapes) and 455/469 (non-parametrically, parametric), while the same job is done in italic at 49, 65, 84, 89, 267, 271, 452, 473, 480, 646, 799, 882, 893, 1095, 1117, 1122 - so a reader has no way to tell the two markings apart. Bold is also used as structural labelling rather than definition at 49, 65 (Part 1, Part 2) and 319, 328 (Two classes of agent., A projection facility.). The genuine definitions that are bolded - Robbins-Monro (56, 295), Laffer curve (611), inflation bias (980), consistent (958), constant-gain (1042), escape-route (1120) - are the minority use.

  • [qe-writing-006] — Capitalize lecture titles properly. Count: 1. Lines: 1104. Example: H3 Title Case: ‘From escape dynamics to the Conquest of American Inflation’ (Conquest, Inflation).

Medium severity#

  • [qe-code-002] — Use Unicode symbols for Greek letters in code. Count: 4. Lines: 663, 669, 674, 677. Example: spelled-out beta.

  • [qe-fig-003] — No matplotlib embedded titles. Count: 1. Lines: 419. Example: .set_title.

  • [qe-fig-004] — Caption formatting conventions. Count: 3. Lines: 695, 996, 1046. Example: caption of 7 words.

  • [qe-fig-005] — Descriptive figure names for cross-referencing. Count: 2. Lines: 1284, 1341. Example: code-cell figure without mystnb figure metadata.

  • [qe-writing-003] (reviewer) — Maintain logical flow. Count: 4. Lines: 859, 515, 613, 314. Example: (1) The overview announces “a third application” (86) and the body is scaffolded as ## Part 1: a stochastic deficit (159) and ## Part 2: a constant deficit and two steady states (497) - but the third application arrives as ## A government learning the Phillips curve (859), with no Part 3, and the concluding remarks then go back to “Part 1” (1131) and “Part 2” (1136) before switching to “The Phillips curve application” (1155). The scaffolding is dropped exactly where the reader changes models. (2) 515 writes \(h_t = m_t / p_t\), introducing \(m_t\) for the first time; Part 1 called the same object \(H_t\) throughout (120, 123, 132, 391) and real balances \(H_t/p_t\) (132). Nothing says they are the same thing, and 813 then uses \(m_t/p_t\) again inside the Brock model. (3) 613 asserts “the low-inflation equilibrium Pareto-dominates every other equilibrium of this model, stationary or not” - the welfare claim on which the whole “learning selects the good equilibrium” story rests, and which 806-807 and 851-852 both lean on - with no argument, no citation and no forward pointer. (4) 288 introduces the conditioning operator as \(E_t\), then 314-315 silently switches to \(E_i\) for the same conditional expectation two paragraphs later, with \(i\) the deficit state and \(t\) the date.

  • [qe-writing-004] — Avoid unnecessary capitalization in narrative text. Count: 2. Lines: 91, 874. Example: mid-sentence ‘Inflation’.

  • [qe-writing-007] (reviewer) — Use visual elements to enhance understanding. Count: 4. Lines: 611, 839, 319, 780. Example: four places where the picture the argument needs is either missing or hidden. (1) 611 tells the reader the high equilibrium sits “on the wrong side of an inflation-tax Laffer curve” and points to {ref}`olg_ex3`; the Laffer curve is then drawn at 1341-1358, inside a :class: dropdown solution at the very end of the file, so the one picture that explains Part 2’s central comparative static is invisible to a reader following the main line. (2) The Brock counterexample (804-857) is the section that limits the lecture’s main claim, and its content is the continuum of non-stationary equilibria in which “gross inflation rate converges to \(\beta\) … and real balances exploding” (839-842) - none of which is computed or plotted; the only cell in the section (825-836) tabulates the stationary equilibrium’s classical comparative static, i.e. the part that is not the counterexample. Four lines of re_path-style iteration would show the deflationary paths. (3) The odd/even two-class device (319-326) and the one-period-lagged learning it forces (363-377: prev, R = (N*s_t - G[i]) / (N*s_p), τ[j_p, i_p] += 1) are the trickiest bookkeeping in the lecture and are carried entirely by prose plus code; a three-row timing diagram would settle it. (4) Marimon and Sunder’s experiment (759-802) is the lecture’s empirical centrepiece - “the experimental inflation paths were much better approximated by the least squares dynamics” (780-782) - and has no figure, table or admonition at all, in a lecture that already plots exactly those two families of paths at 695-722.

Low severity#

None found.

Strengths#

  • The code checks itself against the published source rather than asserting agreement: 252-254 prints the computed saving rates and returns next to (Sargent reports 4.211, 4.364) and Sargent reports [[0.81, 1.0362], [0.7817, 1.00]], and 257 says “Both match the values reported in the text”.

  • The stability reversal is turned into a measurement instead of a claim. 727-729 says the boundary is exact, and 731-737 bisects for it - for _ in range(40): ... if ls_dynamics(mid)[2] - then prints the basin edge beside \(\pi_{high}\), so the reader sees that the RE-stable steady state is the edge of the learning dynamics’ basin.

  • Eleven of the twelve labelled equations are cited where they are used - govt_budget and market_clearing at 137 and 329, return_from_saving at 189 and 387, olg_foc at 268 and 315, olg_equilibrium at 201, 430 and 1223, robbins_monro at 328, 471, 488 and 1233, saving_deterministic at 634, inflation_map at 602 and 1399, phillips_true at 985, phillips_perceived at 944, phillips_rule at 943 and 965 (the exception is phillips_inflation, 904, which is labelled but never referenced).

  • The four {note} admonitions each answer the objection a careful reader would raise at that exact point: why the system is self-referential rather than a forecasting problem (149-157), why the simulation never computes a price level and would overflow if it did (384-393), why learning algorithms and equilibrium-computation algorithms are hard to tell apart (479-495), and that Imrohoroglu’s estimates on German hyperinflation data point the other way (795-802).

  • Convergence is shown at three horizons rather than one: 432-441 tabulates the learned saving rules at \(T = 5{,}000\), \(50{,}000\) and \(200{,}000\) against the independently computed equilibrium printed at 444, and the figure at 410-423 puts time on a log axis so the whole trajectory is visible in one panel.

  • The learning simulation is deliberately started away from the answer and says so in the source: start = [[8.0, 2.0], [2.0, 8.0]]  # deliberately far from equilibrium, and asymmetric (404-405), and the asymmetry is what makes 426-427 (“both classes of agent converge to the same rule even though neither learns from the other”) a real result.

  • Exercise 3’s solution closes its own loop with two independent computations: 1394-1401 argues the roots collide where \(\pi = \sqrt{A_2} = \sqrt{w_1/w_2}\), and 1403-1406 then prints the collision deficit and the Laffer-curve peak side by side and they agree to six decimals.

  • The lecture states its own limits. §“A warning” (804-857) is a whole section devoted to a counterexample to the claim just made, 854-857 draws the careful conclusion (“least squares dynamics reliably select the classical equilibrium … Whether that equilibrium is the good one is a separate question”), and 1150-1153 quotes Sargent conceding his own discomfort.

  • All five figure cells in the main text carry mystnb caption and name metadata (397-403, 555-561, 695-701, 996-1002, 1046-1052), which is why qe-fig-005 reports only the two cells inside exercise solutions (1284, 1341).

  • Every one of the four exercises tests a claim the prose actually made rather than an unrelated extension: rare states are learned about slowly (1175-1183, promised at 462-465), constant gain does not converge (1233-1241), the Laffer-curve geometry (1324-1332, promised at 611), and the gain-versus-escape-frequency relation (1419-1429, promised at 1097-1102).