Repository navigation
Description
Hi @jstac
A few small exposition and notation comments might be useful for the first Kalman filter lecture.
Distinguishing the random state from its realizations
The lecture currently uses lowercase
It might be clearer to distinguish the random state from its realizations at the start.
For example, we could write something like:
Let
$X \in \mathbb R^2$ denote the random vector representing the current location of the missile, and let$x$ denote a possible value of$X$ .
The density$p(x)$ is the density of$X$ evaluated at$x$ .
and the noisy observation can be written as
with observed realization
Noisy signal interpretation
Currently in the filtering step, the lecture says, when introducing the noisy signal:
The bad news is that our sensors are imprecise.
In particular, we should interpret the output of our sensor not as$y=x$ , but rather as$y=Gx+v$ , where$v\sim N(0,R)$ ....
I wonder if it would be helpful to add one sentence in between explain explicitly that
Something like:
The bad news is that our sensors are imprecise, $y$ is not the true location itself.
It is a noisy signal generated from the hidden location, distorted by measurement error.
In particular, we should interpret the output of our sensor not as$y=x$ , but rather as$y=Gx+v$ , where$v\sim N(0,R)$ ....
This might make the role of
Marking the observed signal in the figures
The second figure currently labels the observed value with a text
This could help reinforce the distinction between the hidden state and the noisy observation.
Exercise wording
There are a couple of small indexing / wording points in the exercises:
- Exercise 2 says to plot
$z_t$ against$T$ , but it seems more natural to say plot$z_t$ against$t$ , for$t = 0, 1, \ldots, T$ . - Exercise 3 asks for
$t = 1, \ldots, 50$ , while the solution usesrange(1, T)withT = 50, so the displayed range is$1,\ldots,49$ .
Style guide
While making these changes, it might also be worth doing some cleanup to match the Style Guide:
- some paragraphs contain more than one sentences, we can break them up following the style guide rule
qe-writing-001(one sentence per paragraph) - replace transpose primes such as
$G'$ and$A'$ with$G^\top$ and$A^\top$ , following the style guide ruleqe-math-002; - replace the displayed expression
Q = 0.3 * \Sigmawith standard mathematical multiplication notation, e.g.$Q = 0.3 \Sigma$ , following the style guide ruleqe-math-A5.
Possible np.matrix modernization
The early plotting code uses np.matrix and relies on * for matrix multiplication.
This is not a QuantEcon style-guide issue, but according to NumPy's official guide for np.matrix
It is no longer recommended to use this class, even for linear algebra. Instead use regular arrays. The class may be removed in the future.
If we want to modernize this part of the lecture, we could replace np.matrix with np.array and use @ for matrix multiplication.
Do these changes sound reasonable? I would be happy to open a PR if so.
Best,
Longye
Activity
jstac commentedon Jun 6, 2026
Hi @longye-tian , great review.
All these changes will be valuable. It would be great if you could open a PR.
CC @mmcky