What does CUSUM Alarms conclude, in numbers, about “Eastern and Western Sources: the Dike of a Thousand Zhang and Shewhart's Three Sigma”?

Answer: Chapter 7 examines the Han Feizi's dike that collapses through ant holes and Shewhart's control chart of 1931.

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 only

shiftloss fixedloss CUSUMfixed / CUSUM
0.2544.120.52.15
0.5044.413.83.21
1.0026.78.63.12
2.009.26.81.35
3.005.16.70.76
hair trigger L = 1: false alarm every 6.3 days
hair trigger alarms per year in control: 57.9
CUSUM alarms per year in control: 0.99
Show the full program
# Chapter 7. p71: "a dike of a thousand zhang falls by an ant hole" as a
# loss account.
# Model: after a shift of delta sigma every day until the alarm costs
# delta units of excess (latency above plan, or conversions lost), so
# the expected loss before an alarm is delta * ARL1. The fixed threshold
# (L = 2.782) and the CUSUM (k = 0.5, h = 4.096) share ARL0 = 370. A
# hair-trigger rule that reacts to every reading above one sigma
# (L = 1) stands for blocking every hole at once. Illustrative units.
import math


def cdf(x):
    return 0.5 * math.erfc(-x / math.sqrt(2.0))


def upper(x):
    return 0.5 * math.erfc(x / math.sqrt(2.0))


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 arl(k, h, delta, m=80):
    w = 2.0 * h / (2 * m - 1)
    a = []
    for i in range(m):
        c = i * w - k + delta
        row = [-cdf(w / 2.0 - c)]
        for j in range(1, m):
            row.append(cdf(j * w - w / 2.0 - c)
                       - cdf(j * w + w / 2.0 - c))
        row[i] = row[i] + 1.0
        a.append(row)
    return solve(a, [1.0] * m)[0]


def limit_for(arl0):
    lo, hi = 0.0, 10.0
    for _ in range(200):
        mid = 0.5 * (lo + hi)
        if upper(mid) > 1.0 / arl0:
            lo = mid
        else:
            hi = mid
    return 0.5 * (lo + hi)


if __name__ == "__main__":
    k, h = 0.5, 4.096
    L = limit_for(370.0)
    print(" shift   loss fixed   loss CUSUM   fixed / CUSUM")
    for d in (0.25, 0.5, 1.0, 2.0, 3.0):
        lf = d / upper(L - d)
        lc = d * arl(k, h, d)
        print(" {:5.2f}  {:10.1f}  {:11.1f}  {:10.2f}".format(
            d, lf, lc, lf / lc))
    a0 = 1.0 / upper(1.0)
    print("hair trigger L = 1: false alarm every {:.1f} days".format(a0))
    print("hair trigger alarms per year in control: {:.1f}".format(
        365.0 / a0))
    print("CUSUM alarms per year in control: {:.2f}".format(365.0 / 370.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 7: Eastern and Western Sources: the Dike of a Thousand Zhang and Shewhart's Three Sigma. 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