olg_adaptive_money#
Series: lecture-python.myst
File:
lectures/olg_adaptive_money.mdAudit date: 2026-08-26
Corpus snapshot:
e25fdf2345Categories 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 |
|
Math |
7.5/10 |
|
Code |
6.5/10 |
|
JAX |
out of scope |
JAX rules target |
Figures |
6/10 |
|
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 alls[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 counttau0in 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 bindsgto the Robbins-Monro gain in a file whereg_map(541) is the inflation map andgat 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) issimulate(345-381) copied line for line withgainsubstituted for1/(τ+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 codegis 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 asU_prime/U_double(338, 341) andU_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γ_bat 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: dropdownsolution 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 ofre_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)andSargent 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_budgetandmarket_clearingat 137 and 329,return_from_savingat 189 and 387,olg_focat 268 and 315,olg_equilibriumat 201, 430 and 1223,robbins_monroat 328, 471, 488 and 1233,saving_deterministicat 634,inflation_mapat 602 and 1399,phillips_trueat 985,phillips_perceivedat 944,phillips_ruleat 943 and 965 (the exception isphillips_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
mystnbcaption 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).
Recommended actions#
Do not “fix” the three capitalisation findings at 91, 874 and 1104 - all three are the italicised book title The Conquest of American Inflation, whose capitals are required. The two qe-writing-004 hits are the words
Inflationinside*The Conquest of American Inflation*, and the qe-writing-006 hit is the H3From escape dynamics to the *Conquest of American Inflation*. See scanner_doubts for the measured two-line checker fix.Rename to break the five symbol collisions, starting with the two that cross the code boundary: use \(P(i,j)\) (or
Π) for the transition matrix so \(\pi\) means inflation throughout and matches the code’sP/π, and pick one of the three \(g\)’s - the inflation map, the Brock deficit, the target inflation - to keep.Define \(m_t\) where Part 2 first uses it (515) or keep Part 1’s \(H_t\), and reconcile \(E_t\) (288) with \(E_i\) (314). While there, either give the Pareto-dominance claim at 613 a citation or say it is proved in
{cite:t}`Sargent1993`.Compute the Brock counterexample the section is about: iterate the non-stationary paths where gross inflation falls to \(\beta\) and real balances explode (839-846), so the section that limits the lecture’s main claim has something to look at other than the stationary table at 831-836.
Move the Laffer-curve figure (1341-1358) out of the exercise-3 dropdown and into the main line at 611, where the wrong-side-of-the-curve claim is made; the exercise can then ask for the comparative static rather than the picture.
Settle bold against italic. Bold the definitions and un-bold the emphasis - 67, 73, 76, 86, 90, 623, 841, 912, 1084 are emphasis and belong in italic - and pick one marking for self-referential (italic 151, bold 942) and for the low-inflation equilibrium (italic 552, bold 691 and 781).
Fix
''adaptive''at 45 (two apostrophes for each quotation mark), split the 51-word sentence it sits in, and cut the duplication at 1104-1127, which restates 877-897 and 1082-1102 almost point for point.qe-fig-001: of the seven
figsizesettings, only 410 is a genuine multi-panel grid (1x2); the six single-axes overrides at 564, 702, 1018, 1072, 1285 and 1348 can go. The qe-fig-003 hit at 419 is genuine but needs a replacement, not a deletion - it labels the two panels of one figure, so move “Economy 1 / Economy 2” into the caption at 401 or intoax.annotate.qe-fig-004 flags 699, 1000 and 1050 for length (7, 8 and 8 words against the rule’s 5-6): “Least squares and rational expectations inflation paths” shortens to “least squares against rational expectations”, “Least squares learning converges to the inflation bias” to “learning converges to the inflation bias”, and “Constant-gain learning and recurrent escapes to zero inflation” to “recurrent escapes to zero inflation”. Add caption/name metadata to the two solution figure cells (1284, 1341) and
lw=2at 577 and 1352.Code: rename
tau0(345) toτ0so the visit counter has one spelling, rename the gaingat 372 (γmatches the algebra), drop the placeholder-free f-string at 977, bring the nine over-90-character lines under the limit, and factorsimulate_constant_gain(1251-1271) intosimulatewith a gain argument instead of keeping a line-for-line copy.The bare \(E_t\) / \(E_i\) at 288-291 and 314-315 sit beside \(\mathbb{E}\) at 933; qe-math-010 (proposed) reports only the
\operatorname{Prob}at 164 because its operator branch has no bare-Roman case, so fix all three sites together rather than only the one the report names.