Machine learning · Time series

Why a One-Line Baseline Does Well on Time Series Anomaly Detection Benchmarks: A Follow-up to Wu and Keogh

Why scoring each point by the size of its step does well on several anomaly detection benchmarks, and what that implies for comparisons against it.

Essay / 003
In this essay Contents

Abstract

Scoring each time point by the size of the step into it, ∣xt−xt−1∣|x_t-x_{t-1}|, matches or beats published deep learning detectors on several standard time series anomaly detection benchmarks. We derive when this score separates normal from abnormal points and what it cannot detect, and use these results to ask what a benchmark comparison against it can establish.

A note on audience. This post is written for undergraduates who have finished their introductory machine learning courses and are looking at research areas to work in. It assumes that background and introduces what is specific to time series anomaly detection along the way.

Diff on Standard Benchmarks

In time series anomaly detection, a method receives a sequence of measurements, such as requests per minute to a web service or a patient’s pulse, and assigns every time point a score; a threshold on the score marks points as anomalous. Benchmarks are collections of such series in which annotators have labelled the anomalous points, and methods are ranked by F1 against those labels.

In 2020, Wu and Keogh examined the most widely used benchmarks, including the Yahoo collection and the Numenta archive (NAB), and showed that a large fraction of their series can be solved by a single line of code: a simple formula plus a well-chosen threshold flags the labelled anomalies and little else [1]. Their conclusion was that much of the reported progress on these benchmarks may be illusory, since a benchmark on which a one-liner matches a deep model cannot measure what the deep model adds. They released the UCR anomaly archive as a replacement.

We study one of the simplest one-liners of this kind, which EasyTSAD [2], an open-source library that runs many detectors under a common protocol, calls Diff: st=∣xt−xt−1∣.s_t = |x_t - x_{t-1}|. Figure 1 shows how it fares in one of our EasyTSAD runs against thirteen other detectors, including Anomaly Transformer [3], DCdetector [4] and FCVAE [5]. Diff ranks first on Yahoo, NAB and TODS, second on AIOPS, third on WSD and fifth on UCR, the archive Wu and Keogh built to address these problems.

Figure 1. Diff against thirteen other detectors in one EasyTSAD run, on six benchmark collections. Each marker is one detector’s best F1 with point adjustment, averaged over the series in the collection. Not every detector finished on every collection, so the number compared differs by row.
Figure 1. Diff against thirteen other detectors in one EasyTSAD run, on six benchmark collections. Each marker is one detector’s best F1 with point adjustment, averaged over the series in the collection. Not every detector finished on every collection, so the number compared differs by row.

In this protocol each detector’s threshold is chosen per series to maximise F1 against the test labels, an optimistic choice applied to all detectors alike. The F1 is also computed after point adjustment: if any point inside a labelled anomalous segment is flagged, every point of that segment counts as detected [6].

Figure 2 looks at individual series, using plain pointwise F1 without point adjustment. On two Yahoo series, one threshold on Diff recovers the labels almost perfectly. On BIDMC1 from the UCR archive it fails badly. That series is a plethysmograph recording, the pulse wave of the blood, and its labelled anomaly is a premature ventricular contraction (an early heartbeat) that Wu and Keogh identified from an ECG recorded at the same time [1].

Figure 2. Diff on three series. Each block shows the series (blue), its labels (orange strip, 1 at labelled points), and the Diff score with the F1-maximising threshold (dashed); circles are flagged points, and the right column enlarges the grey stretch of the series panel. F1 is pointwise, with no point adjustment. (a) Yahoo A1 real_12, 2 labelled points, both flagged and nothing else, F1 1.00. (b) Yahoo A1 real_11, 19 labelled points, F1 0.97; the threshold lies near zero on this scale because the anomaly reaches 300,000 and normal steps are a few hundred. (c) UCR BIDMC1, a plethysmograph (pulse) recording, 200 labelled points, precision 0.26, recall 0.04, F1 0.06.
Figure 2. Diff on three series. Each block shows the series (blue), its labels (orange strip, 1 at labelled points), and the Diff score with the F1-maximising threshold (dashed); circles are flagged points, and the right column enlarges the grey stretch of the series panel. F1 is pointwise, with no point adjustment. (a) Yahoo A1 real_12, 2 labelled points, both flagged and nothing else, F1 1.00. (b) Yahoo A1 real_11, 19 labelled points, F1 0.97; the threshold lies near zero on this scale because the anomaly reaches 300,000 and normal steps are a few hundred. (c) UCR BIDMC1, a plethysmograph (pulse) recording, 200 labelled points, precision 0.26, recall 0.04, F1 0.06.

