ifp_discrete#

  • Series: lecture-dp

  • File: lectures/ifp_discrete.md

  • Audit date: 2026-08-26

  • Corpus snapshot: c30490a2f4

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

  • Overall score: 8.5 / 10

  • Priority: LOW

Score breakdown#

Category

Score

One-line note

Writing

6/10

qe-writing-006 ×2; qe-writing-003 ×2.

Math

7/10

qe-math-001 ×2; qe-math-005 ×1; qe-math-009 ×3.

Code

8/10

qe-code-004 ×10; qe-code-001 ×1.

JAX

out of scope

JAX rules target lecture-jax.

Figures

8.5/10

qe-fig-005 ×1; qe-fig-008 ×1.

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-004] — Use quantecon Timer context manager. Count: 10. Lines: 312, 314, 322, 325, 332, 335, 499, 502, 509, 512. Example: bare time() reading.

  • [qe-writing-006] — Capitalize lecture titles properly. Count: 2. Lines: 87, 353. Example: H2 Title Case: ‘Set Up’ (Up).

Medium severity#

  • [qe-math-001] — Prefer UTF-8 unicode for simple parameter mentions, be consistent. Count: 2. Lines: 132, 145. Example: unicode β inside a math environment.

  • [qe-math-009] (reviewer) — Choose simplicity in mathematical notation. Count: 3. Lines: 106, 110, 113. Example: \mathsf used decoratively where plain letters would do: \(\mathsf Y\) for the income support at 106, \(\mathsf S := \mathbb{R}_+ \times \mathsf Y\) at 110, and \(V \colon \mathsf S \to \mathbb{R}\) at 113. Both symbols appear only in these three lines and neither reaches the code, so nothing is gained by the sans-serif face - \(Y\) and \(S\) carry the same meaning and match how the lecture writes every other set and space.

  • [qe-writing-003] (reviewer) — Maintain logical flow. Count: 2. Lines: 130, 412. Example: line 113 defines the value function as \(V\) and equation eqvfs at 118 states it in \(V\); then the Bellman equation at 130 switches to lowercase \(v\) and everything downstream - the display at 145, the operator \(T\) at 232, B, T, get_greedy and every code cell - stays lowercase. The switch is never mentioned, \(V\) is never used again, and eqvfs is never cited, so the reader has to guess that \(v\) and \(V\) are the same object. Separately, exercise step 2 at line 412 says to ‘use staged vmap as shown in earlier examples’ - there are no earlier vmap examples in this lecture; the staged-vmap idiom first appears in this file at 447-449, inside the solution to that very exercise.

Low severity#

  • [qe-code-001] (reviewer) — Follow PEP8 unless closer to mathematical notation. Count: 1. Lines: 438. Example: line 438 writes a, y, ap  = a_grid[i], y_grid[j], a_grid[ip] with two spaces before the = (pycodestyle E221). The aligned assignment blocks at 210-212 and 447-449 are a separate matter and should stay: the reshape comments and the in_axes tuples are column-aligned so the index mapping reads as a table, which is the ‘closer to mathematical notation’ latitude the rule allows.

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

  • [qe-fig-008] — Use lw=2 for line charts. Count: 1. Lines: 366. Example: plot() without lw=.

  • [qe-math-005] — Use curly brackets for sequences. Count: 1. Lines: 106. Example: parenthesised sequence.

Strengths#

  • The {note} at 49-59 answers the question the reader is actually forming - why learn the slow method first - and answers it with a general principle (‘less robust precisely because they exploit more structure’), so the ordering of the whole series is justified rather than just asserted.

  • Every reshape inside B (210-218) carries a trailing comment mapping the incoming index shape to the outgoing one (a[i] -> a[i, j, ip], Q[j, jp] -> Q[i, j, ip, jp]), which makes the 3D and 4D broadcasting auditable line by line instead of something the reader has to re-derive.

  • The Python-loop and jax.lax.while_loop implementations are both kept (259-273 and 279-298), and their outputs are checked against each other on both values and policies (342-343) before the speed ratio is printed at 349 - the correctness check precedes the speed claim, and the same discipline is repeated for the vmap version at 519-526.

  • The anticipated objection is raised and answered where it arises: ‘Some readers might be concerned that we are creating high dimensional arrays’ at 224-230, immediately after the 4D reshape that provokes it.

  • The exercise at 388-417 is a 6-step specification precise enough to attempt without the solution, and the solution closes at 529-533 by admitting the vmap version is no faster and saying why it is still worth knowing - the honest answer rather than a manufactured win.

  • Only the three real definitions are bold - income fluctuation problem and household problem at 24, value function at 113 - with no emphasis-bold anywhere in the file.