What does Kalman Filtering for Readings and Ad Reports conclude, in numbers, about “The Advertising Report: Attribution Noise, On/Off Flighting and Budget Switching”?
Answer: Chapter 6 turns to advertising reports: switching the budget on the raw report changes level 33.8 times in ninety days and earns 0.714 of the ideal, switching on the filtered estimate changes only 5.6 times and earns 0.903, and with constant spend no method learns the effect of advertising.
Scope of the numbers: Its noise variances, drifts, returns and budgets are illustrative parameters; all calculations are generated by its programs. On wearable readings it is not medical advice, claims no effect, judges no one's state of health, and asks readers to consult a licensed physician before any self-experiment; on advertising attribution it is not individual business advice.
Data table
The numbers below are printed verbatim by the chapter's Python program and can be reproduced by running it. standard-library Python onlyprinted values that match the answer: 0.714, 0.903, 33.8, 5.6
| estimate | switches/90d | wrong-day share | profit (yuan) | vs oracle |
| raw | 33.8 | 0.299 | 11118 | 0.714 |
| mean7 | 7.6 | 0.190 | 13776 | 0.885 |
| kalman | 5.6 | 0.175 | 14060 | 0.903 |
| oracle | 5.0 | 0.000 | 15564 | 1.000 |
| steady Kalman gain here: 0.1130 |
Show the full program
# Chapter 6. p62: Switching the budget on raw vs filtered daily returns.
# True incremental margin per yuan of spend ("true return") starts at
# 1.05 and drifts as a random walk (sd 0.03 a day). The daily report
# shows true return + attribution noise (sd 0.25). Rule each morning:
# if the estimate of today's return is above 1, spend 2000 yuan, else
# 300 yuan (a floor that keeps the campaign measurable). Profit of a
# day = (true return - 1) x spend. Estimates: yesterday's raw report,
# trailing 7-day mean, Kalman (q = 0.03^2, r = 0.25^2), and the oracle
# that sees the true return. 1000 runs of 90 days, fixed seed.
import math
import random
import statistics
SD_Q, SD_R, DAYS, HI, LO = 0.03, 0.25, 90, 2000.0, 300.0
rng = random.Random(20261124)
res = {k: ([], [], []) for k in ("raw", "mean7", "kalman", "oracle")}
for _ in range(1000):
rho, path, rep = 1.05, [], []
for _ in range(DAYS + 1):
path.append(rho)
rep.append(rho + rng.gauss(0, SD_R))
rho += rng.gauss(0, SD_Q)
m, p = rep[0], SD_R ** 2
kal = [m]
for y in rep[1:]:
pp = p + SD_Q ** 2
k = pp / (pp + SD_R ** 2)
m, p = m + k * (y - m), pp * (1 - k)
kal.append(m)
ests = {"raw": rep, "kalman": kal, "oracle": path[1:] + [0.0],
"mean7": [statistics.fmean(rep[max(0, t - 6):t + 1])
for t in range(DAYS + 1)]}
for name, e in ests.items():
prof, flips, wrong, last = [], 0, 0, None
for t in range(1, DAYS + 1):
hi = e[t - 1] > 1.0
prof.append((path[t] - 1) * (HI if hi else LO))
wrong += hi != (path[t] > 1.0)
if last is not None and hi != last:
flips += 1
last = hi
res[name][0].append(math.fsum(prof))
res[name][1].append(flips)
res[name][2].append(wrong / DAYS)
top = statistics.fmean(res["oracle"][0])
print("estimate switches/90d wrong-day share profit (yuan) vs oracle")
for name in ("raw", "mean7", "kalman", "oracle"):
pr = statistics.fmean(res[name][0])
print("%-8s %11.1f %14.3f %12.0f %8.3f"
% (name, statistics.fmean(res[name][1]),
statistics.fmean(res[name][2]), pr, pr / top))
pss = (SD_Q ** 2 + math.sqrt(SD_Q ** 4 + 4 * SD_Q ** 2 * SD_R ** 2)) / 2
print("steady Kalman gain here: %.4f" % (pss / (pss + SD_R ** 2)))Single source and citation
Fan, Y. (2026). Kalman Filtering and State-Space Assimilation: Separating Observation Noise from True Signals in Wearable Readings and Advertising Reports (Version 1.0.0), Chapter 6: The Advertising Report: Attribution Noise, On/Off Flighting and Budget Switching. 5D Library. DOI pending
DOI pending · monograph page goes live after publication · 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}
}Other chapter answers in this book
- Chapter 1 · Why Raw Readings Overreact: the Noise-to-Signal Ratio and Decision Flips
- Chapter 2 · Where the Kalman Gain Comes From: One Prediction, One Correction and Exponential Smoothing
- Chapter 3 · Trends and Steps: Slow Drift Takes Weeks to Show, a Real Jump Costs Days of Lag
- Chapter 4 · Looking Back and Filling Gaps: the RTS Smoother, Missing Days and Artefact Readings
- Chapter 5 · How Large Is the Noise? Maximum Likelihood, Innovation Tests and Moments of Differences
- Chapter 7 · Classical Sources East and West: the Mencius and Gauss's Least Squares
- Chapter 8 · Closing the Loop: a Four-Week Filtered Log, Filtered Advertising Reports and Pre-Registered Tests