Repository navigation
Conversation
Review-driven pass over the Kalman filter lecture covering correctness
fixes, code modernization, a notation overhaul, and math layout.
- Fix an unterminated math span ($Y_{t+1}.), a measurement-equation
subscript (v -> v_t), and a stray figure label ($y$ -> $Y_t$).
- Replace the hand-rolled bivariate_normal density with
scipy.stats.multivariate_normal; switch the jet colormap to viridis;
drop redundant float(...item()) conversions.
- Reparameterize the Gaussian throughout as N(mu, Sigma) (xhat -> mu),
in math, prose, and code variables, with bridging notes tying mu_t to
the literature's xhat and the QuantEcon `x_hat` attribute.
- Set "new" subscripts upright (\mathrm{new}) and reflow two wide
derivations into aligned blocks.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
📖 Netlify Preview Ready!Preview URL: https://pr-908--sunny-cactus-210e3e.netlify.app Commit: 📚 Changed LecturesBuild Info
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
A review-driven pass over A First Look at the Kalman Filter (
lectures/kalman.md). The changes fall into four groups: correctness/consistency fixes, code modernization, a notation overhaul for flow, and math-layout tweaks. Every code cell was executed end-to-end after each change (viajupytext --to py); the lecture runs clean and figure output is unchanged except for the intended colormap swap.1. Correctness & consistency fixes
$Y_{t+1}.in the recursive-procedure section was missing its closing$, which would render the rest of the sentence as math. Now$Y_{t+1}$.Y_t = G X_t + v_t, \text{ where } v \sim N(0,R)→v_t \sim N(0,R), so the subscript is consistent within the equation."$y$"while the other two figures use"$Y_t$"; unified to"$Y_t$".2. Code modernization
bivariate_normalfunction (~37 lines, a copy of the long-removedmatplotlib.mlab.bivariate_normal) and replaced it withscipy.stats.multivariate_normal, fed the covariance matrix directly. Verified numerically identical to the old implementation (max abs difference ≈ 2.8e-16).cmap=cm.jettocmap="viridis"(perceptually uniform;jetis discouraged) and dropped the now-unusedimport matplotlib.cm as cm.float(...)wrapping around.item()calls in five places (.item()already returns a Python float), including simplifying twom, v = [float(z) for z in (...)]comprehensions.3. Notation overhaul:
\hat x→\muTo improve flow and logical consistency, the Gaussian is now parameterized throughout as$N(\mu, \Sigma)$ — the canonical mean/covariance pairing — matching the lecture's distributional narrative.
\hat x(and derived forms\hat x^F,\hat x_t,\hat x_{new},\hat x_0, …) replaced by\muin math and prose.x_hat → μ,x_hat_F → μ_F,new_x_hat → new_μ,x_hat_0 → μ_0. The QuantEconKalmanattributes (kalman.x_hat,kn.x_hat) are left intact, since they are library API..x_hatand.Sigmaattributes, explaining the attribute name.4. Math layout
_{new}→_{\mathrm{new}}so "new" renders upright rather than as italicalignedblock with one=step per line, and the longest right-hand side (the variance expansion) is split so the subtracted regression term wraps to its own line.Verification
exit 0), only the expected non-interactive-backend warnings.bivariate_normal→multivariate_normalconfirmed equivalent to machine precision.\hat xoutside the two intentional notes, no orphaned renamed identifiers, and library attributes preserved.🤖 Generated with Claude Code