From 417b7290561d9d9fe6356850deff6042203f2f32 Mon Sep 17 00:00:00 2001 From: Chase Coleman Date: Fri, 25 Sep 2026 13:43:32 +0000 Subject: [PATCH 1/3] Fix sign error in by-hand characteristic roots MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The polynomial is z^2 - ρ1 z - ρ2 = 0, so the roots are (ρ1 ± sqrt(ρ1^2 + 4 ρ2)) / 2. The by-hand formula in y_nonstochastic used -ρ1 in every branch. --- lectures/samuelson.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lectures/samuelson.md b/lectures/samuelson.md index 2b303cf9b..d8528499f 100644 --- a/lectures/samuelson.md +++ b/lectures/samuelson.md @@ -684,17 +684,17 @@ def y_nonstochastic(y_0=100, y_1=80, α=0.92, β=0.5, γ=10, n=80): discriminant = ρ1**2 + 4 * ρ2 if discriminant == 0: - roots.append(-ρ1 / 2) + roots.append(ρ1 / 2) print("Single real root: ") print("".join(f"{r:.2f}" for r in roots)) elif discriminant > 0: - roots.append((-ρ1 + sqrt(discriminant).real) / 2) - roots.append((-ρ1 - sqrt(discriminant).real) / 2) + roots.append((ρ1 + sqrt(discriminant).real) / 2) + roots.append((ρ1 - sqrt(discriminant).real) / 2) print("Two real roots: ") print(" ".join(f"{r:.2f}" for r in roots)) else: - roots.append((-ρ1 + sqrt(discriminant)) / 2) - roots.append((-ρ1 - sqrt(discriminant)) / 2) + roots.append((ρ1 + sqrt(discriminant)) / 2) + roots.append((ρ1 - sqrt(discriminant)) / 2) print("Two complex roots: ") print(" ".join(f"{r.real:.2f}{r.imag:+.2f}j" for r in roots)) From 27c159f9c680bae9b9fa2bb3125a6bef8defa241 Mon Sep 17 00:00:00 2001 From: Chase Coleman Date: Fri, 25 Sep 2026 13:53:29 +0000 Subject: [PATCH 2/3] Align class docstring with the lecture's recurrence MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Samuelson class and analyze_roots use ρ1 = α+β, ρ2 = -β from I_t = β(Y_{t-1} - Y_{t-2}). The docstring still had the 1939 consumption-accelerator form α(1+β), -αβ. --- lectures/samuelson.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lectures/samuelson.md b/lectures/samuelson.md index d8528499f..97600bf9b 100644 --- a/lectures/samuelson.md +++ b/lectures/samuelson.md @@ -976,7 +976,7 @@ class Samuelson: .. math:: - Y_t = \alpha (1 + \beta) Y_{t-1} - \alpha \beta Y_{t-2} + Y_t = (\alpha + \beta) Y_{t-1} - \beta Y_{t-2} + (\gamma + G_t) Parameters ---------- From 76e110054f55f12d6854a76c253cc5b832ff9354 Mon Sep 17 00:00:00 2001 From: John Stachurski Date: Sat, 26 Sep 2026 06:57:37 +1000 Subject: [PATCH 3/3] Make Samuelson docstring raw and include the shock term The non-raw docstring turned \a and \b in \alpha and \beta into control characters. Also add the sigma epsilon_t term, since the class supports a stochastic model. Co-Authored-By: Claude Opus 5.5 --- lectures/samuelson.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lectures/samuelson.md b/lectures/samuelson.md index 97600bf9b..c569fcbef 100644 --- a/lectures/samuelson.md +++ b/lectures/samuelson.md @@ -965,7 +965,7 @@ for the Samuelson model ```{code-cell} ipython3 class Samuelson: - """ + r""" This class represents the Samuelson model, otherwise known as the multiplier-accelerator model. The model combines the Keynesian multiplier @@ -976,7 +976,7 @@ class Samuelson: .. math:: - Y_t = (\alpha + \beta) Y_{t-1} - \beta Y_{t-2} + (\gamma + G_t) + Y_t = (\alpha + \beta) Y_{t-1} - \beta Y_{t-2} + (\gamma + G_t) + \sigma \epsilon_t Parameters ----------