Segmented Confidence Sequences for Anomaly Detection
- Segmented Confidence Sequences (SCS) is an online, unsupervised framework that uses data-driven segmentation to construct statistically principled confidence intervals in locally stationary segments.
- It applies both Hoeffding-style and empirical standard deviation methods to adaptively set thresholds for anomaly detection while controlling for time-uniform Type I errors.
- The framework improves reliability over fixed thresholds, as demonstrated by enhanced true positive rates in scenarios such as sensor monitoring and manufacturing process control.
Segmented Confidence Sequences (SCS) is an online, unsupervised framework devised for robust anomaly detection in nonstationary time series. SCS employs statistically principled confidence sequences within locally stationary segments, where the segmentation is data-driven and adapts to evolving regimes. The construction yields locally adaptive thresholds maintaining time-uniform Type I error control, thereby improving reliability over fixed or globally adaptive thresholds in the presence of regime shifts, concept drift, or multi-scale distributional changes (Li et al., 8 Aug 2025).
1. Definitions and Mathematical Framework
Let denote a stream of real-valued anomaly-scores (such as reconstruction errors), indexed by . Each is assumed bounded: . The timeline is partitioned into non-overlapping segments with breakpoints , so segment covers . Within each segment , define the local sample mean where 0 and 1.
A confidence sequence (CS) for the (unknown) segment mean 2 is a sequence of intervals 3 constructed so that
4
where 5 is the error allocated to segment 6, with 7. An anomaly at time 8 is flagged if 9 lies outside 0 for its current segment and, optionally, also fails a global percentile filter.
2. Construction of Confidence Sequences and Segmentation
2.1. Confidence Sequence Formulas
For 1 and error 2 per segment, the nonparametric Hoeffding-style confidence sequence for 3 at time 4 is
5
Alternatively, use empirical standard deviation 6 and a scaling coefficient 7:
8
with 9 chosen by threshold-dependent rules. Then set 0, 1.
2.2. Segmentation Algorithms
Two segmentation strategies are provided:
- APCA (Adaptive Piecewise Constant Approximation):
- For a window 2, candidate splits at 3 minimize 4.
- Splits accepted if 5.
- Segmentation halts at minimal segment length or if improvement is insufficient. For flat regions (coefficient of variation 6), segments default to size 7.
- K-means Clustering on Sliding-Window Features:
- Feature extraction: mean, std, median, and skewness per window.
- Features normalized and clustered into 8 via K-means; failures result in single-segment treatment.
2.3. Composite Anomaly Detection Rule
Anomaly at 9 in segment 0 is triggered if 1 or 2. Optionally, a global percentile filter requires 3 where 4 is the 5-th percentile (e.g., 6) of training residuals.
3. Statistical Guarantees
SCS inherits its statistical accuracy from nonparametric confidence-sequence theory [Howard et al., 2021]. For independently sampled 7 in a segment, the constructed confidence sequence intervals 8 satisfy
9
and by a union bound or error allocation,
0
Because segmentation depends only on past data, coverage properties are preserved via optional-stopping arguments, even if segmentation is adaptive.
4. Algorithmic Implementation
The SCS workflow, in high-level pseudocode, is as follows:
- Offline Segmentation: Segment data via APCA or K-means, as selected.
- Initialization: For each segment 1, initialize 2, 3, 4 empirical std of a training window.
- Online Update: For each 5:
- Assign segment 6 by 7.
- Update statistics (8, 9, 0).
- Compute bound width by Hoeffding or empirical std formula.
- Flag anomaly if 1 outside 2 and, if enabled, 3 percentile threshold.
Computational Complexity:
- Segmentation: APCA is worst-case 4, typically 5 with pruning; K-means is 6 per iteration on windowed features.
- Online update: 7 per data point.
- Memory: Requires storing segment boundaries and per-segment aggregates.
5. Parameterization and Operational Considerations
- Confidence Level (8): Common choices are 0.05 or 0.01. Lower 9 yields wider bounds, fewer false alarms, and lower sensitivity.
- APCA Improvement Thresholds: Typical values are 0.7 for high variance, 0.5 for moderate variance. Minimum segment length of 0 or 1.
- Boundedness: Enforce or approximate 2 by truncation or winsorization.
- Empirical 3 Updates: Can employ Welford’s algorithm for online updates.
- Global Percentile Filter: Values like 4 provide robustness against local fluctuations; can be disabled to maximize recall at the expense of precision.
- Assumptions: Within each segment, scores are approximately stationary and independent (or weakly dependent).
6. Empirical Benchmarks and Comparative Results
Evaluation was performed on 151 inline semiconductor sensor traces with approximately 10% defective wafers. The baseline used a fixed 99th-percentile residual threshold. Key SCS results are presented below (Δ relative to baseline):
| Method | ΔPrecision | ΔRecall | ΔF1-Score |
|---|---|---|---|
| SCS APCA (5) | –0.3282 | +3.9952 | +1.9074 |
| SCS KMEANS (6) | –0.3999 | +1.6643 | +0.9262 |
| SCS APCA (7) | –0.4290 | +6.1595 | +2.1289 |
| SCS KMEANS (8) | –0.4656 | +3.3286 | +1.4148 |
Anomaly counts at 9:
| Method | TP | TN | FP | FN |
|---|---|---|---|---|
| Baseline (99th pct) | 6 | 1608 | 12 | 137 |
| SCS APCA (0) | 30 | 1516 | 104 | 113 |
| SCS KMEANS (1) | 16 | 1556 | 64 | 127 |
Key findings include a fivefold increase in true positives with SCS APCA (2 vs 3), raising recall from ~4% to ~30%, and an F1-score roughly doubling relative to the baseline for 4 and more than doubling for 5. The percentile filter improves precision at the expense of recall, while K-means segmentation produces slightly less aggressive segmentation than APCA and avoids short segments in smooth series (Li et al., 8 Aug 2025).
7. Context, Related Work, and Applications
SCS provides statistically rigorous local adaptation for anomaly detection in nonstationary time series where global or fixed-threshold approaches are rendered inadequate by distributional drift or regime changes. The framework is unsupervised, suitable for settings with scarce labeled anomalies, and is designed for applications such as manufacturing process control, IT infrastructure monitoring, and sensor data streams.
SCS builds conceptually on the theory of confidence sequences for time-uniform, nonparametric inference [Howard et al., 2021], online segmentation methods such as APCA [Keogh et al., 2001], and builds upon work in sequential quantile estimation under concept drift [Wang et al., 2023]. Its guarantee of explicit, interpretable false alarm rates and empirically validated reliability makes it appropriate for high-stakes or automated monitoring scenarios (Li et al., 8 Aug 2025).