The derivation in Sections 2 to 4 accounts for the Yahoo series, and the information Diff discards, studied in Sections 5 and 6, accounts for the pulse recording. Sections 7 and 8 then use these results to examine evaluation, first the smallest error achievable from a given set of features and then the conditions under which a benchmark margin over Diff reflects a better detector.

Notation

A series is x0,x1,…x_0,x_1,\dots, one real number per time point. We write Δxt=xt−xt−1\Delta x_t=x_t-x_{t-1} for the step into point tt, and use the same notation for any sequence. EasyTSAD’s Diff score is s0=0,st=∣Δxt∣(t≥1).s_0 = 0,\qquad s_t = |\Delta x_t| \quad (t\ge1). It has no parameters, and a detector based on it flags tt when st>τs_t>\tau.

Benchmarks label points, but Diff responds to steps, so our analysis labels steps: Yt=1Y_t=1 means the step Δxt\Delta x_t is anomalous. A single-point spike at tt then has two anomalous steps, into and out of tt, while a jump to a new level has one. The two conventions differ for events that last many points, which Section 6 treats.

When a Threshold on Diff Is Exact

Write the series as xt=at+utx_t=a_t+u_t, where aa is the signal an annotator would call anomalous (a jump, a spike) and uu is what a healthy series does anyway, including trend, periodic structure and sensor noise. The split cannot be observed and serves only to describe the class of data on which Diff works. Assume that for every tt Yt=0⇒Δat=0,Yt=1⇒∣Δat∣≥J,∣Δut∣≤B.Y_t=0 \Rightarrow \Delta a_t = 0,\qquad Y_t=1 \Rightarrow |\Delta a_t| \ge J,\qquad |\Delta u_t| \le B. On a normal step, st=∣Δut∣≤Bs_t=|\Delta u_t|\le B. On an anomalous step, the nuisance can work against the jump but by at most BB, so by the reverse triangle inequality st=∣Δat+Δut∣≥J−Bs_t=|\Delta a_t+\Delta u_t|\ge J-B. Hence every threshold with B≤τ<J−BB\le\tau<J-B classifies every step correctly, and such a threshold exists if and only if J>2B.J > 2B . The argument uses no probability, so it also holds when the noise is dependent across time, as it usually is.

The constant 22 cannot be improved, because if J≤2BJ\le 2B, a normal step with Δut=J/2\Delta u_t=J/2 and an anomalous step with Δat=J\Delta a_t=J, Δut=−J/2\Delta u_t=-J/2 both produce Δxt=J/2\Delta x_t=J/2, and no rule that sees only this step separates them (Figure 4b).

What determines BB

Split the nuisance further into a baseline bb with ∣Δbt∣≤L|\Delta b_t|\le L and measurement error with ∣et∣≤ε|e_t|\le\varepsilon. Then ∣Δut∣≤∣Δbt∣+∣et∣+∣et−1∣≤L+2ε,|\Delta u_t| \le |\Delta b_t| + |e_t| + |e_{t-1}| \le L+2\varepsilon, and the condition becomes J>2L+4εJ>2L+4\varepsilon. Differencing replaces a baseline by its per-step slope LL, which is small for anything slow relative to the sampling rate, such as a daily cycle sampled every minute. It also counts the measurement error twice, and an error sequence alternating between ±ε\pm\varepsilon attains the bound (Figure 4c). Figure 3 shows a constructed example.

