CUSUM (Cumulative Sum) is a sequential analysis technique for change point detection that monitors the cumulative sum of deviations of observed values from a target mean or expected value. It triggers an alert when this cumulative sum exceeds a predefined threshold, signaling a statistically significant shift in the process being monitored. The algorithm is highly sensitive to small, persistent drifts, making it a core component in online learning architectures and production model monitoring systems for detecting concept drift.
Glossary
CUSUM (Cumulative Sum)

What is CUSUM (Cumulative Sum)?
CUSUM is a foundational statistical process control and change point detection algorithm used to monitor data streams for significant shifts in their underlying distribution.
In machine learning operations, CUSUM is applied to monitor key performance indicators like prediction error rates or data distribution statistics. When a change point is detected, it can trigger automated alerts for model retraining or investigation. Its efficiency stems from its recursive calculation, requiring only the current observation and the previous cumulative sum, making it ideal for real-time data streams. This places CUSUM within the broader category of statistical process control methods essential for maintaining continuous model learning systems.
Key Features of CUSUM
CUSUM (Cumulative Sum) is a foundational sequential analysis technique for detecting shifts in a process mean. Its core features make it highly effective for real-time monitoring in machine learning and data streams.
Sequential Sensitivity
CUSUM is designed for sequential analysis, meaning it processes data points one at a time as they arrive. Unlike batch methods, it does not require a fixed sample size. It cumulatively sums deviations from a target value (e.g., a process mean), allowing it to detect small, persistent shifts that would be missed by point-in-time tests. This makes it ideal for real-time monitoring of model performance metrics or data quality in production.
Cumulative Deviation Accumulation
The algorithm's power comes from its memory. For each observation x_t, it calculates S_t = max(0, S_{t-1} + (x_t - μ) - k), where μ is the target mean and k is a slack parameter. This formula ensures that only deviations in one direction are accumulated; random noise tends to cancel out, while a systematic drift causes S_t to grow monotonically. This accumulation amplifies subtle signals over time, leading to high detection power for small shifts.
Threshold-Based Alerting
CUSUM triggers an alert when the cumulative sum S_t exceeds a pre-defined decision threshold h. Setting h controls the trade-off between:
- False Alarm Rate (Type I Error): A low
hincreases sensitivity but may cause alerts from normal noise. - Detection Delay (Type II Error): A high
hreduces false alarms but delays the detection of an actual shift. This threshold is typically set based on the desired Average Run Length (ARL) when the process is in control, providing a statistically grounded alerting mechanism.
Parameterization: Slack (k) & Threshold (h)
CUSUM performance is tuned via two key parameters:
- Slack Parameter (k): Often set to half the minimum detectable shift. If you want to detect a shift of
2σ,kis typicallyσ. It determines the algorithm's sensitivity; a smallerkmakes it sensitive to tiny shifts but increases noise accumulation. - Threshold (h): Determines the alerting confidence. It is derived from the target in-control ARL. For example, an ARL of 1000 might correspond to
h = 5in standardized units. These parameters allow engineers to tailor CUSUM for specific quality control or concept drift detection scenarios.
Two-Sided Detection (CUSUM+ & CUSUM-)
Standard CUSUM detects upward shifts. For full monitoring, a two-sided CUSUM is used, running two parallel algorithms:
- CUSUM+ (Upper):
S_t^+ = max(0, S_{t-1}^+ + x_t - μ - k)for detecting increases. - CUSUM- (Lower):
S_t^- = max(0, S_{t-1}^- + μ - k - x_t)for detecting decreases. An alert is raised if either cumulative sum exceedsh. This is critical for monitoring metrics like model accuracy or API latency, where both positive and negative drifts can be problematic.
Applications in ML & Data Streams
CUSUM is a workhorse algorithm for production ML observability and data pipeline monitoring. Key applications include:
- Concept Drift Detection: Monitoring the error rate of a deployed model for sudden increases.
- Data Quality Monitoring: Detecting shifts in the mean or variance of feature distributions in real-time.
- Anomaly Detection in Metrics: Identifying persistent deviations in system KPIs like request latency or throughput.
- Online A/B Testing: Can be adapted to monitor the cumulative difference in performance between two model variants for early stopping.
How CUSUM Works: The Algorithm
The CUSUM (Cumulative Sum) algorithm is a foundational sequential analysis technique for detecting shifts in the mean of a process by monitoring the cumulative sum of deviations from a target value.
The CUSUM algorithm operates by calculating a running cumulative sum of the differences between observed values and a predefined target or reference mean. For each new data point, the algorithm updates two statistics: the positive deviation sum (S_high) and the negative deviation sum (S_low), which are reset to zero after crossing a decision threshold (h). This threshold is calibrated based on the desired Average Run Length (ARL), balancing the trade-off between false alarms and detection speed. When either cumulative sum exceeds this threshold, a change point is signaled, indicating a statistically significant shift in the process mean.
The algorithm's core mechanism is its recursive update rule: S_t = max(0, S_{t-1} + (x_t - μ_0 - k)), where μ_0 is the target mean and k is the allowance (or slack), typically half the magnitude of the shift one wishes to detect. This formulation makes CUSUM optimal for detecting small, persistent mean shifts, as it accumulates small deviations that other methods might ignore. Its memory property—retaining information from past deviations until a reset—provides high sensitivity and is a key differentiator from simpler Shewhart control charts. The algorithm is widely implemented in statistical process control (SPC) and online learning systems for concept drift detection.
CUSUM Use Cases in Machine Learning
CUSUM (Cumulative Sum) is a foundational sequential analysis technique for detecting shifts in statistical processes. In machine learning systems, it is a critical tool for monitoring model health and data stability in real-time.
Concept Drift Detection
CUSUM is a primary statistical method for concept drift detection in online learning systems. It monitors a model's performance metric (e.g., prediction error rate, loss) or input data statistics over time.
- How it works: It calculates the cumulative sum of deviations between observed values and an expected baseline (e.g., a target error rate). A sustained positive sum indicates a significant upward drift.
- Key advantage: It is sensitive to small, persistent shifts that might be missed by point-in-time thresholds, making it ideal for early warning systems.
- Example: Monitoring the accuracy of a fraud detection model; CUSUM triggers a retraining alert when the cumulative sum of false negative deviations exceeds a control limit.
Data Distribution Shift Monitoring
Beyond model performance, CUSUM monitors the input data distribution for covariate shift. This is crucial for ensuring the production data matches the model's training assumptions.
- Application: It can be applied to summary statistics of feature values, such as the mean or variance of a critical variable. For multivariate monitoring, features are often monitored independently or via a engineered summary statistic.
- Real-time alerting: A drift in a key feature's distribution, detected by CUSUM, can alert engineers to investigate broken data pipelines or changing user behavior before model performance degrades.
- Example: An e-commerce recommendation model monitors the average
user_session_length. A CUSUM-detected increase could indicate bot traffic or a UI change, signaling the need for model review.
Anomaly Detection in Model Logs
CUSUM serves as a core algorithm for online anomaly detection within telemetry and log streams from ML systems.
- Target signals: It can monitor inference latency, system throughput, memory usage, or exception rates from model serving endpoints.
- Proactive operations: By detecting subtle increases in latency or error counts, SRE and MLOps teams can be alerted to infrastructure issues (e.g., failing GPU, memory leak) before they cause full service outages.
- Implementation: Often used in conjunction with other detectors. For instance, a spike might be caught by a simple threshold, while a gradual performance degradation is flagged by CUSUM.
Trigger for Automated Retraining
In automated MLOps pipelines, CUSUM provides a statistically rigorous trigger to initiate model retraining or pipeline remediation.
- Closed-loop systems: The CUSUM control chart is integrated into the model monitoring service. When its test statistic crosses a pre-defined threshold, it sends an event to an orchestration system (e.g., Apache Airflow, Kubeflow).
- Efficiency: This moves beyond scheduled retraining to an event-driven paradigm, conserving computational resources and ensuring models are only updated when a statistically significant drift is confirmed.
- System Design: The threshold (or decision interval) is a key hyperparameter, balancing sensitivity to drift against the cost of false alarms and unnecessary retraining.
Comparison with Other Detectors
CUSUM is one tool among several for change detection. Understanding its trade-offs is key for system design.
- Vs. ADWIN (Adaptive Windowing): ADWIN dynamically adjusts its window size, while CUSUM uses all data since the last reset. CUSUM is often more sensitive to small sustained shifts; ADWIN may adapt faster to abrupt changes followed by stability.
- Vs. Shewhart Control Charts: Shewhart charts (using rules like "3-sigma") are better at detecting large, sudden shifts. CUSUM excels at detecting smaller, persistent drifts.
- Vs. Page-Hinkley Test: This is a variant of CUSUM designed to be more robust to outliers. The Page-Hinkley test includes a forgetting factor, making it suitable for detecting drifts in non-stationary environments where the baseline may slowly change.
Implementation in Streaming Architectures
Deploying CUSUM effectively requires integration into modern stream processing frameworks.
- Stateful Operation: CUSUM is inherently stateful, maintaining a running cumulative sum. This aligns perfectly with stateful stream processors like Apache Flink, Apache Spark Structured Streaming, or ksqlDB.
- Scalability: For high-volume feature monitoring, CUSUM statistics can be computed in parallel per feature or per model segment (e.g., per country) using map-reduce or partitioned stream topologies.
- Lambda/Kappa Architecture: CUSUM operates in the speed layer of a Lambda Architecture or within the single stream-processing engine of a Kappa Architecture, providing real-time detection while historical analysis may run in batch.
CUSUM vs. Other Change Detection Methods
A technical comparison of CUSUM's characteristics against other primary statistical and machine learning-based methods for detecting shifts in data streams, highlighting trade-offs in sensitivity, computational cost, and assumptions.
| Feature / Metric | CUSUM (Cumulative Sum) | Statistical Process Control (SPC) Charts | Machine Learning Classifiers (e.g., Isolation Forest) |
|---|---|---|---|
Core Detection Principle | Cumulative sum of deviations from a target | Rule-based thresholds on individual/group statistics (e.g., Shewhart rules) | Learned model of "normal" vs. "anomalous" patterns |
Primary Use Case | Detecting small, persistent mean shifts in sequential data | Monitoring process stability; detecting large, sudden shifts | Detecting complex, non-parametric anomalies in high-dimensional data |
Detection Sensitivity | High for small, sustained drifts | Low for small drifts; high for large, abrupt shifts | Variable; depends on model and training data |
Assumptions on Data | Assumes i.i.d. observations; known or estimated target mean and variance | Assumes i.i.d. or weakly correlated data; known control limits | Minimal parametric assumptions; requires representative training data |
Memory & State | Maintains a single cumulative sum statistic | Typically stateless per point (except for moving averages) | Requires storing the trained model parameters; stateful |
Computational Cost (per point) | O(1); very low (add/subtract and compare) | O(1) to O(w) for moving windows; low | O(n_features) to O(n_samples); moderate to high |
Explainability of Alert | High; alert triggered by cumulative deviation exceeding threshold | High; specific rule violation (e.g., point beyond 3σ) is clear | Low to moderate; often a "black-box" anomaly score |
Adaptation to Drift | None; static target parameters. Requires reset after detection. | Limited; control limits are typically static. | Can be retrained; some online variants exist (concept drift). |
Common Implementation Context | Industrial process monitoring, network intrusion detection, financial surveillance | Manufacturing quality control, operational metrics dashboards | IT system monitoring, fraud detection, predictive maintenance |
Frequently Asked Questions
CUSUM (Cumulative Sum) is a foundational sequential analysis technique for detecting changes in data streams. These FAQs address its core mechanics, applications in machine learning, and practical implementation considerations.
CUSUM (Cumulative Sum) is a sequential analysis algorithm for change point detection that monitors the cumulative sum of deviations from a target value or process mean. It works by calculating a running sum of the differences between observed values and a reference. When this cumulative sum exceeds a pre-defined decision threshold, it triggers an alert, signaling a statistically significant shift in the underlying process. The algorithm is highly sensitive to small, persistent drifts because small deviations accumulate over time, making them detectable.
Mathematical Formulation: For a sequence of observations (X_t), the CUSUM statistic (S_t) is typically defined as: [ S_t = \max(0, S_{t-1} + (X_t - \mu_0) - k) ] where (\mu_0) is the target mean, and (k) is a slack parameter (often half the shift one wishes to detect). An alarm is raised when (S_t > h), where (h) is the threshold.
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
CUSUM is a foundational technique within the broader ecosystem of online learning and change detection. These related concepts are essential for building robust, adaptive systems.
Concept Drift Detection
The overarching problem that CUSUM addresses. Concept drift refers to a change in the statistical properties of the target variable a model is trying to predict, relative to the input data, over time. CUSUM is one statistical method for detecting such shifts, particularly in the mean of a process. Other methods include:
- ADWIN (Adaptive Windowing): Dynamically adjusts window size to find a stable period.
- Page-Hinkley Test: Similar to CUSUM but uses a forgetting factor.
- Statistical Process Control (SPC) charts: The broader industrial quality control family CUSUM belongs to.
Online Learning
The machine learning paradigm where CUSUM is often deployed. In online learning, a model updates its parameters sequentially with each new data point or mini-batch, without storing or revisiting the entire historical dataset. This is essential for streaming applications. CUSUM monitors the model's performance or input data within this stream to trigger adaptation.
Key characteristics:
- Single-pass over data.
- Bounded memory footprint.
- Immediate, incremental updates via algorithms like Stochastic Gradient Descent (SGD).
ADWIN (Adaptive Windowing)
A direct alternative and often complementary algorithm to CUSUM for change detection in data streams. ADWIN maintains a variable-length window of recently seen items. It continuously tests, using the Hoeffding bound, whether the average of two sub-windows within the main window differs significantly. If a change is detected, the older portion of the window is dropped.
Comparison to CUSUM:
- ADWIN is parameter-light and provides theoretical guarantees on false positive/negative rates.
- CUSUM is optimal for detecting known-magnitude shifts in the mean and is often faster to signal.
Regret Minimization
The theoretical framework for analyzing online learning algorithms, which provides context for why detecting change (with CUSUM) is critical. Regret is defined as the cumulative loss difference between the predictions of the online algorithm and the best fixed decision made in hindsight. The goal of online learning is to design algorithms with sublinear regret, meaning the average regret per round goes to zero.
A sudden concept drift can cause regret to spike. Effective change-point detection like CUSUM allows the algorithm to "reset" or adapt its strategy, bounding long-term regret in non-stationary environments.
Stateful Stream Processing
The systems engineering context for deploying CUSUM. Stateful stream processing frameworks (e.g., Apache Flink, Apache Samza) enable applications to maintain and update an internal state across a sequence of events. Implementing CUSUM as an operator in such a framework is a common pattern.
How it works:
- The operator maintains the running cumulative sum S_t as its internal state.
- For each new event (e.g., a prediction error), it updates S_t.
- It compares S_t to a threshold, emitting an alert record if exceeded.
- State may be reset upon an alert or via a decay factor.
Statistical Process Control (SPC)
The industrial quality control discipline from which CUSUM originates. SPC uses statistical methods to monitor and control a process to ensure it operates at its full potential. CUSUM charts are one of several control charts used to detect small, persistent shifts in a process mean more quickly than Shewhart (e.g., X-bar) charts.
Related SPC Charts:
- Shewhart Control Charts: Detect large shifts using rules applied to the last sample.
- EWMA (Exponentially Weighted Moving Average) Charts: Weight recent observations more heavily, sensitive to smaller shifts.
- CUSUM Charts: Optimal for detecting a sustained shift of a specified size.

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us