---
tag: VYM8AJ8111
kind: definition
name: CUSUM
msc: [62L10, 62P30]
defines: 1VXZHAHT6K
uses: [Z5H8ZZHVMC, 9CWYNB9003, 0VW9E4QXR6, WND87FBAKC]
sources:
  - url: https://en.wikipedia.org/wiki/CUSUM
---

## Definition

Let $X_1, X_2, \dots$ be observed one at a time, in the setting of the [[change detection|Z5H8ZZHVMC]] problem with pre-change density $f_0$ and post-change density $f_1$.
Let $\ell(x) = \log \big( f_1(x) / f_0(x) \big)$ be the log [[likelihood ratio|0VW9E4QXR6]] of one observation.
The *CUSUM statistic* is defined by
$$W_0 = 0, \qquad W_n = \max\left(0, \; W_{n-1} + \ell(X_n)\right) \quad (n \ge 1).$$
For a threshold $h > 0$, the *CUSUM procedure* is the [[stopping time|WND87FBAKC]]
$$T_h = \min \set{n \ge 1 : W_n \ge h},$$
at which it raises an alarm.

## Remarks

Equivalently, $W_n = \max_{1 \le k \le n + 1} \sum_{i=k}^{n} \ell(X_i)$, with the empty sum for $k = n + 1$ equal to $0$.
So $W_n$ is the largest log-likelihood ratio of "a change happened at time $k$" against "no change yet", over all candidate times $k$.

Example: for a shift of a normal mean from $\mu_0$ to $\mu_1 > \mu_0$ with variance $\sigma^2$, one finds $\ell(x) = \frac{\mu_1 - \mu_0}{\sigma^2} \left( x - \frac{\mu_0 + \mu_1}{2} \right)$.
After rescaling, the statistic becomes $S_n = \max(0, S_{n-1} + X_n - \mu_0 - k)$ with the reference value $k = (\mu_1 - \mu_0)/2$, the form used in quality control.

Non-example: the plain cumulative sum $\sum_{i=1}^n \ell(X_i)$ without the reset at $0$ is not the CUSUM statistic.
Before the change it drifts down to $-\infty$, so after a late change it needs a long time to climb back to the threshold.

The mean time to a false alarm satisfies $E_\infty[T_h] \ge e^h$, which guides the choice of $h$.
