Time series anomaly detection is the task of identifying observations, intervals or entire sequences in time-ordered data that deviate from the behavior expected given their temporal context. Within anomaly detection in artificial intelligence, it differs from static outlier detection because order, trend, seasonality and autocorrelation define what counts as normal.
Typical inputs are sensor readings, server metrics, financial transactions and physiological signals. The output is usually an anomaly score per time step or window, which a thresholding rule turns into alerts for operators or downstream systems.
Types of anomalies in time series
Anomalies in temporal data fall into three classic categories, and the category determines which detection methods can find them. A value can be abnormal on its own, abnormal only at a given time, or normal individually but abnormal as part of a sequence.
| Anomaly type | Description | Example |
|---|---|---|
| Point anomaly | Single value far from the normal range | Temperature sensor reads 900 degrees for one sample |
| Contextual anomaly | Value normal globally but not at that time | High office power use at 3 a.m. on Sunday |
| Collective anomaly | Sequence abnormal as a whole | Flat heartbeat signal lasting several seconds |
| Level shift or change point | Persistent change in mean or variance | Latency baseline doubles after a deployment |
| Pattern or shape anomaly | Unusual waveform shape | Distorted vibration cycle in a rotating machine |
A practical distinction separates univariate series, where one signal is monitored, from multivariate anomaly detection, where the anomaly may only appear in the relationship between signals, for example two correlated sensors suddenly diverging.
How detection methods model normal behavior
Every method builds an implicit or explicit model of normal behavior and scores deviations from it. The main families differ in how they represent normality and which anomaly types they handle well.
| Family | How it scores anomalies | Representative methods |
|---|---|---|
| Statistical decomposition | Residual after removing trend and seasonality | STL with robust z-scores, Seasonal hybrid ESD |
| Forecasting-based | Error between prediction and observation | ARIMA, exponential smoothing, LSTM forecasters |
| Reconstruction-based | Reconstruction error of a learned compression | LSTM autoencoders, variational autoencoders |
| Distance and subsequence | Distance to nearest similar window | Matrix profile, time series discords |
| Window-based tabular | Outlier score on extracted window features | Isolation forest, local outlier factor |
| Transformer-based | Attention or association discrepancy | Anomaly Transformer |
Forecasting-based detection is often the most interpretable approach: the model predicts the next value with a prediction interval, and a point outside the interval is flagged. Matrix profile methods are strong for finding discords, the subsequences least similar to any other subsequence, without training a model.
Thresholds, windows and streaming operation
Turning scores into alerts is frequently harder than computing the scores. A static threshold rarely works on real data because noise levels change with load, season and equipment age. Dynamic thresholding sets limits from a rolling estimate of the score distribution, for example a robust median and median absolute deviation over recent windows.
Design decisions about windows and timing have a large effect on results. The table below lists the parameters that most often require tuning.
| Parameter | Typical setting | What it affects |
|---|---|---|
| Window length | One to several seasonal periods | Which anomaly durations are detectable |
| Threshold rule | Robust z-score of 3-5 or a percentile | Trade-off between recall and false alarms |
| Training period | Several full seasonal cycles | Quality of the learned baseline |
| Retraining frequency | Daily to monthly | Adaptation to concept drift |
| Alert suppression | Minimum duration or count | Reduces flapping and duplicate alerts |
In streaming settings, detectors must score each new point with bounded latency and memory. Online variants of decomposition and forecasting models, as well as robust random cut forest, are designed for this mode and update incrementally rather than retraining from scratch.
Evaluating time series anomaly detectors
Evaluation is notoriously difficult and easy to inflate. Labels are scarce, anomalies are rare and many are long intervals rather than single points. The widely used point-adjust protocol, which counts an entire anomalous segment as detected if any single point is flagged, can make even random scores look strong.
- Prefer range-aware or event-based metrics that reward early detection and penalize fragmented alerts.
- Report false alarms per day alongside precision and recall, because operators experience alert volume directly.
- Benchmarks such as the Numenta Anomaly Benchmark and several popular multivariate datasets contain labeling flaws, so results should be checked on the target data.
- Always compare against simple baselines, such as a seasonal naive forecast with a robust threshold, which remain surprisingly competitive.
Common pitfalls in practice
Most failures in production come from data and process issues rather than model choice. The table below links frequent symptoms to their causes and fixes.
| Symptom | Likely cause | Fix |
|---|---|---|
| Alerts every Monday morning | Unmodeled weekly seasonality | Add weekly component or seasonal baseline |
| Detector misses slow degradation | Baseline adapts too quickly | Use longer windows or change point tests |
| Bursts of alerts after outages | Anomalies contaminating training data | Exclude or downweight labeled incidents |
| Spikes from missing data | Gaps filled with zeros | Mark gaps explicitly or interpolate |
| Many correlated alerts | Per-metric detection without grouping | Aggregate alerts or use multivariate models |
In plain words
Many systems record numbers over time. Examples are room temperature, website visits or a heart rate. These numbers usually follow a regular rhythm. They rise in the morning and fall at night, or they repeat every week.
Time series anomaly detection learns that rhythm and raises a flag when the numbers break it. A busy shop at noon is normal. The same crowd at midnight is strange. The key point is context: a value is judged by when it happens, not only by how big it is.
A real-world example
A regional water utility monitors flow and pressure sensors across its distribution network every minute. Demand follows a strong daily cycle, with peaks around breakfast and evening and a minimum between 2 and 4 a.m., plus a weekly pattern and slow seasonal changes.
The utility builds a forecasting-based detector for each district. A seasonal model trained on eight weeks of data predicts the expected flow with a prediction interval, and night-time flow receives special attention because unexplained flow at night usually indicates leakage rather than consumption. Alerts fire only when the residual exceeds a dynamic threshold for at least 30 consecutive minutes.
Within the first months, the detector identifies a district where minimum night flow rose by about 15 percent over three days. Crews locate a burst underground pipe that had not surfaced, repairing it weeks earlier than customer complaints would have revealed it and reducing water losses.