主要内容

NoiseAnomaly

Synthetic noise anomaly model for validating anomaly detection models

Since R2026a

Description

Add-On Required: This feature requires the Time Series Anomaly Detection for MATLAB add-on.

The NoiseAnomaly object specifies the characteristics of an additive noise anomaly model that you can inject into a time series using injectAnomaly. Name-value argument specifications in injectAnomaly determine the window location and length during which the anomaly occurs.

Plot of a noise anomaly within a constant signal. The noise spikes are near the center.

You create this model using syntheticAnomaly. NoiseAnomaly is one type of anomaly model in a set of anomaly objects that you can use to perturb a time series in multiple ways. You can then use this perturbed time series to help validate anomaly detection models against different anomaly types.

For an example of creating a synthetic anomaly object, see Create and Inject Synthetic Anomaly Models

Properties

expand all

Noise type, represented as "White" or "Burst". For either noise type, the noise has a Gaussian distribution.

  • When Type is set to "White", injectAnomalyadds the noise over the entire window length that is specified in injectAnomaly.

  • When Type is set to "Burst", the noise is added in bursts that are specified in NumBursts and BurstDuration. The burst locations are selected with a uniform distribution.

Mean for the Gaussian noise, represented as 0 or a numeric scalar.

Standard deviation for the Gaussian noise, represented as 0 or a numeric scalar.

Number of noise bursts to inject when Type is set to "Burst", represented as an integer.

Duration of each noise burst, in number of samples, when Type is set to "Burst".

Object Functions

injectAnomaly Inject anomalies defined by one or more anomaly models into a univariate time series

Examples

collapse all

Create a NoiseAnomaly model that models white noise that has a standard deviation and a mean of 3.0.

noiseanom = syntheticAnomaly("Noise",Type="White",Std=3,Mean = 3.0);

Create a "StuckAtConstant" model that sticks at a custom constant of 1.5.

sacanom = syntheticAnomaly("StuckAtConstant",Type="Custom",Value=1.5);

Combine the anomalies into a vector so that they can be injected together into a time series.

anomvec = [noiseanom sacanom]
anomvec = 
1×2 AnomalyTypes:

 NoiseAnomaly, StuckAtConstantAnomaly

Load and plot the healthy single-variable time series channel1, which serves as the injection target.

load HealthySineWaveU channel1

Plot the time series.

plot(channel1)
title("Healthy Time Series")

Figure contains an axes object. The axes object with title Healthy Time Series contains an object of type line.

Inject the anomalies into channel1. For example repeatability, specify starting positions for the two anomalies.

[channel1_anom,labels] = injectAnomaly(anomvec,channel1,WindowStart=[185 1080]);

The resulting signal is channel1_anom. The labels output identifies where the anomalies are injected.

ianom = find(labels==1);
ianom(1:8)
ans = 8×1

   185
   186
   187
   188
   189
   190
   191
   192

plot(channel1_anom)

Figure contains an axes object. The axes object contains an object of type line.

The anomalies appear where WindowStart specifies.

Version History

Introduced in R2026a