STUMPY Library
Modern time series analysis using Matrix Profiles. Automatically discover recurring patterns, detect anomalies, and identify market regime changes in price data. Created by TD Ameritrade.
Installation
Key Features
Matrix Profile
Find all recurring patterns in time series data
Motif Discovery
Automatically detect repeated patterns (motifs)
Discord Detection
Find anomalies and unusual price movements
Pan Matrix Profile
Multi-resolution analysis across different subsequence lengths
Semantic Segmentation
Split time series into meaningful regimes
GPU Acceleration
CUDA support for massive datasets
Code Examples
Installation
Install stumpy
Basic Matrix Profile
Compute matrix profile to find recurring price patterns
Find Recurring Patterns (Motifs)
Discover the most frequently occurring patterns
Detect Price Anomalies (Discords)
Find unusual price movements that differ from normal patterns
Market Regime Detection
Segment the market into different regimes
Best Practices
Choose Window Size Wisely
The subsequence length (m) determines what patterns you find — try multiple sizes
Normalize First
Z-normalize your data for better pattern matching across different price levels
Computational Cost
Matrix profiles are O(n²) — use GPU acceleration for large datasets
Interpretation Required
Raw matrix profiles need domain knowledge to interpret — combine with other analysis