Repository navigation
Highlights
-
detect_cusumgets areferenceparameter, to choose the level that each sample is compared with,s[t] = x[t] − reference[t−1]:'previous'(default): the previous sample, the same detection as in 0.0.5'residual': exponentially weighted mean, set with the newalphaparameter (Gustafsson, 2000)'run_mean': mean of the data so far, as in the Page-Hinkley test'mean': mean of a baseline ofn_baselinesamples (classical CUSUM, Page 1954)- a number: a known, fixed reference level
The estimated references restart after each detected change. With a reference level, small sustained changes can be detected; with
'previous'they could not. -
Reliable ending of changes (
ending=True): each change now gets exactly one ending, found by running the algorithm backwards over that change's own stretch of data. The old reverse run and its pairing heuristics could drop
detected changes or pair them with the wrong ending. -
Example notebooks are now marimo notebooks, with interactive examples. Run them in the browser from the links in the README.
Changes that affect results
detect_cusum(..., ending=True):tafandampcan differ from 0.0.5, and detected changes are no longer dropped.ampis now the difference between the mean of the data after and before the change, instead of the difference
between two single samples.detect_cusumwith the defaultreference='previous'andending=Falsereturns the sametaandtaias 0.0.5.
Fixes
detect_peaks: replacednp.in1d, deprecated in NumPy 2, withnp.isin. Data with NaN's triggered this code path.detect_seq: the sequence lengths used bymax_alertwere one sample short.detect_cusum: plotting into axes you pass in (ax) now works (#3, by @piiq). This fix is released here for the first time.
Packaging
pyproject.tomlreplacessetup.py.numpyis now a declared dependency, and the license is listed as MIT.- Requires Python ≥ 3.9. Tested on 3.9, 3.12 and 3.14, with NumPy 1.x and 2.x.
pip install "detecta[plot]"also installs matplotlib for the plots.- New test suite, and continuous integration that publishes to PyPI from GitHub releases.
Full changelog: v0.0.5...v0.1.0