Level 0: Foundation
★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.When did things change?
A factory machine starts producing parts that are slightly too thick. One part alone looks fine, but if you keep a running tally of how much thicker than usual each part is, the tally soon becomes too large to be chance. That running tally is the idea behind CUSUM, one of the oldest and best change detectors. Looking back over a whole year of data, a different question is asked: where exactly were all the changes?
The CUSUM chart was invented by E. S. Page in 1954, and in 1971 G. Lorden showed that it is optimal in a precise worst-case sense.
- 1. A change point is…
- 2. Online detection aims to…
- 3. CUSUM keeps…
Level 1: Beginner
★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.By hand
- Shewhart chart: alarm when a single standardised value exceeds h. Fast for large shifts, slow for small ones.
- EWMA chart: alarm when z_t = λx_t + (1 − λ)z_t−1 exceeds h; small λ accumulates more evidence.
- CUSUM: S_t = max(0, S_t−1 + x_t − k), alarm when S_t > h. With k = δ/2 it is tuned to a shift of size δ; it is the sequential likelihood-ratio test for that shift.
- Average run length (ARL): ARL₀ is the mean time to a false alarm with no change; the detection delay (ARL₁) is the mean time to alarm after a change. Compare charts at equal ARL₀.
- Offline segmentation: choose change points minimising the total segment cost plus a penalty per change. Binary segmentation splits greedily; PELT finds the exact optimum in about linear time by pruning.
- Penalty: BIC-type penalties (for a mean change with known variance about 2σ² log n in squared-error units) balance missed and spurious changes. Other tools: Bayesian online change-point detection, kernel and rank-based costs.
- 1. Charts should be compared at equal…
- 2. CUSUM with k = δ/2 is tuned for a shift of…
- 3. PELT finds…
Level 2: Intermediate
★★★☆☆ Intermediate⏱ 25 minUndergraduate students and practising engineers.CUSUM online, PELT offline
Exercise 1.
- A shift of 1 sd at step 200 of standard normal data, monitored with an upper CUSUM (k = 0.5, h = 5).
- A 500-point signal with means 0, 2, −1, 1 and changes at 150, 250 and 400.
- PELT with the BIC penalty and with a much smaller penalty.
Practice.
- Calibrate thresholds by the false-alarm rate you can live with, by simulation or from published ARL tables.
- Tune to the smallest shift that matters: CUSUM’s k or EWMA’s λ.
- Standardise with in-control estimates; estimation error in the mean and sd changes the actual ARL.
- Choose the offline penalty deliberately (BIC, or by cross-validation on labelled history) and check the segments visually.
- Tools: ruptures (PELT, binary segmentation, kernel costs), changepoint (R), statsmodels, bayesian_changepoint_detection.
import numpy as np
def cusum(x, k):
S, out = 0.0, []
for v in x:
S = max(0.0, S + v - k)
out.append(S)
return np.array(out)- 1. Thresholds are set from…
- 2. Too small a penalty in offline segmentation gives…
- 3. A Python library with PELT:
Level 3: Advanced
★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.Theory
CUSUM as a likelihood ratio. For N(0, 1) before and N(δ, 1) after a change, the log-likelihood ratio of one observation is δ(x − δ/2). The largest sum of these ratios over all possible change times, updated recursively, is δ·S_t with k = δ/2. Lorden (1971) showed that CUSUM minimises the worst-case detection delay among all procedures with the same ARL₀, for the shift it is tuned to.
EWMA variance. For independent values with sd σ, the EWMA has stationary sd σ√(λ/(2 − λ)), which is 0.23σ for λ = 0.1. A threshold of 0.58 is therefore about 2.5 EWMA sds, far below the 2.87 a Shewhart chart needs at the same ARL₀.
Penalised segmentation. With cost equal to the sum of squared deviations from each segment mean, the optimal partition satisfies F(t) = min over s of F(s) + C(s, t) + β. PELT drops a candidate s once F(s) + C(s, t) exceeds F(t), because adding more data to a segment never lowers its cost, so s can never become optimal later.
- 1. The per-observation log-likelihood ratio for a shift δ is…
- 2. Stationary sd of an EWMA with λ = 0.1 (σ = 1):
- 3. PELT can prune a candidate because segment costs…
Level 4: Expert
★★★★★ Expert⏱ 30 minResearchers: original papers and open problems.At the same false-alarm rate, how fast do Shewhart, EWMA and CUSUM charts detect upward mean shifts of different sizes, and how does the penalty change what PELT finds offline?
History.
- W. A. Shewhart (1931) introduced control charts; E. S. Page (1954) the CUSUM; S. W. Roberts (1959) the EWMA chart.
- G. Lorden (1971) and G. V. Moustakides (1986) proved the optimality of CUSUM.
- A. J. Scott and M. Knott (1974) introduced binary segmentation; R. Killick, P. Fearnhead and I. A. Eckley (2012) introduced PELT; R. P. Adams and D. J. C. MacKay (2007) Bayesian online change-point detection.
Exercise 2.
- Online: standard normal data; thresholds for one-sided Shewhart, EWMA (λ = 0.1) and CUSUM (k = 0.5) set by simulation of 500 chains so that the in-control ARL is 500. Mean delay over 500 chains whose mean is shifted from the start (the count includes the alarm step).
- Offline: 100 signals of 500 points with 0–5 changes at least 20 apart, jumps of 0.5–2 sd. A detected change is correct if within 5 steps of a true one.
Seed 0, mean detection delay:
| chart (threshold) | 0.25 sd | 0.5 sd | 1 sd | 2 sd | 3 sd |
|---|---|---|---|---|---|
| Shewhart (2.87) | 222 | 108 | 32 | 5.0 | 1.9 |
| EWMA, λ = 0.1 (0.58) | 71 | 25 | 8.7 | 3.8 | 2.6 |
| CUSUM, k = 0.5 (4.39) | 97 | 29 | 9.0 | 3.6 | 2.3 |
- For small shifts the accumulating charts were 2–4 times faster than Shewhart; EWMA was fastest for shifts of 0.25 and 0.5 sd.
- EWMA and CUSUM were close for a 1 sd shift (8.7 and 9.0), CUSUM was faster for 2 sd, and Shewhart for 3 sd.
- Offline, PELT with the BIC penalty found changes with precision 0.82 and recall 0.78. A penalty of 2 reported about 35 changes per true change (precision 0.03); a penalty of 10 log n missed more than half (recall 0.42) with precision 0.90.
- Seeds 1 and 2: delays for 0.5 sd were 121 and 122 (Shewhart), 24 and 24 (EWMA), 30 and 30 (CUSUM); BIC precision 0.84 and 0.84, recall 0.78 in both.
Change-point detection in practice
- Manufacturing and quality: CUSUM and EWMA charts are standard in statistical process control.
- Operations and monitoring: detecting regressions in latency or error rates after deployments.
- Science: segmenting climate records, genomic copy number and spacecraft telemetry into regimes.
- Beyond the mean: changes in variance, trend, distribution or correlation need other costs or statistics; kernel and rank-based costs handle unknown distributions.
References
- E. S. Page (1954). “Continuous inspection schemes.” Biometrika.
- G. Lorden (1971). “Procedures for reacting to a change in distribution.” Annals of Mathematical Statistics.
- R. Killick, P. Fearnhead and I. A. Eckley (2012). “Optimal detection of changepoints with a linear computational cost.” Journal of the American Statistical Association.
- R. P. Adams and D. J. C. MacKay (2007). “Bayesian online changepoint detection.” arXiv.
- C. Truong, L. Oudre and N. Vayatis (2020). “Selective review of offline change point detection methods.” Signal Processing.