Figure 3. (a) A series x=a+b+ex=a+b+ex=a+b+e with a sinusoidal baseline (L=0.126L=0.126L=0.126) and uniform measurement error (ε=0.4\varepsilon=0.4ε=0.4), so B=0.926B=0.926B=0.926. The signal aaa (grey) has five anomalous steps of size at least J=3J=3J=3: two for the spike near t=60t=60t=60 and one for each of the three jumps. The strip shows YtY_tYt​. (b) Diff scores: every normal score is at most BBB and every anomalous score at least J−BJ-BJ−B, so any threshold in the hatched band is exact. (c) Misclassified steps as a function of τ\tauτ, on the same vertical axis. The error is zero on the whole band, and slightly below it because this realisation’s largest normal score happens to be under BBB.
Figure 3. (a) A series x=a+b+ex=a+b+e with a sinusoidal baseline (L=0.126L=0.126) and uniform measurement error (ε=0.4\varepsilon=0.4), so B=0.926B=0.926. The signal aa (grey) has five anomalous steps of size at least J=3J=3: two for the spike near t=60t=60 and one for each of the three jumps. The strip shows YtY_t. (b) Diff scores: every normal score is at most BB and every anomalous score at least J−BJ-B, so any threshold in the hatched band is exact. (c) Misclassified steps as a function of τ\tau, on the same vertical axis. The error is zero on the whole band, and slightly below it because this realisation’s largest normal score happens to be under BB.
Figure 4. (a) Attainable scores for a normal step and for an anomalous step of size exactly JJJ, with ∣Δut∣≤B|\Delta u_t|\le B∣Δut​∣≤B, as functions of J/BJ/BJ/B. The anomalous range is [max⁡(J−B,0), J+B][\max(J-B,0),\,J+B][max(J−B,0),J+B]. Exact thresholds (hatched) exist only for J>2BJ>2BJ>2B. (b) The collision at B=1B=1B=1, J=1.5J=1.5J=1.5. (c) The measurement-error step Δet\Delta e_tΔet​ for ete_tet​ alternating between ±ε\pm\varepsilon±ε, which attains 2ε2\varepsilon2ε at every step, and for independent uniform ete_tet​.
Figure 4. (a) Attainable scores for a normal step and for an anomalous step of size exactly JJ, with ∣Δut∣≤B|\Delta u_t|\le B, as functions of J/BJ/B. The anomalous range is [max⁡(J−B,0), J+B][\max(J-B,0),\,J+B]. Exact thresholds (hatched) exist only for J>2BJ>2B. (b) The collision at B=1B=1, J=1.5J=1.5. (c) The measurement-error step Δet\Delta e_t for ete_t alternating between ±ε\pm\varepsilon, which attains 2ε2\varepsilon at every step, and for independent uniform ete_t.

Random Noise

Sensor noise is rarely bounded, so we replace the bound BB by a tail condition. Fix a step and write Δxt=A+N\Delta x_t=A+N, with A=0A=0 on normal steps, ∣A∣≥J|A|\ge J on anomalous ones, and NN the nuisance step. At the midpoint threshold τ=J/2\tau=J/2, a normal step is misclassified only if ∣N∣>J/2|N|>J/2, and an anomalous one only if ∣A+N∣≤J/2|A+N|\le J/2, which again forces ∣N∣≥J/2|N|\ge J/2. So every error lies in the event {∣N∣≥J/2}\{|N|\ge J/2\}, whatever the dependence between AA, YY and NN.

If NN is centred and sub-Gaussian with variance proxy vv, meaning E eλN≤evλ2/2\mathbb{E}\,e^{\lambda N}\le e^{v\lambda^2/2} for all λ\lambda, the Chernoff bound gives Pr⁡[error]≤Pr⁡[∣N∣≥J/2]≤2exp⁡ ⁣(−J28v).\Pr[\text{error}] \le \Pr\bigl[|N|\ge J/2\bigr] \le 2\exp\!\left(-\frac{J^2}{8v}\right). For independent Gaussian sensor errors with standard deviation σ\sigma, N=et−et−1N=e_t-e_{t-1} has v=2σ2v=2\sigma^2 and the bound is 2e−J2/16σ22e^{-J^2/16\sigma^2}: about 2.5×10−42.5\times10^{-4} per step at J=12σJ=12\sigma and 0.0370.037 at J=8σJ=8\sigma. At J=8σJ=8\sigma the exact Gaussian rates are about 0.0050.005 for false alarms and 0.0020.002 for misses. The miss rate is roughly half the false-alarm rate because only noise opposing the jump causes a miss, while a false alarm can come from either tail (Figure 5a).

A baseline step DD with ∣D∣≤L|D|\le L shifts the effective margin from J/2J/2 to J/2−LJ/2-L, giving 2exp⁡(−(J/2−L)2/2v)2\exp(-(J/2-L)^2/2v) for J≥2LJ\ge2L (Figure 5b).

