Paying for Uncertainty Only When the Noise Is New: Gated Stochastic Inference for Streaming Anomaly Detection

Anomaly detectors that watch sensor streams face a basic tradeoff. Monte Carlo Dropout keeps the network's random neuron-dropping switched on at test time and runs the same input many times. The spread of the resulting answers then shows when the model is unsure. That spread is what exposes subtle, early-stage faults. In a building chiller study, a deterministic network was 95% sure that an incipient fault was "normal," while 100 dropout passes per sample surfaced the correct fault in every one of the 12 incipient cases (Detecting and Diagnosing Incipient Building Faults Using Uncertainty Information from Deep Neural Networks). One hundred passes per time step is affordable when a chiller reports once a minute. It is not affordable for vibration, power-grid synchrophasor, or server telemetry streams. Those streams are also where sensor noise drifts into regimes the model never saw in training.

We propose a small, single-pass "trigger" attached to a streaming detector. On each window, the trigger predicts whether running the expensive stochastic passes would change the anomaly decision. The full set of dropout passes runs only on the windows the trigger flags. The new ingredient is how the trigger is trained. It is fit with whole noise families held out, so it learns to fire on unfamiliar corruption rather than only on in-distribution ambiguity. The claim is that most of the detection benefit of 100-pass Monte Carlo Dropout under unseen noise can be recovered for an average cost of a few forward passes per window. We also claim that triggers which ignore held-out noise, such as score-margin gating or a variance head trained only on training-distribution noise, fail on exactly the windows where sampling matters.

Where the idea sits

Sequential anomaly detection is the application regime. Detectors such as the Anomaly Transformer score each time step by comparing two views of how it relates to the rest of the series. One view is a local, neighbor-focused attention pattern; the other is ordinary global attention. Frequency-domain models such as CATCH split the signal into frequency bands and learn which sensors inform each other within each band. Both are deterministic: one pass, with no notion of "I have not seen noise like this." SISVAE does model a time-varying noise level, a per-step variance that widens its tolerance during noisy stretches. It does so with sequential Monte Carlo sampling at inference, so it pays the same sampling cost we want to avoid. Its variance captures noise in the data, not the model's unfamiliarity with that noise. These papers motivate the proposal. Strong temporal detectors exist, but none of them knows when to be unsure, and the one that models noise pays for it on every step.

Stochastic inference overhead is the constraint. AdaNSP is the closest mechanism. It spends extra decoding computation only on tokens where dropout variance is high. However, it computes that variance with multiple dropout passes before deciding, so it saves nothing on the uncertainty estimate itself, and its REINFORCE-trained halting was fragile. Our trigger inverts this: one cheap prediction decides whether to sample at all, and it is trained with ordinary supervised regression. Directly Optimizing Calibrated Test-Time Uncertainty supplies the training principle. It separates "predictive noise," fit on training data, from "generalization noise," fit on held-out data, inside a single model. It was shown only on tabular regression and segmentation. We reuse its held-out-objective idea, but the held-out split is by noise family, and the target is the disagreement that Monte Carlo sampling produces on a sequential anomaly score.

Unseen noise generalization is the evaluation regime and the reason held-out training is needed. The speech literature shows how badly models trained with ordinary average-loss minimization collapse on unseen interference. In the Mixup-Breakdown work, separation quality fell to 1.86 SI-SNRi under unseen environmental noise (Mixup-breakdown). It also shows that learned selectors degrade when noise is severe: model-selection accuracy in SSEMS fell from about 95% at 15 dB to about 51% at −10 dB. This second result is a warning for us. A learned gate can fail exactly where it is needed most, so the trigger must be evaluated on noise it never saw.

Core Claim

Let $s_\theta(x)$ be the deterministic anomaly score of window $x$. Let $\bar s_T(x)$ and $v_T(x)$ be the mean and variance of the score over $T$ dropout passes. Let $\tau$ be the alarm threshold. The quantity worth predicting is not the variance itself but whether sampling would flip the decision:

