Skip to content

[ge_arrow] Example 4 transition matrix row 2 sums to 1.8 (not a stochastic matrix) #1030

Description

@mmcky

Problem

Example 4 of lectures/ge_arrow.md defines a 3-state transition matrix whose second row does not sum to 1, so it is not a valid stochastic matrix (ge_arrow.md#L1270 on main):

λ = .9
μ = .9
δ = .05

# prosperous, moderate, and recession states
P = np.array([[1-λ, λ, 0], [μ/2, μ, μ/2], [(1-δ)/2, (1-δ)/2, δ]])

Row sums: row 1 = 0.1 + 0.9 + 0 = 1 ✅, row 2 = 0.45 + 0.9 + 0.45 = 1.8 ❌, row 3 = 0.475 + 0.475 + 0.05 = 1 ✅.

All of Example 4's published output (Q, R, A, α, ψ, J) is computed from this matrix, so the numbers shown on the live lecture page for that example don't correspond to a well-defined Markov economy.

Likely intended matrix

The natural reading, given row 3's pattern of splitting the off-diagonal mass, is that row 2 was meant to be [(1-μ)/2, μ, (1-μ)/2] = [0.05, 0.9, 0.05] — a sticky "moderate" state — which sums to 1. Someone closer to the original intent (perhaps Tom) should confirm before we change the published numbers.

Suggested fix

  1. Correct row 2 (pending confirmation of intent) and refresh Example 4's discussion if any printed values are referenced in the text.
  2. Add a cheap validation when the model is constructed, e.g. assert np.allclose(P.sum(axis=1), 1), so an invalid transition matrix fails loudly instead of silently producing plausible-looking output. The NumPy restructure discussed in [ge_arrow] Update to JAX and compare runtime #717 (a validating factory alongside the NamedTuple) is a natural home for this.

Context

Found during the style-guide review that wrapped up #717. The bug pre-dates that PR — it is present on main and was carried over unchanged by the JAX rewrite.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions