Skip to content

Commit c8f569d

Browse files
committed
updates
1 parent af58380 commit c8f569d

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed
12.8 KB
Loading

lectures/kalman.md

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ kernelspec:
1818
</div>
1919
```
2020

21-
# 卡尔曼滤波器的初步介绍
21+
# 初见卡尔曼滤波器
2222

2323
```{index} single: 卡尔曼滤波
2424
```
@@ -40,7 +40,7 @@ tags: [hide-output]
4040

4141
本讲座为卡尔曼滤波器提供了一个简单直观的介绍,适合以下读者:
4242

43-
* 听说过卡尔曼滤波器但不知道它如何工作的人,或者
43+
* 听说过卡尔曼滤波器但不知道它如何运作的人,或者
4444
* 知道卡尔曼滤波的方程但不知道这些方程从何而来的人
4545

4646
关于卡尔曼滤波的更多(进阶)阅读材料,请参见:
@@ -83,9 +83,11 @@ from scipy.linalg import eigvals
8383

8484
总结我们知识的一种方式是点预测 $\hat x$
8585

86-
* 但如果总统想知道导弹目前在日本海上空的概率呢?
87-
* 那么用二元概率密度 $p$ 来总结我们的初始认知会更好
88-
* $\int_E p(x)dx$ 表示我们认为导弹在区域 E 内的概率。
86+
然而,点预测可能不够用。例如,我们可能需要回答"导弹目前在日本海上空的概率是多少"这样的问题。
87+
88+
为了回答这类问题,我们需要用二元概率密度函数 $p$ 来描述我们对导弹位置的认知。
89+
90+
对于任意区域 $E$,积分 $\int_E p(x)dx$ 给出了我们认为导弹在该区域内的概率。
8991

9092
密度 $p$ 被称为随机变量 $x$ 的*先验*
9193

@@ -186,7 +188,7 @@ def bivariate_normal(x, y, σ_x=1.0, σ_y=1.0, μ_x=0.0, μ_y=0.0, σ_xy=0.0):
186188
187189
def gen_gaussian_plot_vals(μ, C):
188190
"用于绘制二元高斯 N(μ, C) 的 Z 值"
189-
m_x, m_y = float(μ[0]), float(μ[1])
191+
m_x, m_y = float(μ[0].item()), float(μ[1].item())
190192
s_x, s_y = np.sqrt(C[0, 0]), np.sqrt(C[1, 1])
191193
s_xy = C[0, 1]
192194
return bivariate_normal(X, Y, s_x, s_y, m_x, m_y, s_xy)
@@ -232,7 +234,7 @@ plt.show()
232234
```{math}
233235
:label: kl_measurement_model
234236
235-
y = G x + v, \quad \text{where} \quad v \sim N(0, R)
237+
y = G x + v, \quad \text{} \quad v \sim N(0, R)
236238
```
237239

238240
这里 $G$ 和 $R$ 是 $2 \times 2$ 矩阵,其中 $R$ 是正定矩阵。两者都被假定为已知,且噪声项 $v$ 被假定与 $x$ 独立。
@@ -292,7 +294,7 @@ new_Z = gen_gaussian_plot_vals(x_hat_F, Σ_F)
292294
cs2 = ax.contour(X, Y, new_Z, 6, colors="black")
293295
ax.clabel(cs2, inline=1, fontsize=10)
294296
ax.contourf(X, Y, new_Z, 6, alpha=0.6, cmap=cm.jet)
295-
ax.text(float(y[0]), float(y[1]), "$y$", fontsize=20, color="black")
297+
ax.text(float(y[0].item()), float(y[1].item()), "$y$", fontsize=20, color="black")
296298
297299
plt.show()
298300
```
@@ -321,7 +323,7 @@ plt.show()
321323
```{math}
322324
:label: kl_xdynam
323325
324-
x_{t+1} = A x_t + w_{t+1}, \quad \text{where} \quad w_t \sim N(0, Q)
326+
x_{t+1} = A x_t + w_{t+1}, \quad \text{} \quad w_t \sim N(0, Q)
325327
```
326328

327329
我们的目标是将这个运动定律和我们当前的分布 $p(x \,|\, y) = N(\hat x^F, \Sigma^F)$ 结合起来,得出一个新的一个时间单位后位置的*预测*分布。
@@ -405,7 +407,7 @@ new_Z = gen_gaussian_plot_vals(new_x_hat, new_Σ)
405407
cs3 = ax.contour(X, Y, new_Z, 6, colors="black")
406408
ax.clabel(cs3, inline=1, fontsize=10)
407409
ax.contourf(X, Y, new_Z, 6, alpha=0.6, cmap=cm.jet)
408-
ax.text(float(y[0]), float(y[1]), "$y$", fontsize=20, color="black")
410+
ax.text(float(y[0].item()), float(y[1].item()), "$y$", fontsize=20, color="black")
409411
410412
plt.show()
411413
```
@@ -482,7 +484,7 @@ plt.show()
482484

483485
方程 {eq}`kalman_sdy` 被称为离散时间黎卡提差分方程。
484486

485-
方程 {eq}`kalman_dare` 被称为[离散时间代数黎卡提方程](https://en.wikipedia.org/wiki/Algebraic_Riccati_equation)
487+
方程 {eq}`kalman_dare` 被称为[离散时间代数黎卡提方程](https://zhuanlan.zhihu.com/p/692283143)
486488

487489
关于固定点存在的条件以及序列 $\{\Sigma_t\}$ 收敛到该固定点的条件在 {cite}`AHMS1996` 和 {cite}`AndersonMoore2005` 第4章中有详细讨论。
488490

@@ -646,7 +648,7 @@ y = y.flatten()
646648
647649
for t in range(T):
648650
# 记录当前预测的均值和方差并绘制其密度
649-
m, v = [float(temp) for temp in (kalman.x_hat, kalman.Sigma)]
651+
m, v = [float(temp.item()) for temp in (kalman.x_hat, kalman.Sigma)]
650652
651653
f = lambda x: norm.pdf(x, loc=m, scale=np.sqrt(v))
652654
integral, error = quad(f, θ - ϵ, θ + ϵ)
@@ -795,5 +797,5 @@ plt.show()
795797
这说明 $x_t$ 运动规律中的随机性越大,会导致预测中的(永久性)不确定性越大。
796798
```
797799

798-
[^f1]: 例如,参见 {cite}`Bishop2006` 第93页。要从他的表达式得到上面使用的表达式,你还需要应用 [Woodbury矩阵恒等式](https://en.wikipedia.org/wiki/Woodbury_matrix_identity)
800+
[^f1]: 例如,参见 {cite}`Bishop2006` 第93页。要从他的表达式得到上面使用的表达式,你还需要应用 [Woodbury矩阵恒等式](https://zhuanlan.zhihu.com/p/388027547)
799801

0 commit comments

Comments
 (0)