$$ y(x) = \mathbb{1}\big[\, \mathbb{1}[s_\theta(x) > \tau] \neq \mathbb{1}[\bar s_T(x) + \kappa\sqrt{v_T(x)} > \tau] \,\big], $$

Here $\kappa$ sets how much variance-inflated evidence triggers an alarm, as in the uncertainty-aware decision rule of the chiller study. The trigger $g_\phi$ reads the detector's hidden state and a few cheap noise-floor statistics of the window, such as spectral flatness, the kurtosis of first differences, and per-channel residual scale. It outputs $\hat y(x)$.

The trigger is trained on windows whose corruption comes from noise families held out from the detector's own training. At test time, the full $T$-pass procedure runs only when $\hat y(x)$ exceeds a cutoff chosen to meet a budget $\rho$, the fraction of windows sampled. Expected cost per window is then $1 + \rho T$ passes rather than $T$. With $T=100$, a budget of $\rho = 0.02$ costs three passes per window on average.

The hypothesis has two parts. First, decision-flipping windows are rare and concentrated in unfamiliar noise and incipient anomalies. Second, deterministic signals, the score margin $|s_\theta - \tau|$ included, cannot find those windows, because overconfidence on unfamiliar inputs is the failure being corrected.

Research Program

The work builds two dropout-equipped backbones that the literature already supports for subsequence anomalies: the Anomaly Transformer and a CATCH-style frequency-patch model. Each is trained on nominal data under a fixed set of noise families. The noise library has eight families chosen to stress different detector assumptions. They are white Gaussian, heavy-tailed impulsive (Student-t), colored $1/f$ noise, slow multiplicative gain drift, quantization, intermittent channel dropout, periodic interference at a non-native frequency, and cross-channel crosstalk. The heavy-tailed family specifically targets SISVAE's stated Gaussian limitation.

The protocol is leave-one-family-out. The detector trains on some families. The trigger is fit on a disjoint subset of families against Monte Carlo targets, following the held-out-objective logic of the calibrated-uncertainty paper. Testing uses the remaining families, which neither component has seen. Generating the targets costs 100 passes per training window, but this cost is paid offline, once.

Three analyses come before any headline claim. The first measures how often sampling actually changes decisions, as a function of noise family and anomaly type. If flips are not rare, gating cannot save compute and the project reduces to a negative result about cheap uncertainty. The second checks whether flipping windows cluster where the deterministic score is confident, which is the chiller paper's finding transplanted to sequences. The third is an ablation of the trigger's inputs, hidden state versus noise-floor statistics, to see whether the trigger is detecting novelty of the noise or difficulty of the anomaly.

Baselines

The naive reference point is the deterministic backbone run once per window with a fixed threshold. This is what deployments do now and what any gating scheme must beat at near-equal cost.

The strongest existing method is full Monte Carlo Dropout at $T=100$ on every window, following the chiller study, which reports 100% inclusion of the correct fault label across all 12 incipient cases while the non-dropout model failed on every SL1 case. It is the accuracy ceiling, not a cost competitor. Success means recovering at least 90% of its VUS-PR gain over the deterministic detector on held-out noise families, at an average of three or fewer passes per window.

A uniform low-sample baseline runs $T$ equal to the gated method's average pass count, around 2 to 3, on every window. This is the compute-matched competitor. The gated method must beat it in VUS-PR at matched mean passes, and also at matched 99th-percentile latency, since gating makes cost bursty.

Score-margin gating samples only when $|s_\theta - \tau|$ is small, with the margin set to hit the same budget $\rho$. This baseline isolates whether a learned trigger is needed at all.

A single-pass uncertainty head is trained with the predictive-plus-generalization-noise objective of Directly Optimizing Calibrated Test-Time Uncertainty and used as a direct variance-inflated score with no sampling. Its trigger-free variant is a variance head distilled from Monte Carlo targets on training-distribution noise only.

SISVAE represents explicit noise modeling. Its reported AUPRC on Yahoo A1 is 0.369, against 0.178 for Donut. Signature Isolation Forest represents fast, order-sensitive classical detection, running in 30 seconds on Handoutlines against roughly 10 minutes for an autoencoder. TAB's classical methods (KMeans, OCSVM) are included as well.

