Finding "needles in haystacks" within continuous-time event data—such as server logs, financial transactions, or seismic activity—is a critical challenge in machine learning. In their NeurIPS 2021 paper, Shchur et al. propose a novel unsupervised method for detecting anomalies in event sequences by framing the problem as Out-of-Distribution (OoD) detection for Temporal Point Processes (TPPs).
They introduce the Sum-of-Squared-Spacings (3S) statistic, a metric that effectively captures both unusual event frequencies and irregular timing patterns, significantly outperforming traditional statistical tests and standard log-likelihood approaches.
The Challenge: Statistical Blind Spots in Event Streams
In fields like DevOps and information security, data arrives as a stream of discrete events in continuous time. Detecting "abnormal" behavior is vital for catching server failures or security breaches. However, high-quality labels for anomalies are rare, necessitating unsupervised approaches.
Traditional Goodness-of-Fit (GoF) tests used for these sequences, such as the Kolmogorov-Smirnov (KS) test, have a major weakness: they often ignore the number of events ($N$). A sequence might have perfectly timed events but feature ten times the normal volume, and a standard test might still classify it as "normal." The authors aim to bridge the gap between deep generative modeling (Neural TPPs) and classical statistical testing to create a more robust anomaly detector that accounts for these blind spots.
Methodology: The 3S Statistic
To address the limitations of existing tests, the authors propose the Sum-of-Squared-Spacings (3S) statistic. The anomaly detection workflow proceeds as follows:
- Model Training: A Neural TPP is trained on "normal" data to learn its underlying patterns (specifically, the compensator function, $\Lambda^*$).
- Transformation: Using the Random Time Change Theorem, the complex event sequence is transformed into a Standard Poisson Process (SPP). This mathematical transformation holds true if the underlying model accurately reflects the data.
-
The 3S Statistic: On this transformed sequence, the 3S statistic is calculated: $$\psi(Z) = \frac{1}{V} \sum_{i=1}^{N+1} (v_i - v_{i-1})^2$$ Essentially, this sums the squares of the gaps (spacings) between events.
-
Anomaly Scoring: Because the distribution of this 3S statistic is known (or can be estimated) for "normal" data, any sequence with a significantly different 3S value is flagged as an anomaly.
Unlike traditional tests that normalize away the event count $N$, the 3S statistic is explicitly sensitive to it. By choosing a specific normalization ($1/V$ instead of $N/V^2$), the 3S statistic reacts to the total event count. If a sequence has too many events, the spacings become small, and the sum of their squares drops; if it has too few, the sum rises.
As shown above, the 3S statistic easily distinguishes between sequences with different numbers of events ($N=85$ vs. $N=115$), whereas the traditional KS test distributions completely overlap, demonstrating its "blind spot."
Experimental Validation
The authors evaluated their method across a diverse range of datasets, including synthetic SPP variants, simulated DevOps data (e.g., server overloads or sudden latency), real-world server logs with injected failures, seismic data (Stanford Earthquake Dataset), and neuronal spike trains.
The 3S statistic consistently outperformed baselines across almost all scenarios:
- Consistency: In synthetic GoF testing, 3S was the top performer in 5 out of 6 scenarios.
- Real-World Performance: On real-world server logs featuring packet corruption, 3S achieved an ROC AUC of 95.5%, while the standard Log-Likelihood approach only managed 75.9%.
- Robustness: Even when only 5% of a time interval was affected by an anomaly (e.g., a brief server flicker), the 3S statistic detected it with near-perfect accuracy, whereas inter-event timing tests failed completely.
Key Insights and Limitations
A core takeaway from this work is the distinction between typicality and likelihood. "High probability" does not always mean "normal." For example, in a sequence of 100 coin flips, a sequence of 100 heads is very unlikely, but so is any specific sequence of 50 heads and 50 tails. The 3S statistic looks for typicality—whether the sequence looks like what we expect from the broader distribution. Furthermore, the method is highly modular; any state-of-the-art Neural TPP can be used as the base model, with the 3S statistic acting as a diagnostic layer on top.
However, the approach does have limitations. It assumes that training sequences are independent and identically distributed (IID). In the real world, "normal" behavior might drift over time, potentially leading to false positives. Additionally, the accuracy of the anomaly detection is inherently tethered to the quality of the underlying Neural TPP. Finally, the authors acknowledge that no single statistic is universally optimal for every possible anomaly type, though 3S proves to be highly versatile for continuous-time event data.
Summary updated