STUMPY: Matrix Profiles for Motifs, Anomalies and Regime Changes
Citation. Sean M. Law (TD Ameritrade). "STUMPY: A Powerful and Scalable Python Library for Time Series Data Mining". Journal of Open Source Software 4(39), 1504, 2019. DOI 10.21105/joss.01504. Read with the method's source, by Chin-Chia Michael Yeh, Yan Zhu, Liudmila Ulanova, Nurjahan Begum and Yifei Ding. Its other authors are Hoang Anh Dau, Diego Furtado Silva, Abdullah Mueen and Eamonn Keogh. "Matrix Profile I: All Pairs Similarity Joins for Time Series". ICDM 2016, 1317–1322, DOI 10.1109/ICDM.2016.0179. The software is TDAmeritrade/stumpy, version 1.14.1 of 8 February 2026. Its LICENSE.txt is the 3-Clause BSD licence with a trademark line, which is why GitHub shows no licence.
Status. Not applicable. A trading rule built on motifs carries a vast search, and neither paper shows that motifs in prices predict anything. The library can be used without look-ahead, but only with care. Use the left matrix profile, read at the end of each window, and FLOSS rather than FLUSS. Its discords could flag odd stretches in the data, but not tell a bad tick from a crash. Don't depend on it now.
Read. Read on 2026-11-28. I read the JOSS paper in full, two pages. I read the abstract, method and complexity of Yeh et al. (2016), and its experiments in outline, from the extended version at cs.ucr.edu, 10 pages. Through the GitHub API at tag v1.14.1, I read LICENSE.txt, the left and right outputs in stumpy/stump.py, and stumpy/floss.py. I didn't read stumpi, scrump or the tutorials, and I didn't run it.
Summary
Claim. The matrix profile is "a vector that represents the distances between all subsequences within a time series and their nearest neighbors". Yeh et al. say their algorithm "is exact, providing no false positives or false dismissals". They add that it is "simple and parameter-free", and needs space "just O(n) with a small constant factor".
What the code does.
stump. For each subsequence of length m, the z-normalised distance to its nearest match, and that match's index. For self-joins it also returns "the top-1 left matrix profile" and the right one. The left profile looks only at matches that start earlier. The docstring notes that "left and right matrix profiles are only available for self-joins". An exclusion zone stops a subsequence from matching itself.fluss. It finds regime changes from the matrix profile index. It counts the "arcs" from each subsequence to its nearest match, and finds the points that few arcs cross. It calls_cacwithbidirectional=True, so arcs go both forward and back in time.floss. The streaming form. It slides a window, uses "the right matrix profile index", and updates as data arrive.- The edges.
_cacsets the arc curve to 1.0, meaning "no change", for the first and lastL * excl_factorpoints. The defaultexcl_factoris 5, and L is the subsequence length. - Normalisation. Distances are z-normalised by default, so a match is a match of shape.
Findings. Yeh et al. report speed and exactness, and show uses such as finding events in seismology data. The JOSS paper reports no results. Neither paper tests prices.
Where the claims go beyond the evidence
"Parameter-free" isn't free in practice. The join itself needs no threshold, but every use of it needs a window length m, and motif and discord rules add thresholds. Each choice is a trial (#7).
No evidence that motifs predict prices. The papers show that the profile finds repeated shapes. A shape that repeated in the past is a pattern found by comparing every subsequence with every other one. In a random walk, that search always finds close pairs. Without a test after the search, a motif is not a signal (evidence-based-technical-analysis.md, #118).
z-normalisation discards what matters for trading. Two windows match if their shapes match, whatever their size. A 1% rise and a 20% rise can be nearest neighbours, though they mean very different profits. The library's non-normalised option keeps size, and a trading use would need it.
The left profile is causal only when read late. The profile at index i describes the window from i to i + m − 1. Its value is known only when that window ends, m − 1 steps after i. A backtest that reads it at i looks m − 1 steps ahead.
FLUSS looks both ways, and FLOSS is slow by design. FLUSS's arcs go into the future, so its regime changes are found with hindsight. FLOSS removes that, but its arc curve is fixed at "no change" for the last 5L points. With a window of 20 days, that is a delay of about 100 days before a change can show.
Credit. The method is exact, and the paper says plainly what it is fast at. The library exposes the left and right profiles that a causal use needs.
Use in this repo
Count the search. A rule that trades a motif has searched every pair of windows, at each window length and threshold tried. It enters the trial ledger at that size, and the selection tests charge for it (#7, #11). The honest test is out of sample, on a later period, with the window and threshold fixed before.
Use only past matches, read at the window's end. For a feature at time t, take the left profile of the window that ends at t, built from data up to t. An expanding computation with stumpi, updated one point at a time, does that. The harness's oracle can't catch a profile computed on the whole series, because the leak is inside the strategy's own code (#87).
Discords flag odd shapes, not bad data. A discord is a window with no close match. A crash is one, and so is a bad tick. A data check still needs a second source to tell them apart (#181, tsmoothie.md).
Regime changes: compare with a filter. FLOSS's delay of about five window-lengths is a cost to set against a Markov-switching filter's (hmmlearn.md, #139). Both should be scored on the same planted changes in synthetic data (#5).
Similar isn't causal. An AB-join finds when two series move alike. That is similarity, not a cause, and it is no substitute for the dependency graph's tests (#187).
The cost is low. The join is O(n²) in time with O(n) memory. Ten years of hourly bars is under 90,000 points, which a laptop handles. If a motif study is ever worth running, an optional extra would do.