hanr_fft_binseg_cusum: Anomaly Detector using FFT with BinSeg and CUSUM Cutoff

View source: R/hanr_fft_binseg_cusum.R

hanr_fft_binseg_cusumR Documentation

Anomaly Detector using FFT with BinSeg and CUSUM Cutoff

Description

This function implements an anomaly detection method that combines the Fast Fourier Transform (FFT) with a changepoint-based cutoff strategy using the Binary Segmentation (BinSeg) method applied to the cumulative sum (CUSUM) of the frequency spectrum.

The method first computes the FFT of the input time series and obtains its power spectrum. Then, it applies a CUSUM transformation to the spectral density to enhance detection of gradual transitions or accumulated changes in energy across frequencies. The Binary Segmentation method is applied to the CUSUM-transformed spectrum to identify a changepoint that defines a cutoff frequency.

Frequencies below this cutoff are removed from the spectrum, and the signal is reconstructed using the inverse FFT. This produces a filtered signal that retains only the high-frequency components, emphasizing potential anomalies.

Anomalies are then detected by measuring the deviation of the filtered signal from the original one, and applying an outlier detection mechanism based on this residual.

This function extends the HARBINGER framework and returns an object of class hanr_fft_binseg_cusum.

Usage

hanr_fft_binseg_cusum()

Value

hanr_fft_binseg_cusum object

Examples

library(daltoolbox)

#loading the example database
data(examples_anomalies)

#Using simple example
dataset <- examples_anomalies$simple
head(dataset)

# setting up time series fft detector
model <- hanr_fft_binseg_cusum()

# fitting the model
model <- fit(model, dataset$serie)

detection <- detect(model, dataset$serie)

# filtering detected events
print(detection[(detection$event),])


harbinger documentation built on June 8, 2025, 10:19 a.m.