Because anomalies are rare, we bound the two error rates separately. For L≤τ≤J−LL\le\tau\le J-L, FPR(τ)≤2e−(τ−L)2/(2v),FNR(τ)≤2e−(J−τ−L)2/(2v),\mathrm{FPR}(\tau) \le 2e^{-(\tau-L)^2/(2v)},\qquad \mathrm{FNR}(\tau) \le 2e^{-(J-\tau-L)^2/(2v)}, which makes the trade-off in τ\tau explicit (Figure 5c). These bounds hold per step. Over a series of TT points the expected number of false alarms is T⋅FPRT\cdot\mathrm{FPR} by linearity, with no independence needed, so a 10−310^{-3} rate on a 10,000-point series still means about ten false alarms.

Figure 5. Gaussian sensor noise with standard deviation σ\sigmaσ (v=2σ2v=2\sigma^2v=2σ2); log scale on the vertical axes. (a) The bound at τ=J/2\tau=J/2τ=J/2 (dashed, capped at 1), the exact false-alarm rate, and the exact miss rate for a jump of size exactly JJJ. The miss rate vanishes as J→0J\to0J→0 because a miss requires A+NA+NA+N to land in an interval of width JJJ. Circles are Monte Carlo estimates from 4×1064\times10^64×106 draws, shown where at least 50 errors occur. (b) Drift bounds (dashed) and exact worst-case error (solid), one colour per LLL; each curve starts at J=2LJ=2LJ=2L. (c) FPR and FNR against τ\tauτ for J=8σJ=8\sigmaJ=8σ, L=0L=0L=0: bounds dashed, exact solid, simulation circles.
Figure 5. Gaussian sensor noise with standard deviation σ\sigma (v=2σ2v=2\sigma^2); log scale on the vertical axes. (a) The bound at τ=J/2\tau=J/2 (dashed, capped at 1), the exact false-alarm rate, and the exact miss rate for a jump of size exactly JJ. The miss rate vanishes as J→0J\to0 because a miss requires A+NA+N to land in an interval of width JJ. Circles are Monte Carlo estimates from 4×1064\times10^6 draws, shown where at least 50 errors occur. (b) Drift bounds (dashed) and exact worst-case error (solid), one colour per LL; each curve starts at J=2LJ=2L. (c) FPR and FNR against τ\tau for J=8σJ=8\sigma, L=0L=0: bounds dashed, exact solid, simulation circles.

Information Lost by Differencing

Computing Diff scores discards some information about a series, and no threshold or model trained on the scores can recover it.

Signed steps determine a series up to an additive constant: Δx=Δz\Delta x=\Delta z if and only if z=x+cz=x+c. So nothing about the level of a series is available from its steps. A slow climb to a dangerous value produces only small steps. Whether such a climb is an anomaly is the labeller’s decision; Diff cannot distinguish it from a harmless drift.

Taking absolute values also discards the sign of every step. Precisely, s(x)=s(z)s(x)=s(z) if and only if Δzt=±Δxt\Delta z_t=\pm\Delta x_t at every tt, with the sign chosen independently at each step. The ramp 0,1,2,3,…0,1,2,3,\dots and the oscillation 0,1,0,1,…0,1,0,1,\dots therefore have identical scores 0,1,1,1,…0,1,1,1,\dots. A task that labels the ramp normal and the oscillation anomalous, with equal prior probability, cannot be solved from the scores at better than error 1/21/2. The same holds for any window of the two series, so a pointwise detector that looks at the scores in a neighbourhood of tt cannot do better either.

Figure 6c tests this with trained classifiers. One class of series moves monotonically (up or down with equal probability), the other alternates, and the step magnitudes are i.i.d. from the same distribution in both classes, so the score sequences are identically distributed across classes. On signed steps, k-NN, random forests, gradient boosting and an MLP reach zero test error, while on Diff scores all five classifiers stay at 1/21/2. Logistic regression is at chance even on signed steps: any linear function of the steps takes values of both signs on the monotone class (whose sign is random) and values near zero on the alternating class, so no single cut on it separates them.

In general, a property of a series is a function of its Diff scores if and only if it is invariant under adding a constant and under flipping the sign of any subset of steps.

