关于「噪音有多大:极大似然、新息检验与差分矩估计」,《可穿戴读数与广告日报的卡尔曼滤波》给出的定量结论是什么?
结论:第五章讲极大似然、新息检验与差分矩估计:四周数据估出的增益在 0.031 到 0.481 之间,只能当作起点。
数据口径:本书用局部水平与局部趋势的状态空间模型检验这一常识:一个读数等于真实水平加测量误差,当误差方差远大于真实日变化方差时,按原始读数做是或否的决定会对噪音过度反应;示意参数下原始读数每百天翻转 23.6 次,卡尔曼滤波估计只翻转 5.5 次。 书中的噪音方差、漂移、回报率与预算均为示意参数;全部计算由书中程序生成。
对照数据表
下表数字由本章 Python 程序原样打印,可重新运行复现。 程序只用 Python 标准库与结论吻合的打印值: 0.031, 0.481
| true rho = r/q | 16, true gain K = 0.2207 |
| days rho 5% median | 95% K 5% median 95% |
| 28 | 2.00 28.18 1000.0 0.031 0.171 0.481 |
| fits at the grid edge rho | 1000 (level looks flat): 73 of 300 |
| 120 | 6.31 15.85 70.8 0.112 0.222 0.327 |
| fits at the grid edge rho | 1000 (level looks flat): 1 of 300 |
核心公式
\[\log L=-\tfrac12\sum_t\left(\log F_t+\frac{v_t^2}{F_t}\right).\]
查看完整验算程序
# Chapter 5. p51: Estimating the noise ratio from the readings alone.
# Prediction error decomposition: with q = s2 and r = s2 * rho, the
# log-likelihood is -0.5 sum(log F + v^2 / F); s2 is concentrated out,
# s2_hat = mean(v^2 / F*), and rho is found on a log grid from 0.01 to
# 1000. The filter starts from the first reading (posterior var r).
# True q = 0.25, r = 4, so rho = 16 and the steady gain is 0.2207.
# 300 simulated logs each of 28 days (four weeks) and 120 days; fixed
# seed. Reported: median and 5 % / 95 % points of rho_hat and K_hat.
import math
import random
import statistics
Q, R = 0.25, 4.0
GRID = [10 ** (-2 + 5 * i / 100) for i in range(101)]
rng = random.Random(20261120)
def gain(rho):
p = (1 + math.sqrt(1 + 4 * rho)) / 2
return p / (p + rho)
def profile(ys, rho):
m, p, terms, logf = ys[0], rho, [], []
for y in ys[1:]:
pp = p + 1.0
f = pp + rho
v = y - m
terms.append(v * v / f)
logf.append(math.log(f))
k = pp / f
m, p = m + k * v, pp * (1 - k)
n = len(terms)
s2 = math.fsum(terms) / n
return -0.5 * (math.fsum(logf) + n * math.log(s2) + n), s2
def fit(ys):
best = max(GRID, key=lambda g: profile(ys, g)[0])
return best, profile(ys, best)[1]
def pct(xs, a):
xs = sorted(xs)
return xs[int(a * (len(xs) - 1))]
print("true rho = r/q = %.0f, true gain K = %.4f" % (R / Q, gain(R / Q)))
print("days rho 5% median 95% K 5% median 95%")
for n in (28, 120):
rhos, ks = [], []
for _ in range(300):
mu, ys = 0.0, []
for _ in range(n):
mu += rng.gauss(0, math.sqrt(Q))
ys.append(mu + rng.gauss(0, math.sqrt(R)))
rho, _ = fit(ys)
rhos.append(rho)
ks.append(gain(rho))
print("%4d %7.2f %7.2f %7.1f %.3f %.3f %.3f"
% (n, pct(rhos, 0.05), statistics.median(rhos),
pct(rhos, 0.95), pct(ks, 0.05), statistics.median(ks),
pct(ks, 0.95)))
edge = [g >= GRID[-1] for g in rhos].count(True)
print(" fits at the grid edge rho = 1000 (level looks flat):"
" %d of 300" % edge)唯一数据源与引用
范雅福(Fan, Y.). (2026). 《卡尔曼滤波状态空间同化、可穿戴读数观测噪音与广告归因真实信号提纯母典》第 5 章「噪音有多大:极大似然、新息检验与差分矩估计」(版本 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}
}