Skip to content

Commit 691ee45

Browse files
committed
modify styling
1 parent 0fb1c34 commit 691ee45

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

lectures/kalman.md

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ One way to summarize our knowledge is a point prediction $\hat{x}$
8686
* Then it is better to summarize our initial beliefs with a bivariate probability density $p$
8787
* $\int_E p(x)dx$ indicates the probability that we attach to the missile being in region $E$.
8888

89-
The density $p$ is called our *prior* for the random variable $x$.
89+
The density $p$ is called our **prior** for the random variable $x$.
9090

9191
To keep things tractable in our example, we assume that our prior is Gaussian.
9292

@@ -163,13 +163,10 @@ def gen_gaussian_plot_vals(X, Y, μ, Σ):
163163
PDF values with same shape as X and Y meshgrids.
164164
"""
165165
166-
# Create coordinate arrays: stack X and Y to get shape (2, M, N)
167-
coords = jnp.stack([X, Y], axis=0)
166+
# Create coordinate arrays: stack X and Y to get shape (2, M * N)
167+
coords = jnp.stack([X.ravel(), Y.ravel()])
168168
169-
# Reshape to (2, M*N) for batch processing
170-
coords_flat = coords.reshape(2, -1)
171-
172-
# Vectorized computation
169+
# Define bivariate normal p.d.f
173170
def bivariate_normal(x):
174171
"""Compute PDF for a single point x"""
175172
x_μ = x.reshape(-1, 1) - μ # (2, 1)
@@ -181,7 +178,7 @@ def gen_gaussian_plot_vals(X, Y, μ, Σ):
181178
vectorized_pdf = jax.vmap(bivariate_normal, in_axes=1)
182179
183180
# Compute all PDF values
184-
pdf_values = vectorized_pdf(coords_flat)
181+
pdf_values = vectorized_pdf(coords)
185182
186183
# Reshape back to original meshgrid shape
187184
return pdf_values.reshape(X.shape)
@@ -203,7 +200,7 @@ plt.show()
203200

204201
We are now presented with some good news and some bad news.
205202

206-
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)$.
203+
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$.
207204

208205
The next figure shows the original prior $p(x)$ and the new reported
209206
location $y$.
@@ -284,7 +281,14 @@ where
284281
\Sigma^F := \Sigma - \Sigma G' (G \Sigma G' + R)^{-1} G \Sigma
285282
```
286283

287-
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}$.
284+
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}$.
285+
286+
We can verify it by computing
287+
```{math}
288+
\mathrm{Cov}(x - \hat{x}, y - G \hat{x})\mathrm{Var}(y - G \hat{x})^{-1}
289+
= \mathrm{Cov}(x - \hat{x}, G x + v - G \hat{x})\mathrm{Var}(G x + v - G \hat{x})^{-1}
290+
= \Sigma G'(G \Sigma G' + R)^{-1}
291+
```
288292

289293
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.
290294

@@ -343,7 +347,7 @@ We have obtained probabilities for the current location of the state (missile) g
343347
This is called "filtering" rather than forecasting because we are filtering
344348
out noise rather than looking into the future.
345349

346-
* $p(x \,|\, y) = N(\hat x^F, \Sigma^F)$ is called the *filtering distribution*
350+
* $p(x \,|\, y) = N(\hat x^F, \Sigma^F)$ is called the **filtering distribution**
347351

348352
But now let's suppose that we are given another task: to predict the location of the missile after one unit of time (whatever that may be) has elapsed.
349353

@@ -382,7 +386,7 @@ $$
382386
$$
383387

384388
The matrix $A \Sigma G' (G \Sigma G' + R)^{-1}$ is often written as
385-
$K_{\Sigma}$ and called the *Kalman gain*.
389+
$K_{\Sigma}$ and called the **Kalman gain**.
386390

387391
* The subscript $\Sigma$ has been added to remind us that $K_{\Sigma}$ depends on $\Sigma$, but not $y$ or $\hat x$.
388392

@@ -399,7 +403,7 @@ Our updated prediction is the density $N(\hat x_{new}, \Sigma_{new})$ where
399403
\end{aligned}
400404
```
401405

402-
* The density $p_{new}(x) = N(\hat x_{new}, \Sigma_{new})$ is called the *predictive distribution*
406+
* The density $p_{new}(x) = N(\hat x_{new}, \Sigma_{new})$ is called the **predictive distribution**
403407

404408
The predictive distribution is the new density shown in the following figure, where
405409
the update has used parameters.
@@ -743,7 +747,7 @@ plt.show()
743747
As discussed {ref}`above <kalman_convergence>`, if the shock sequence $\{w_t\}$ is not degenerate, then it is not in general possible to predict $x_t$ without error at time $t-1$ (and this would be the case even if we could observe $x_{t-1}$).
744748

745749
Let's now compare the prediction $\hat x_t$ made by the Kalman filter
746-
against a competitor who **is** allowed to observe $x_{t-1}$.
750+
against a competitor who *is* allowed to observe $x_{t-1}$.
747751

748752
This competitor will use the conditional expectation $\mathbb E[ x_t
749753
\,|\, x_{t-1}]$, which in this case is $A x_{t-1}$.

0 commit comments

Comments
 (0)