Figure 6. (a) Three series with the same step magnitudes: a ramp, an oscillation, and a series with random step signs (offset vertically for visibility). (b) Their common Diff scores. (c) Test error of five classifiers trained on 6,000 series of length 32 and tested on 6,000 more, using signed steps (green) or Diff scores (black), with 95% Wilson intervals; the dotted line is the Bayes error of the Diff scores on this task (Section 7). Panels (d) to (f) belong to Section 6: (d) a level shift of height h=3h=3h=3 held for k=40k=40k=40 labelled points; (e) at threshold h/2h/2h/2, Diff flags the first point of the shift and the first point after it; (f) pointwise F1 against kkk, from the formulas in Section 6 (lines) and from simulated series (circles).
Figure 6. (a) Three series with the same step magnitudes: a ramp, an oscillation, and a series with random step signs (offset vertically for visibility). (b) Their common Diff scores. (c) Test error of five classifiers trained on 6,000 series of length 32 and tested on 6,000 more, using signed steps (green) or Diff scores (black), with 95% Wilson intervals; the dotted line is the Bayes error of the Diff scores on this task (Section 7). Panels (d) to (f) belong to Section 6: (d) a level shift of height h=3h=3 held for k=40k=40 labelled points; (e) at threshold h/2h/2, Diff flags the first point of the shift and the first point after it; (f) pointwise F1 against kk, from the formulas in Section 6 (lines) and from simulated series (circles).

Event Labels and the Pulse Recording

Diff fails on the pulse recording of Figure 2c for two reasons. Its precision is low because every normal heartbeat produces a pulse with a steep upstroke, so in the decomposition of Section 3 the regular beats belong to uu, and BB is set by their steep edges. The pulse of the premature beat does produce the largest steps in the recording, but they exceed the normal pulses’ steps by far less than a factor of two. Any threshold low enough to catch more than its single largest step also catches normal pulses.

The 200-point annotation explains the low recall. It marks an abnormal state, while Diff responds to individual steps. Consider the cleanest version, a level shift of height hh held for kk points (Figure 6d,e). A threshold between the noise and hh flags the first point of the shift and the first point after it, giving TP=1\mathrm{TP}=1, FP=1\mathrm{FP}=1, FN=k−1\mathrm{FN}=k-1 and F1=2k+2,\mathrm{F1} = \frac{2}{k+2}, about 0.050.05 for k=40k=40, although the event was detected at its onset. A detector that flags only the onset gets 2/(k+1)2/(k+1).

Point adjustment, used in Figure 1, was designed for this case: one flagged point inside a labelled segment credits the whole segment. It is why Diff averages 0.770.77 on UCR there while scoring 0.060.06 pointwise on BIDMC1. It also makes detection easy to overstate, since a detector that fires at random is likely to land inside every long segment; Kim et al. analyse this inflation and show that random scores can reach a high F1 under point adjustment [6].

The Bayes Error of a Feature Map

The ramp and oscillation example is an instance of a general calculation that applies to any detector. Let ϕ\phi be the features a detector sees (the Diff score at one point, the whole score sequence, or the raw series), and assume for simplicity that ϕ\phi takes finitely many values. Inputs with the same value of ϕ\phi must receive the same prediction, so the Bayes error of ϕ\phi is min⁡g Pr⁡[g(ϕ(X))≠Y]=∑zmin⁡{Pr⁡[ϕ=z, Y=0],  Pr⁡[ϕ=z, Y=1]},\min_{g}\,\Pr\bigl[g(\phi(X))\ne Y\bigr] = \sum_{z}\min\bigl\{\Pr[\phi=z,\,Y=0],\;\Pr[\phi=z,\,Y=1]\bigr\}, attained by a majority vote within each level set of ϕ\phi. It is zero if and only if each value of ϕ\phi occurs with one label only. For the ramp and oscillation, ϕ\phi has a single value carrying probability 1/21/2 under each label, so the Bayes error is 1/21/2.

The masses in this sum belong to the joint distribution of features and labels, so the Bayes error depends on the dataset as well as on ϕ\phi. Diff’s near-perfect F1 on the Yahoo series of Figure 2 shows that the Bayes error of its score is small there and carries no information about data from another source, and an in-distribution test split cannot reveal the difference. Figure 7a–c shows a binary feature in three datasets. On the benchmark it equals the label (Bayes error 00); on independent data its Bayes error is 1/21/2; on data where the relation is reversed the Bayes error is 00 again, yet the rule learned on the benchmark, g(z)=zg(z)=z, now errs everywhere, so the Bayes error and the error of the learned rule move in opposite directions.

