Solution (source code)

= Solution

Iterating the <CUSUM> recursion shows that
$$
X_t=\max\left(0,\max_{1\leq k\leq t}\sum_{s=k}^tW_s\right).
$$
Thus it searches all possible starting times for a recent stretch of evidence favoring an increase. If adding an increment makes the current sum negative, that accumulated evidence favors the null; retaining it would force a later real deterioration first to repay a deficit accumulated during healthy years. Starting a new candidate segment gives zero instead. \b[Resetting at zero makes detection responsive to a change with unknown onset.] Negative values would be permissible for a fixed-start signed <log-likelihood ratio>, but that is a different statistic from this one-sided tabular <CUSUM>.