You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: lectures/kalman.md
+13-12Lines changed: 13 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -57,15 +57,15 @@ Required knowledge: Familiarity with matrix manipulations, multivariate normal d
57
57
We'll need the following imports:
58
58
59
59
```{code-cell} ipython3
60
-
import matplotlib.pyplot as plt
61
-
from scipy import linalg
62
60
import jax
63
61
import jax.numpy as jnp
62
+
import matplotlib.pyplot as plt
64
63
import matplotlib.cm as cm
65
-
from quantecon import Kalman, LinearStateSpace
64
+
from scipy import linalg
66
65
from scipy.stats import norm
67
66
from scipy.integrate import quad
68
67
from scipy.linalg import eigvals
68
+
from quantecon import Kalman, LinearStateSpace
69
69
```
70
70
71
71
## The Basic Idea
@@ -100,7 +100,7 @@ p = N(\hat{x}, \Sigma)
100
100
```
101
101
102
102
where $\hat{x}$ is the mean of the distribution and $\Sigma$ is a
103
-
$2 \times 2$ covariance matrix. In our simulations, we will suppose that
103
+
$2 \times 2$ covariance matrix. In our simulations, we will suppose that
104
104
105
105
```{math}
106
106
:label: kalman_dhxs
@@ -201,7 +201,7 @@ plt.show()
201
201
202
202
We are now presented with some good news and some bad news.
203
203
204
-
The good news is that the missile has been located by our sensors, which report that the current location is $y = (2.3, -1.9)^top$.
204
+
The good news is that the missile has been located by our sensors, which report that the current location is $y = (2.3, -1.9)\top$.
205
205
206
206
The next figure shows the original prior $p(x)$ and the new reported
207
207
location $y$.
@@ -285,17 +285,18 @@ where
285
285
Here $\Sigma G' (G \Sigma G' + R)^{-1}$ is the matrix of population regression coefficients of the hidden object $x - \hat{x}$ on the surprise $y - G \hat{x}$.
286
286
287
287
We can verify it by computing
288
+
288
289
$$
289
290
\begin{aligned}
290
-
\mathrm{Cov}(x - \hat{x}, y - G \hat{x})\mathrm{Var}(y - G \hat{x})^{-1}
291
+
&\mathrm{Cov}(x - \hat{x}, y - G \hat{x})\mathrm{Var}(y - G \hat{x})^{-1} \\
291
292
&= \mathrm{Cov}(x - \hat{x}, G x + v - G \hat{x})\mathrm{Var}(G x + v - G \hat{x})^{-1}\\
292
293
&= \Sigma G'(G \Sigma G' + R)^{-1}
293
294
\end{aligned}
294
295
$$
295
296
296
297
This new density $p(x \,|\, y) = N(\hat{x}^F, \Sigma^F)$ is shown in the next figure via contour lines and the color map.
297
298
298
-
The original density is left in as contour lines for comparison
299
+
The original density is left in as contour lines for comparison.
299
300
300
301
```{code-cell} ipython3
301
302
---
@@ -409,7 +410,7 @@ Our updated prediction is the density $N(\hat x_{new}, \Sigma_{new})$ where
409
410
* The density $p_{new}(x) = N(\hat x_{new}, \Sigma_{new})$ is called the **predictive distribution**
410
411
411
412
The predictive distribution is the new density shown in the following figure, where
412
-
the update has used parameters.
413
+
the update has used the following parameters:
413
414
414
415
$$
415
416
A
@@ -487,7 +488,7 @@ Swapping notation $p_t(x)$ for $p(x)$ and $p_{t+1}(x)$ for $p_{new}(x)$, the ful
487
488
488
489
1. Start the current period with prior $p_t(x) = N(\hat x_t, \Sigma_t)$.
489
490
1. Observe current measurement $y_t$.
490
-
1. Compute the filtering distribution $p_t(x \,|\, y) = N(\hat x_t^F, \Sigma_t^F)$ from $p_t(x)$ and $y_t$, applying Bayes rule and the conditional distribution {eq}`kl_measurement_model`.
491
+
1. Compute the filtering distribution $p_t(x \,|\, y) = N(\hat x_t^F, \Sigma_t^F)$ from $p_t(x)$ and $y_t$, applying Bayes' rule and the conditional distribution {eq}`kl_measurement_model`.
491
492
1. Compute the predictive distribution $p_{t+1}(x) = N(\hat x_{t+1}, \Sigma_{t+1})$ from the filtering distribution and {eq}`kl_xdynam`.
0 commit comments