To bound the change, let PP and QQ be the benchmark and deployment distributions over pairs ω=(input,label)\omega=(\text{input},\text{label}), let Y~\widetilde Y be the benchmark’s label and YY the correct one, and let η=Pr⁡P[Y~≠Y]\eta=\Pr_P[\widetilde Y\ne Y]. With the total variation distance TV(P,Q)=12∑ω∣P(ω)−Q(ω)∣\mathrm{TV}(P,Q)=\tfrac12\sum_\omega|P(\omega)-Q(\omega)|, the Bayes error of ϕ\phi under (P,Y~)(P,\widetilde Y) and under (Q,Y)(Q,Y) differ by at most η+TV(P,Q)\eta+\mathrm{TV}(P,Q). Each relabelled point moves at most its own mass between the two minima in the sum, and changing the distribution moves at most TV\mathrm{TV} of mass; this is the same mechanism as the classical domain-adaptation bounds [7]. Neither term is identifiable from the benchmark: η\eta requires correct labels and TV(P,Q)\mathrm{TV}(P,Q) requires deployment data.

The bound is attained when the benchmark is mixed with the independent dataset: for Qw=(1−w)P+wQQ_w=(1-w)P+wQ, TV(P,Qw)=w/2\mathrm{TV}(P,Q_w)=w/2 and the Bayes error is exactly w/2w/2 (Figure 7d). Mixing with the reversed dataset, Rw=(1−w)P+wRR_w=(1-w)P+wR, gives Bayes error min⁡(w,1−w)\min(w,1-w), while the learned rule’s error grows linearly to 11 (Figure 7e).

Figure 7. (a) to (c) Joint probabilities of a binary feature ϕ\phiϕ and label YYY in three datasets; hatched bars are the smaller mass in each column, and they sum to the Bayes error. “Copy rule” is the error of g(z)=zg(z)=zg(z)=z, the rule learned on (a). (d) Qw=(1−w)P+wQQ_w=(1-w)P+wQQw​=(1−w)P+wQ with QQQ the independent dataset: the Bayes error equals the bound TV(P,Qw)=w/2\mathrm{TV}(P,Q_w)=w/2TV(P,Qw​)=w/2. (e) Rw=(1−w)P+wRR_w=(1-w)P+wRRw​=(1−w)P+wR with RRR the reversed dataset: the Bayes error is min⁡(w,1−w)\min(w,1-w)min(w,1−w) while the copy rule’s error rises to 111. Circles are test errors of depth-one decision trees trained on 40,000 samples at each www.
Figure 7. (a) to (c) Joint probabilities of a binary feature ϕ\phi and label YY in three datasets; hatched bars are the smaller mass in each column, and they sum to the Bayes error. “Copy rule” is the error of g(z)=zg(z)=z, the rule learned on (a). (d) Qw=(1−w)P+wQQ_w=(1-w)P+wQ with QQ the independent dataset: the Bayes error equals the bound TV(P,Qw)=w/2\mathrm{TV}(P,Q_w)=w/2. (e) Rw=(1−w)P+wRR_w=(1-w)P+wR with RR the reversed dataset: the Bayes error is min⁡(w,1−w)\min(w,1-w) while the copy rule’s error rises to 11. Circles are test errors of depth-one decision trees trained on 40,000 samples at each ww.

Interpreting a Benchmark Margin

Suppose detector aa beats detector bb on a benchmark. We would like to conclude that aa has lower error on deployment data with correct labels. We use 0-1 error rather than F1 here because it decomposes over points, which makes the argument a few lines long; sampling error, label errors and distribution shift act on F1 in the same way, with the extra complication of a random denominator.

Only points where the two detectors disagree can affect the comparison. Where aa and bb output the same label they incur the same loss under any label and any distribution, so the per-point loss difference ℓ(a,ω)−ℓ(b,ω)\ell(a,\omega)-\ell(b,\omega) is in {−1,0,1}\{-1,0,1\} and is nonzero only when a(ω)≠b(ω)a(\omega)\ne b(\omega); on such a point, flipping the label changes it by 22. Define κab=Pr⁡P[a≠b, Y~≠Y],δab=∑ω∣Q(ω)−P(ω)∣ 1{a(ω)≠b(ω)}.\kappa_{ab}=\Pr_P\bigl[a\ne b,\ \widetilde Y\ne Y\bigr],\qquad \delta_{ab}=\sum_\omega |Q(\omega)-P(\omega)|\,\mathbf{1}\{a(\omega)\ne b(\omega)\}. Then the error difference on (Q,Y)(Q,Y) and the error difference on (P,Y~)(P,\widetilde Y) differ by at most 2κab+δab2\kappa_{ab}+\delta_{ab}. The factor 2 is the label flip; δab\delta_{ab} has no 12\tfrac12 because the loss difference ranges over an interval of length 2 rather than 1. Adding the sampling error mabm_{ab} between the test-set difference and its expectation under (P,Y~)(P,\widetilde Y), a measured margin larger than mab+2κab+δabm_{ab}+2\kappa_{ab}+\delta_{ab} certifies the ranking on deployment data.

