关于「卡尔曼增益从哪里来:一步预测、一步修正与指数平滑」,《可穿戴读数与广告日报的卡尔曼滤波》给出的定量结论是什么?

结论:局部水平模型下的卡尔曼滤波只有四行算术:预测方差加 \(q\),增益等于预测方差除以预测方差加 \(r\),估计按增益吸收新息,方差按增益缩小。增益几天之内稳定下来,稳定之后就是平滑系数等于增益的指数平滑;在示意参数下它是 0.2207,一半的权重落在最近三天。七日均线在嘈杂读数上差得不多,在干净读数上却比不平滑还差。可是真实的指标并不总是围着一个水平随机漂移:体重秤读数可能有持续的趋势,订单可能在某一天因为一次真实的事件跳上一个台阶。滤波遇到趋势与台阶会怎样?下一章回答。

数据口径:本书用局部水平与局部趋势的状态空间模型检验这一常识:一个读数等于真实水平加测量误差,当误差方差远大于真实日变化方差时,按原始读数做是或否的决定会对噪音过度反应;示意参数下原始读数每百天翻转 23.6 次,卡尔曼滤波估计只翻转 5.5 次。 书中的噪音方差、漂移、回报率与预算均为示意参数;全部计算由书中程序生成。

English version

对照数据表

下表数字由本章 Python 程序原样打印,可重新运行复现。 程序只用 Python 标准库与结论吻合的打印值: 0.2207

daypredicted Pgain Kfiltered sd
1100.0000.96151.961
24.0960.50591.423
32.2740.36241.204
51.4430.26511.030
81.1950.23000.959
121.1410.22190.942
steady state: P = 1.133K = 0.2207filtered sd 0.940
single reading sd 2.000; error variance cut to 0.221
EWMA weight today 0.2207; half the weight in last 3 days, 90 % in last 10
mean age of the information: 3.53 days

核心公式

\[P_t=p_{t-1}+q.\]
查看完整验算程序
# Chapter 2. p21: The Kalman gain settles fast and turns into an EWMA.
# Local level, q = 0.25 (true daily change sd 0.5) and r = 4 (reading
# error sd 2.0), as in p11; the first estimate starts from a vague
# prior, variance 100. Predicted variance P satisfies, at steady state,
#   P = (q + sqrt(q^2 + 4 q r)) / 2,  K = P / (P + r).
# Muth (1960): the steady-state filter is exponential smoothing with
# weight K, so reading j days back gets weight K (1 - K)^j.
import math

Q, R, P0 = 0.25, 4.0, 100.0

p = P0
print("day  predicted P  gain K   filtered sd")
for t in range(1, 13):
    pp = p + Q if t > 1 else p
    k = pp / (pp + R)
    p = pp * (1 - k)
    if t in (1, 2, 3, 5, 8, 12):
        print("%3d  %10.3f   %.4f   %.3f" % (t, pp, k, math.sqrt(p)))
pss = (Q + math.sqrt(Q * Q + 4 * Q * R)) / 2
kss = pss / (pss + R)
print("steady state: P = %.3f  K = %.4f  filtered sd %.3f"
      % (pss, kss, math.sqrt(pss * (1 - kss))))
print("single reading sd %.3f; error variance cut to %.3f"
      % (math.sqrt(R), pss * (1 - kss) / R))
w = [kss * (1 - kss) ** j for j in range(200)]
cum, half, ninety = 0.0, None, None
for j in range(200):
    cum = math.fsum(w[:j + 1])
    if half is None and cum >= 0.5:
        half = j + 1
    if ninety is None and cum >= 0.9:
        ninety = j + 1
print("EWMA weight today %.4f; half the weight in last %d days,"
      " 90 %% in last %d" % (kss, half, ninety))
print("mean age of the information: %.2f days" % ((1 - kss) / kss))

唯一数据源与引用

范雅福(Fan, Y.). (2026). 《卡尔曼滤波状态空间同化、可穿戴读数观测噪音与广告归因真实信号提纯母典》第 2 章「卡尔曼增益从哪里来:一步预测、一步修正与指数平滑」(版本 1.0.0). 5D Library. DOI 待发布

DOI 待发布 · 专著页正式发布后上线(本站暂无专著页) · 5DL-B-245 · v1.0.0 · CC-BY-NC-ND-4.0

BibTeX
@book{fan2026245,
  author    = {Fan, Yafu},
  title     = {Kalman Filtering and State-Space Assimilation: Separating Observation Noise from True Signals in Wearable Readings and Advertising Reports},
  year      = {2026},
  publisher = {5D Library},
  edition   = {1.0.0},
  note      = {DOI pending}
}

本书其他章节结论