What does Kalman Filtering for Readings and Ad Reports conclude, in numbers, about “Closing the Loop: a Four-Week Filtered Log, Filtered Advertising Reports and Pre-Registered Tests”?
Answer: Chapter 8 gives the closed loops for a four-week filtered log and for filtered advertising reports, the Noisy-Reading Filter tool and two pre-registered protocols (96 advertising accounts under conservative assumptions, 57 personal logs). Marked boxes separate published evidence, runnable Python calculations (19 programs), classical sources and the author's hypotheses.
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: 96
| as in p62 mean gain | 1963.1 yuan, sd 1506.4, d 1.303, wins 0.918 |
| clean mean gain | 728.9 yuan, sd 636.3, d 1.146, wins 0.913 |
| accounts for 80 % power in the clean world | 6 |
| accounts if the true gain is only a quarter of that | 96 |
| simulated power with 3 accounts | 0.587 |
| simulated power with 6 accounts | 0.887 |
Show the full program
# Chapter 8. p82: How many ad accounts does a fair split test need?
# Each account's audience is split at random into two halves (regions
# or user groups) that share the same true return path. One half runs
# the switching rule of p62 on its own raw daily report, the other on
# the Kalman estimate of its own report; each half spends half of 2000
# or 300 yuan, so its report noise is larger by sqrt(2). Accounts draw
# drift sd U(0.02, 0.04), start return U(0.95, 1.15) and full-account
# noise sd U(0.15, 0.35) ("as in p62") or U(0.05, 0.15) ("clean", the
# pessimistic world used for the design); q and r are mis-set by a
# factor e^N(0, 0.5) each. Outcome: paired difference in 90-day profit
# (yuan). Sample size from the clean world, checked by simulation.
# Fixed seed; illustrative values.
import math
import random
import statistics
DAYS, HI, LO = 90, 1000.0, 150.0
rng = random.Random(20261128)
Z = statistics.NormalDist()
def account(lo, hi):
sq = rng.uniform(0.02, 0.04)
sr = rng.uniform(lo, hi) * math.sqrt(2)
q = sq * sq * math.exp(rng.gauss(0, 0.5))
r = sr * sr * math.exp(rng.gauss(0, 0.5))
rho = rng.uniform(0.95, 1.15)
m, p, gain = None, r, []
for _ in range(DAYS):
ya, yb = rho + rng.gauss(0, sr), rho + rng.gauss(0, sr)
if m is None:
m = yb
else:
pp = p + q
k = pp / (pp + r)
m, p = m + k * (yb - m), pp * (1 - k)
rho += rng.gauss(0, sq)
sb = HI if m > 1.0 else LO
sa = HI if ya > 1.0 else LO
gain.append((rho - 1) * (sb - sa))
return math.fsum(gain)
za, zb = Z.inv_cdf(0.975), Z.inv_cdf(0.80)
for name, lo, hi in (("as in p62", 0.15, 0.35), ("clean", 0.05, 0.15)):
pilot = [account(lo, hi) for _ in range(3000)]
mu, sd = statistics.fmean(pilot), statistics.stdev(pilot)
d = mu / sd
n = math.ceil((za + zb) ** 2 / d ** 2)
win = [g > 0 for g in pilot].count(True) / len(pilot)
print("%-9s mean gain %7.1f yuan, sd %7.1f, d %.3f, wins %.3f"
% (name, mu, sd, d, win))
print("accounts for 80 %% power in the clean world: %d" % n)
print("accounts if the true gain is only a quarter of that: %d"
% math.ceil((za + zb) ** 2 / (d / 4) ** 2))
for k in (n // 2, n):
hits = 0
for _ in range(300):
g = [account(0.05, 0.15) for _ in range(k)]
if statistics.fmean(g) / (statistics.stdev(g) / math.sqrt(k)) > za:
hits += 1
print("simulated power with %d accounts: %.3f" % (k, hits / 300))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 8: Closing the Loop: a Four-Week Filtered Log, Filtered Advertising Reports and Pre-Registered Tests. 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 6 · The Advertising Report: Attribution Noise, On/Off Flighting and Budget Switching
- Chapter 7 · Classical Sources East and West: the Mencius and Gauss's Least Squares