Both correction terms are supported on the disagreement set, which makes the bound usable in practice. Estimating κab\kappa_{ab} only requires re-annotating the points where the two detectors disagree, typically a small fraction of the data. Suppose the detectors disagree on 3%3\% of points and aa leads by one percentage point. If 0.5%0.5\% of all labels are wrong and all of those fall on disagreements, 2κab=0.012\kappa_{ab}=0.01 erases the lead; if they fall where the detectors agree, κab=0\kappa_{ab}=0. Label noise spread uniformly at random lands almost entirely on agreements and barely moves the comparison (Figure 8a).

For the sampling term, the independent unit is the series. Points within a series are strongly autocorrelated, and treating them as independent overstates the effective sample size. With nn series and per-series error differences in [−1,1][-1,1], Hoeffding’s inequality gives mab≤tm_{ab}\le t with probability at least 1−e−nt2/21-e^{-nt^2/2}, so a one-sided 5% test needs t=2ln⁡20/nt=\sqrt{2\ln 20/n}. That is 0.300.30 for Yahoo A1’s 67 series and 0.150.15 for the UCR archive’s 250. These are worst-case margins, since real per-series differences rarely use the full range, but a gap of a few F1 points is well below either. Selecting the best of MM thresholds or detectors on the same labels multiplies the failure probability by up to MM (union bound), giving t=2ln⁡(20M)/nt=\sqrt{2\ln(20M)/n} (Figure 8b). The per-series oracle threshold in Figures 1 and 2 is such a selection, applied to every detector alike.

F1 itself is unstable when a series has few labelled points: one missing annotation can move a series from F1 1 to F1 0, and a detector that flags only the recorded anomalies outscores one that also finds unrecorded ones. Precision also depends on prevalence π\pi: precision=π TPRπ TPR+(1−π) FPR≤2πFPR(π≤12).\text{precision} = \frac{\pi\,\mathrm{TPR}}{\pi\,\mathrm{TPR}+(1-\pi)\,\mathrm{FPR}} \le \frac{2\pi}{\mathrm{FPR}} \qquad (\pi\le\tfrac12). At π=0.5%\pi=0.5\% and FPR=5%\mathrm{FPR}=5\%, even perfect recall gives precision 50/548≈0.09150/548\approx0.091 (in 10,000 points, 50 true alarms against about 498 false ones), and the bound caps it at 0.20.2. Two detectors on the same collection share π\pi, but averages across collections, and comparisons between papers that use different collections, mix very different prevalences (Figure 8c).

Figure 8. (a) Two simulated detectors disagreeing on 3% of 10,000 points, aaa ahead by one percentage point, with 50 wrong labels. The horizontal axis is the fraction of wrong labels on disagreements. Lines show the measured gap when every such error favours one detector; the band is 0.01±2κab0.01\pm2\kappa_{ab}0.01±2κab​. Green points are 600 placements of the wrong labels uniformly at random. (b) The margin ttt for a one-sided 5% test with nnn series when the best of MMM comparisons is reported: Hoeffding bound (dashed) and simulated 95% quantile with per-series differences ±1\pm1±1 (solid). (c) Precision against prevalence at FPR=5%\mathrm{FPR}=5\%FPR=5% for recall 1 and 0.5, with the bound 2π/FPR2\pi/\mathrm{FPR}2π/FPR (dashed, capped at 1).
Figure 8. (a) Two simulated detectors disagreeing on 3% of 10,000 points, aa ahead by one percentage point, with 50 wrong labels. The horizontal axis is the fraction of wrong labels on disagreements. Lines show the measured gap when every such error favours one detector; the band is 0.01±2κab0.01\pm2\kappa_{ab}. Green points are 600 placements of the wrong labels uniformly at random. (b) The margin tt for a one-sided 5% test with nn series when the best of MM comparisons is reported: Hoeffding bound (dashed) and simulated 95% quantile with per-series differences ±1\pm1 (solid). (c) Precision against prevalence at FPR=5%\mathrm{FPR}=5\% for recall 1 and 0.5, with the bound 2π/FPR2\pi/\mathrm{FPR} (dashed, capped at 1).