The key ablation is the same trigger architecture trained without the leave-one-family-out split, so that trigger and detector see the same noise. If this matches the held-out trigger on unseen families, our central ingredient is unnecessary.

All methods share backbones, data splits, a tuning budget of 50 configurations on the same validation families, and hardware, with latency measured on one GPU and one CPU core. For the strongest published numbers on our benchmarks, the Anomaly Transformer reports F1 of 92.33% on SMD and 96.69% on SMAP. These were obtained under the point-adjustment protocol that TAB criticizes, so we will not compare against them directly. No reported VUS-PR result was found on Lacuna for any of these methods under injected unseen noise, which means every comparison here must be rerun.

Why not just…?

Why not just run three dropout passes everywhere? At the same average cost, this is the obvious competitor. If decision-flipping windows are rare and need many samples to resolve, three uniform passes give a noisy variance estimate on every window and a good one on none. The chiller study's dependence on dropout rate and sample count suggests small $T$ is unreliable, but it did not test small $T$ directly. The compute-matched comparison settles this. If uniform $T=3$ matches gating, we report that and drop the trigger.

Why not just gate on the deterministic score margin? This is cheap and needs no training. The evidence against it is that deterministic networks are confidently wrong on incipient faults: 95% "normal" in the chiller study. Such windows sit far from the threshold and would never be sampled. We test this directly by measuring what fraction of decision-flipping windows fall outside the margin band. If most flips sit near the threshold, margin gating is enough and we say so.

Why not just learn a single-pass uncertainty head and skip sampling entirely? This is the real threat. The calibrated-uncertainty paper shows single-model calibration is achievable under its held-out objective, and if that transfers to sequential scores, gating adds nothing. Our concern is that a head is itself a deterministic function that must extrapolate to unseen noise, the same failure it is meant to fix. The SSEMS selector's collapse at low SNR is one instance of a learned quality judge failing out of distribution. The experiment is a direct comparison on held-out families. We commit in advance to abandoning gating if the head matches full Monte Carlo Dropout within the 90% recovery criterion.

Why not just use a classical detector, which is fast and has nothing to calibrate? TAB finds that classical methods often win on univariate data. Signature Isolation Forest handles order-swap anomalies cheaply. Against this, TAB and CATCH report that window-based classical methods do little better than random on shapelet and seasonal anomalies. These methods also offer no uncertainty signal for incipient faults. They are included as baselines, and on univariate subsets they may win; we will report that.

Proposed Experiments

The benchmarks are the TAB multivariate collection, focusing on SMD, SMAP, MSL, PSM, and SWaT, plus Yahoo A1, Open μPMU, EMG, and ASHRAE RP-1043. The chiller dataset matters most because its labeled severity levels let us measure incipient-fault recall directly, here treated as a sequence rather than static feature vectors. Following TAB, the primary metric is VUS-PR without point adjustment. Secondary measures are incipient-fault recall at fixed false-alarm rate, mean and 99th-percentile forward passes per window, wall-clock latency, and the trigger's precision and recall at identifying decision-flipping windows. Long-duration anomalies on SWaT, which CATCH reports absorbing into its normal baseline, are scored separately. Gating cannot fix a look-back window that is too short, and we expect no gain there.

The first decisive check is the compute-matched curve: VUS-PR on held-out noise families versus mean passes per window, for gated, uniform-$T$, and margin-gated inference. The proposal succeeds if the gated curve dominates across budgets from 1.5 to 5 passes and reaches 90% of the full-sampling gain by three passes.

The second check is the held-out-training ablation. The held-out-family trigger should beat the same-noise trigger on unseen families while matching it on seen ones. This would show that the leave-one-family-out objective is what makes the trigger work.

The third check is the head-to-head against the single-pass calibrated head. Its outcome decides whether this line of work should continue as gating or fold into single-model uncertainty.

A final stress test runs inference through regime switches: a stream that moves from a training noise family into an unseen one mid-sequence. It measures how many windows the trigger takes to start firing and whether its sampling rate returns to baseline once the new noise is learned through periodic retraining.