A time series discord is the subsequence of a given length whose distance to its nearest non-self match is the largest in the whole series. In anomaly detection, discord discovery provides a parameter-light definition of an unusual shape: the segment that looks least like anything else in the data.
The concept was introduced in 2005 together with the HOT SAX search algorithm, and it has since become one of the most reliable baselines for time series anomaly detection. Its appeal lies in needing only one main parameter, the subsequence length, and no training labels or model of normal behavior.
How a discord is defined
Discord discovery slides a window of length m across a series of length n and treats every window as a candidate subsequence. For each candidate, it finds the closest other subsequence, excluding trivial matches that overlap the candidate itself; the distance to that closest match is the candidate’s nearest-neighbor distance.
The top discord is the candidate with the maximum nearest-neighbor distance. Extensions define the top-k discords as the k largest such distances with non-overlapping locations, and the k-th nearest-neighbor discord, which uses the distance to the k-th match to resist repeated anomalies.
Most modern work measures similarity with the z-normalized Euclidean distance, which compares shapes regardless of offset and amplitude. The exclusion zone that removes trivial matches is usually set to between m/4 and m/2 samples on each side of the candidate.
The core quantities used to define and rank discords are listed below.
| Quantity | Meaning | Typical setting |
|---|---|---|
| Subsequence length m | Width of the pattern being compared | One period or event duration |
| Exclusion zone | Region ignored as trivial matches | m/4 to m/2 samples |
| Distance measure | How shapes are compared | z-normalized Euclidean |
| Nearest-neighbor distance | Gap to the closest non-self match | Discord score |
| Number of discords k | How many anomalies to report | 1 to 10 in practice |
Algorithms for discord discovery
A brute-force search compares every pair of subsequences and costs O(n squared times m) operations, which becomes impractical for long series. Practical algorithms either prune candidates early or compute all nearest-neighbor distances at once with fast exact methods.
HOT SAX orders candidates with a symbolic SAX representation so that likely discords are examined first and ordinary ones are abandoned as soon as a close match appears. Later methods compute the matrix profile, whose maximum value directly marks the top discord, and newer algorithms extend the search to all lengths or to streaming data.
The following table compares the best-known algorithms and their intended use.
| Algorithm | Approach | Strength | Limitation |
|---|---|---|---|
| Brute force | All-pairs comparison | Exact and simple | Quadratic cost |
| HOT SAX | Symbolic ordering with early abandoning | Fast on typical data | Sensitive to SAX parameters |
| DRAG | Range-based disk-aware pruning | Handles data larger than memory | Needs a distance threshold |
| Matrix profile methods | Exact all-subsequence nearest neighbors | Gives all scores at once | Fixed length per run |
| MERLIN | Efficient search over a length range | Removes guessing of m | More computation per range |
| DAMP | Online left-discord search | Streaming and very long series | Only looks at past data |
How discords relate to other anomaly types
A discord is a subsequence anomaly, so it captures unusual shapes rather than single extreme values. It overlaps with the classic categories of point, contextual and collective anomalies, but it does not map neatly onto any one of them.
| Concept | What is unusual | Detected by discords |
|---|---|---|
| Point anomaly | A single extreme value | Only if it distorts the local shape |
| Contextual anomaly | A normal value at the wrong time | Often, when the window covers the context |
| Collective anomaly | A sequence that is abnormal as a whole | Yes, this is the main target |
| Change point | A lasting shift in behavior | Only the transition, not the new regime |
| Forecast residual anomaly | Deviation from a model prediction | Different method, often complementary |
Compared with forecasting-based anomaly detection or deep models such as the Anomaly Transformer, discords need no training phase and no learned model. Benchmark studies have repeatedly found that simple discord baselines remain competitive with far more complex neural methods on many univariate datasets.
Choosing parameters in practice
The subsequence length is the decision that matters most. It should match the duration of the expected anomalous event or one natural cycle of the signal, such as a heartbeat, a machine cycle or a day of sensor readings.
The decision table below links common situations to parameter choices.
| Situation | Recommended setting | Reason |
|---|---|---|
| Clear periodic signal | m equal to one period | Compares whole cycles |
| Unknown event duration | Search a range of lengths | Avoids missing short or long events |
| Repeated identical faults | Use the k-th nearest neighbor | Prevents twin anomalies hiding each other |
| Continuous monitoring | Online left-discord search | Scores each point as it arrives |
| Amplitude matters | Skip z-normalization | Keeps level differences visible |
Thresholding is a separate step. A discord score is a relative ranking, so operational systems either report the top few discords for review or compare scores against a dynamic threshold learned from historical values.
Limitations and common pitfalls
The definition is elegant but has well-known blind spots. Each one follows from the rule that a discord must be far from its single nearest match.
- Twin freak problem: two similar anomalies match each other and both receive low scores.
- Wrong window length: a window far shorter or longer than the event dilutes the anomaly.
- Flat or noisy segments: z-normalizing near-constant data amplifies noise into false discords.
- Multivariate data: a single-channel definition misses anomalies spread across sensors.
- Always one winner: every series has a top discord, even when nothing is truly abnormal.
The last point is the most frequent misunderstanding. A top discord is only a candidate, and its score must be compared with the normal range of scores before anyone treats it as a real fault.
The idea in brief
Picture a long recording of a heartbeat. Almost every beat looks like many other beats. Now cut the recording into short pieces and find, for each piece, its most similar partner.
The piece whose best partner is still a poor match is the discord. It is the part of the recording that has no look-alike. That makes it the most likely place where something unusual happened. No one has to teach the method what normal looks like, because normal is simply what repeats.
A practical scenario
A reliability engineer at a water utility monitors a pump station that records motor current every second. A normal pumping cycle lasts about 90 seconds, and a month of data contains roughly 2.6 million readings.
The engineer computes the matrix profile with a subsequence length of 90 samples and reviews the top five discords. Four correspond to scheduled maintenance stops, which are recorded in the work log. The fifth is a cycle with a brief current spike followed by a slow decay, a shape that appears nowhere else in the month.
Inspection reveals a partially blocked impeller that caused the motor to strain at start-up. The pump is cleaned during the next planned shutdown, and the utility avoids an unplanned outage. The team then adds the k-th neighbor variant so that repeated blockages would not mask each other.