Conclusions and Next Steps

Diff is exact whenever anomalies are steps more than twice the largest normal step, and under sub-Gaussian noise its error decays like e−J2/8ve^{-J^2/8v}. The Yahoo series in Figure 2 have this form. We have not yet measured how much of each collection does, but Figure 1 suggests it is a large share for Yahoo, NAB and TODS under point-adjusted scoring. Diff fails when normal behaviour itself takes large steps, as in the pulse recording, and when labels mark long states, which point adjustment then partly hides.

For reading the literature, the consequence is that a margin of a few F1 points over Diff on these collections is weak evidence that a method detects anything Diff misses. Such a margin is within the sampling error of a few dozen series. Label errors on the small set of points where the two detectors disagree can produce or erase it, and switching between pointwise and adjusted scoring can change it.

Our next step is to test the assumptions above on real archives: measure step distributions at normal and anomalous points and test separation with thresholds fixed on held-out series, estimate the overlap of normal and anomalous score distributions (which bounds the Bayes error of Diff from below), re-annotate disagreement points between Diff and a stronger detector to estimate κab\kappa_{ab}, and repeat published comparisons with series as the sampling unit.

This is joint work with Vidyut Veedgav, Donovan Wu, Sreya Srinidhi and Weicong Chen. It grew out of our work on anomaly detection by estimating what typical data looks like, for images in Forte [8], for system logs in K⁴ [9] and its streaming deployment K4-Serve [10], and for language model prompts in Trust The Typical [11]. Diff’s results came up when we benchmarked that approach on time series.

References

1.
Citation 1 Citation 2
2.
Back to text
3.
J. Xu et al. (2022). Anomaly Transformer: Time Series Anomaly Detection with Association Discrepancy. International conference on learning representations (ICLR). Read source.
Back to text
4.
Y. Yang et al. (2023). DCdetector: Dual Attention Contrastive Representation Learning for Time Series Anomaly Detection. ACM SIGKDD conference on knowledge discovery and data mining (KDD). Read source.
Back to text
5.
Back to text
6.
Citation 1 Citation 2
7.
S. Ben-David et al. (2010). A theory of learning from different domains. Machine Learning. Read source.
Back to text
8.
D. Ganguly et al. (2025). Forte: Finding Outliers with Representation Typicality Estimation. The thirteenth international conference on learning representations. Read source.
Back to text
9.
W. Chen et al. (2025). K⁴: Online Log Anomaly Detection Via Unsupervised Typicality Learning. 2025 IEEE 32nd international conference on high performance computing, data, and analytics (HiPC). Read source.
Back to text
10.
W. Chen et al. (2026). K4-Serve: Robust Streaming Log Anomaly Detection for HPC & AI Infrastructure. Proceedings of the practice and experience in advanced research computing 2026: Resilient roots + empowered communities (PEARC ’26). Read source.
Back to text
11.
D. Ganguly et al. (2026). Trust The Typical. The fourteenth international conference on learning representations. Read source.
Back to text

Cite this essay

Debargha Ganguly, Vidyut Veedgav, Donovan Wu, Sreya Srinidhi, and Weicong Chen. “Why a One-Line Baseline Does Well on Time Series Anomaly Detection Benchmarks: A Follow-up to Wu and Keogh.” Research notes, November 5, 2026. https://blog.debargha.com/essays/when-diff-works/

@misc{ganguly2026whyoneline,
  author       = {Ganguly, Debargha and Veedgav, Vidyut and Wu, Donovan and Srinidhi, Sreya and Chen, Weicong},
  title        = {Why a One-Line Baseline Does Well on Time Series Anomaly Detection Benchmarks: A Follow-up to Wu and Keogh},
  howpublished = {Research notes},
  year         = {2026},
  month        = nov,
  url          = {https://blog.debargha.com/essays/when-diff-works/},
}
Download .bib
∎

Thank you for reading.

Download bibliography