What does CUSUM Alarms conclude, in numbers, about “A Daily CUSUM at the Toll Gate: P99 Latency, Silent Conversion Drops and a Falsification Protocol”?
Answer: Chapter 8 sets out a daily CUSUM routine for a toll gate's P99 latency and conversion: when conversion falls by a tenth, the CUSUM alarms after 13.7 days on average and a fixed count rule after 52.8; it also presents the distilled CUSUM Alarm Designer and a pre-registered test. Marked boxes separate published evidence, runnable Python calculations (23 programs), classical sources and the author's hypotheses.
Scope of the numbers: Parameters are illustrative; all calculations are generated by the book's programs; the book is general business analysis, not individualised business advice, and Chapter 8 is an offline model that reads no server. Marked boxes separate published evidence, runnable Python calculations (23 programs), classical sources and the author's hypotheses.
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: 13.7, 52.8
| expected conversions per day | 60 |
| fixed rule: alarm when y < | 39, ARL0 = 443.1 days |
| CUSUM: h | 4.428, chain ARL0 = 442.8 days |
| CUSUM ARL0 by simulation (10000 runs) | 430.5 +/- 8.3 |
| drop p fixed ARL1 CUSUM ARL1 sim | |
| 0.10 | 0.0270 52.8 13.7 13.5 |
| 0.15 | 0.0255 21.2 6.6 6.6 |
| 0.20 | 0.0240 9.6 4.3 4.3 |
| 0.30 | 0.0210 2.8 2.6 2.6 |
Show the full program
# Chapter 8. p82: a Bernoulli log-likelihood CUSUM for a silent drop in
# conversion, checked once a day.
# Model: each day n = 2000 visitors convert independently with p0 = 0.030
# in control. The chart is tuned to a 15 per cent drop (p1 = 0.0255): a
# day with y conversions adds y log(p1/p0) + (n - y) log((1-p1)/(1-p0))
# to S = max(0, S + llr), the per-visitor Bernoulli CUSUM summed over a
# day. The fixed rule alarms when y <= c, with c the largest count that
# keeps ARL0 >= 365 days; h is then solved so the CUSUM has the same
# ARL0. ARL comes from a Markov chain on [0, h] (m = 100 cells, binomial
# moves rounded to the nearest cell) and is checked by a fixed-seed
# simulation; rounding discrete moves to cells costs a few per cent in
# ARL0. Traffic and rates are illustrative.
import bisect
import math
import random
N, P0, P1 = 2000, 0.030, 0.0255
YMAX = 200
def solve(a, b):
# Gaussian elimination with partial pivoting; back substitution
# adds its terms with math.fsum
n = len(b)
m = [list(row) + [b[i]] for i, row in enumerate(a)]
for p in range(n):
q = max(range(p, n), key=lambda r: abs(m[r][p]))
m[p], m[q] = m[q], m[p]
piv = m[p]
for r in range(p + 1, n):
f = m[r][p] / piv[p]
if f != 0.0:
m[r] = m[r][:p] + [x - f * y for x, y in
zip(m[r][p:], piv[p:])]
x = [0.0] * n
for i in range(n - 1, -1, -1):
s = math.fsum(m[i][j] * x[j] for j in range(i + 1, n))
x[i] = (m[i][n] - s) / m[i][i]
return x
def pmf(p):
out = []
for y in range(YMAX + 1):
lg = (math.lgamma(N + 1) - math.lgamma(y + 1)
- math.lgamma(N - y + 1) + y * math.log(p)
+ (N - y) * math.log(1.0 - p))
out.append(math.exp(lg))
return out
def llr(y):
return (y * math.log(P1 / P0)
+ (N - y) * math.log((1.0 - P1) / (1.0 - P0)))
def arl(h, f, m=100):
w = 2.0 * h / (2 * m - 1)
a = [[0.0] * m for _ in range(m)]
for i in range(m):
for y, q in enumerate(f):
s = i * w + llr(y)
if s > h:
continue
j = 0 if s <= w / 2.0 else min(m - 1, int(s / w + 0.5))
a[i][j] = a[i][j] - q
a[i][i] = a[i][i] + 1.0
return solve(a, [1.0] * m)[0]
def simulate(rng, h, cum, runs):
# returns the mean run length and its standard error
out = []
for _ in range(runs):
s, t = 0.0, 0
while True:
t = t + 1
y = bisect.bisect_left(cum, rng.random())
s = max(0.0, s + llr(y))
if s > h:
out.append(t)
break
mean = math.fsum(out) / runs
var = math.fsum((x - mean) ** 2 for x in out) / (runs - 1)
return mean, math.sqrt(var / runs)
if __name__ == "__main__":
f0 = pmf(P0)
c = 0
while 1.0 / math.fsum(f0[:c + 2]) >= 365.0:
c = c + 1
a0 = 1.0 / math.fsum(f0[:c + 1])
lo, hi = 0.5, 20.0
for _ in range(30):
mid = 0.5 * (lo + hi)
if arl(mid, f0) < a0:
lo = mid
else:
hi = mid
h = 0.5 * (lo + hi)
print("expected conversions per day: {:.0f}".format(N * P0))
print("fixed rule: alarm when y <= {}, ARL0 = {:.1f} days".format(c, a0))
print("CUSUM: h = {:.3f}, chain ARL0 = {:.1f} days".format(
h, arl(h, f0)))
rng = random.Random(20261113)
cum0 = [math.fsum(f0[:j + 1]) for j in range(len(f0))]
mean, se = simulate(rng, h, cum0, 10000)
print("CUSUM ARL0 by simulation (10000 runs): {:.1f} +/- {:.1f}".format(
mean, 1.96 * se))
print(" drop p fixed ARL1 CUSUM ARL1 sim")
for drop in (0.10, 0.15, 0.20, 0.30):
p = P0 * (1.0 - drop)
f = pmf(p)
fx = 1.0 / math.fsum(f[:c + 1])
cum = [math.fsum(f[:j + 1]) for j in range(len(f))]
print(" {:4.2f} {:.4f} {:10.1f} {:11.1f} {:6.1f}".format(
drop, p, fx, arl(h, f), simulate(rng, h, cum, 4000)[0]))Single source and citation
Fan, Y. (2026). CUSUM Control Charts and Average Run Length: the Fastest Alarm within a False-Alarm Budget for Latency Drift and Silent Conversion Drops (Version 1.0.0), Chapter 8: A Daily CUSUM at the Toll Gate: P99 Latency, Silent Conversion Drops and a Falsification Protocol. 5D Library. DOI pending
DOI pending · monograph page goes live after publication · 5DL-B-305 · v1.0.0 · CC-BY-NC-ND-4.0
BibTeX
@book{fan2026305,
author = {Fan, Yafu},
title = {CUSUM Control Charts and Average Run Length: the Fastest Alarm within a False-Alarm Budget for Latency Drift and Silent Conversion Drops},
year = {2026},
publisher = {5D Library},
edition = {1.0.0},
note = {DOI pending}
}Other chapter answers in this book
- Chapter 1 · The Sluggish Red Line: at Equal False-Alarm Rates the CUSUM Is Several Times Faster
- Chapter 2 · One Line of Recursion: the CUSUM Is a Running Log-Likelihood Ratio
- Chapter 3 · The Markov Chain of Brook and Evans: the Average Run Length as a System of Linear Equations
- Chapter 4 · Siegmund's Approximation and Lorden's Bound: Detection Delay Grows Only with the Logarithm of the False-Alarm Interval
- Chapter 5 · Design Tables for the Reference Value and the Limit: the Cost of a Wrong Shift and a Wrong Baseline
- Chapter 6 · The Boundaries of Optimality: Autocorrelation, Residual Charts and Large Jumps
- Chapter 7 · Eastern and Western Sources: the Dike of a Thousand Zhang and Shewhart's Three Sigma