This paper introduces temporal-conditioned normalizing flows (tcNF), a novel framework that addresses anomaly detection in time series data with accurate modeling of temporal dependencies and uncertainty. By conditioning normalizing flows on previous observations, tcNF effectively captures complex temporal dynamics and generates accurate probability distributions of expected behavior. This autoregressive approach enables robust anomaly detection by identifying low-probability events within the learned distribution. We evaluate tcNF on diverse datasets, demonstrating good accuracy and robustness compared to existing methods. A comprehensive analysis of strengths and limitations and open-source code is provided to facilitate reproducibility and future research.
Figures & tables
Figure 1: Forward propagation of one coupling layer from the base distribution to the data distribution.
Figure 2: Overview of a temporal-conditioned coupling layer, drawn as normalization (reverse process) of the data distribution u2,t=g(x1,t,wt) . We drop the coupling layer index i=1,…,N and the time index t from xi,t and ui,t whenever it is clear from the context. The diagram illustrates how the conditioning information (red arrows) is added to the conditioner function expressed as wt . After one such transformation, it is required to swap the two slices, such as x2,t1:d=u2,td+1:D and x2,td+1:D=u2,t1:d , to achieve a full coupling of the input as the next xt of the following layer.
Dataset
# Datasets
Variables
Train
Test
Anomalies (%)
FSB Baumgartner et al. (2023)
70
210
10010000
0.0915.00
SRB Baumgartner et al. (2023)
4
4
199000999000
0.010.03
SWaT Goh et al. (2017)
1
51
449919
449919
12.15
CalIt2 Hutchins (2006)
1
2
4032
1008
3.17
GHL Filonov et al. (2016)
48
16
1535118
200001
0.390.42
Metro Hogue (2019)
1
5
38563
9641
0.13
Table 1: Description of the datasets. (%) is the percentage of anomalous data points in the dataset.
Parameter
RealNVP
tcNF-base
tcNF-mlp
tcNF-cnn
tcNF-stateless
tcNF-stateful
Coupling layers
For all models: 320
Θ(⋅) multiplier
For all models: 150
Θ(⋅) layers
For all models: 38
Θ(⋅) dropout
For all models: 0.10.9
Θ(⋅) funnel factor
For all models: 110
Look-back window
-
FSB: 150 , others: 1100
Table 2: The listed hyperparameters are optimized per dataset and explored with CMA-ES to find a good parameter set. Θ(⋅) parameters are for the conditioner function in each coupling layer. Past and encoder(⋅) parameters are primarily for the encoder outside the normalizing flow. ”-” indicates that this parameter is not part of a given method.
Figure 3: Comparison of anomaly detection performance on the FSB benchmark using AUC (top) and VUS (bottom) sorted by average performance on the AUC metric. The results demonstrate the competitive performance of the proposed tcNF models compared to established baselines, particularly in terms of RealNVP Dinh et al. (2017) as the unchanged baseline method.
(a) AUC
Sine (16)
ECG-CBF-RW (20)
Increasing (13)
Saw (2)
Wave (14)
Corr (5)
Method
▲ tcNF-base
0.85 ± 0.15
0.69 ± 0.27
0.97 ± 0.04
0.97 ± 0.01
0.90 ± 0.10
0.70 ± 0.18
▲ tcNF-mlp
0.83 ± 0.14
0.59 ± 0.33
0.83 ± 0.12
0.98 ± 0.02
0.62 ± 0.26
0.72 ± 0.17
▲ tcNF-cnn
0.83 ± 0.16
0.67 ± 0.31
0.89 ± 0.12
0.98 ± 0.01
0.87 ± 0.15
0.68 ± 0.19
▲ tcNF-stateless
0.78 ± 0.23
0.63 ± 0.30
0.88 ± 0.11
0.98 ± 0.01
0.76 ± 0.21
0.70 ± 0.15
Table 3: Comparing anomaly detection performance on the FSB benchmark from the sequence type using AUC (a) and VUS (b). The results show that our proposed tcNF models can handle most sequences well and shows difficulties on rapidly changing signals, demonstrating overall a competitive performance. Method categories: red : deep learning, blue : classic machine learning, black : outlier detection, ▲ : distribution, ■ : reconstruction, ⧫ : distance, ★ : forecasting and ◀ : trees.
Figure 4: The first row shows the training sequences and the latent representation to the right. The second row contains the test sequence with no clearly visible anomaly in the sequence to the human eye. The latent representation to the right clearly shows one out-of-distribution point as indicated by the red triangle. The anomaly in this case is a sudden jump in one timestep, as marked by the anomaly label in the third row, and is based on the standard deviation of the values in the 10 previous timesteps. Both latent space representations indicate that the model captured the sequence behavior, and only noise remains.
Figure 5: The parameter search in this case highlights that a rather extensive access to previous datapoints is important, which correlates with an increased model capacity, such as Θ(⋅) multiplier and Θ(⋅) layers in each coupling layer.
AUC
VUS
Method
▲ tcNF-base
0.73 ± 0.17
0.70 ± 0.20
▲ tcNF-cnn
0.72 ± 0.19
0.70 ± 0.20
▲ tcNF-mlp
0.69 ± 0.20
0.66 ± 0.22
▲ tcNF-stateless
0.59 ± 0.13
0.54 ± 0.18
◀ IF-LOF Cheng et al. (2019)
0.90 ± 0.14
0.95 ± 0.05
Table 4: Comparing anomaly detection performance on the SRB benchmark from the sequence type using AUC and VUS. The results show our proposed tcNF models can outperform the base model, RealNVP, but can not fully outperform all other models on this benchmark suite. See Tab. 3 for method categories.
(a) AUC
SWaT
CalIt
GHL
Metro
SMD
Method
▲ tcNF-base
0.88
0.25
0.88 ± 0.09
0.48
0.78 ± 0.11
▲ tcNF-mlp
0.88
0.30
0.64 ± 0.34
0.67
0.80 ± 0.14
▲ tcNF-cnn
0.84
0.29
0.89 ± 0.04
0.49
0.80 ± 0.13
▲ tcNF-stateless
0.88
0.23
0.58 ± 0.40
0.53
0.78 ± 0.14
Table 5: Comparison of anomaly detection performance on five real-world datasets using AUC (a) and VUS (b). The results demonstrate various performance improvements over the base method. SWaT, CalIt, and Metro consist of rapidly jumping values, which are difficult for our method. GHL and SMD consist of a mix of jumps and smoother channels, which work better for our method. See Tab. 3 for method categories.
Figure 6: Clip-out of the machine-1-5 sequence in the SMD dataset showing the training sequence with some normal and unusual behaviour. The test sequence contains a strong anomaly in two out of the 38 channels, where six distinct channels are shown. This case shows the delay of the tcNF-cnn method, which relies more strongly on historical behavior via the conditioning.
Figure 7: The most significant parameters in this example are the Θ(⋅) multiplier, Θ(⋅) layers, Θ(⋅) funnel, number of coupling layers and look-back size. The parameters indicate a successful regularisation by the optimization search and the other two indicate that a certain amount is needed to be able to learn a good representation.
Figure 8: Clip-out of the machine-2-5 sequence in the SMD dataset showing a normal training set with one exception in the beginning which can also be seen in the latent space as outlier. The test sequence contains two labeled anomalies. A zoom in would reveal an early detection meaning at the beginning of the anomaly, which indicates that, in this case, the near past is important for the detection.
Figure 9: The parameter optimization search reveals exactly that the previous observations is important for this sequence, including some regularisation on the other parameters.
The core challenge in unsupervised anomaly detection is identifying abnormal patterns without prior knowledge of their characteristics. While existing methods have addressed aspects of this problem, they often struggle to learn a robust representation of the normal data distribution that is distinct from anomalous patterns. In this paper, we present a novel framework, Unified Unsupervised Anomaly Detection (U2AD), that comprehensively addresses anomaly detection in multivariate time series. Our approach learns the underlying data distribution of normal samples by utilizing score-based generative modeling. We introduce a novel time-dependent score network and a unified training objective that together delineate the manifold of normal data while considering both local and global temporal contexts. Reconstruction is then performed via a deterministic sampling process using an ordinary differential equation solver. Our extensive experimental evaluations demonstrate that U2AD not only outperforms current state-of-the-art methods in detection accuracy but also identifies anomalies at significantly earlier stages of their occurrence.
Prithul Sarker, Sushmita Sarker, Nicholas G. Murray +1
Time Series Foundation Models (TSFMs) achieve strong generalization by learning to reconstruct or forecast broad temporal patterns from large-scale time series during pre-training. Yet this strength can become a weakness for anomaly detection: TSFMs may model rare anomalous patterns as effectively as normal ones, allowing anomalies to be accurately reconstructed or forecasted and thus diminishing their reconstruction/forecasting error-based anomaly scores. This paper proposes \underline{\textbf{N}}$$\textbf{ormality}\underline{\textbf{C}}$$\textbf{onstraint}\underline{\textbf{L}}$$\textbf{earning} (NCL), a lightweight plug-and-play framework that adapts pre-trained TSFMs for accurate anomaly detection without modifying their pre-trained parameters. Our key insight is to constrain the broad pattern space of TSFMs to the normal structure of a target time series, preventing their broad modeling capability from obscuring abnormal deviations. Specifically, NCL constructs a compact normality subspace from a few normal patch features and adaptively steers each patch feature toward normality within this subspace, guided by contrastive constraints that form compact and discriminative normality manifolds. The calibrated features are aggregated to reinforce normal components and fused with the original TSFM output, amplifying the discrepancy between normal and abnormal observations for the reconstruction/forecasting error-based anomaly scoring. Extensive experiments across diverse TSFM families and benchmarks show that NCL consistently improves anomaly detection performance, providing a generalizable framework for adapting TSFMs to anomaly detection.
Xiaohui Zhou, Yijie Wang, Hongzuo Xu +2
National Key Laboratory of Parallel and Distributed Computing · College of Computer Science and Technology, National University of Defense Technology · Intelligent Game and Decision Lab (IGDL) +1
Deep generative models for anomaly detection in multivariate time-series are typically trained by maximizing observed data likelihood. However, likelihood in observation space measures marginal density rather than conformity to structured temporal dynamics, and therefore can assign high probability to anomalous or out-of-distribution samples. We address this structural limitation by relocating the notion of anomaly to a prescribed latent space. We introduce explicit inductive biases in conditional normalizing flows, modeling time-series observations within a discrete-time state-space framework that constrains latent representations to evolve according to prescribed temporal dynamics. Under this formulation, expected behavior corresponds to compliance with a specified distribution over latent trajectories, while anomalies are defined as violations of these dynamics. Anomaly detection is consequently reformulated as a statistically grounded compliance test, such that observations are mapped to latent space and evaluated via goodness-of-fit tests against the prescribed latent evolution. This yields a principled decision rule that remains effective even in regions of high observation likelihood. Experiments on synthetic and real-world time-series demonstrate reliable detection of anomalies in frequency, amplitude, and observation noise, while providing interpretable diagnostics of model compliance.
David Baumgartner, Eliezer de Souza da Silva, Iñigo Urteaga
Department of Computer Science, Norwegian University of Science and Technology, Norway · BCAM — Basque Center for Applied Mathematics, Spain · Department of Informatics Engineering, University of Coimbra, Portugal +2