ts_fil_gabor: One-Dimensional Gabor Filter

View source: R/ts_fil_gabor.R

ts_fil_gaborR Documentation

One-Dimensional Gabor Filter

Description

Smooth a time series with a one-dimensional Gabor kernel, which combines a Gaussian envelope with a cosine carrier to perform localized frequency-aware smoothing.

Usage

ts_fil_gabor(window_size = 3, central_frequency = 0.1)

Arguments

window_size

Positive numeric value. Standard deviation of the Gaussian envelope, in observations. Larger values use a wider local window.

central_frequency

Numeric value in ⁠[0, 0.5]⁠. Central frequency of the cosine carrier, expressed in cycles per observation. Values close to zero behave more like Gaussian smoothing; larger values emphasize oscillatory local structure.

Details

The filter builds a symmetric kernel g(t) = exp(-t^2 / (2 * window_size^2)) * cos(2 * pi * central_frequency * t) over a finite window of radius 3 * window_size. The kernel is normalized to preserve the local level when its sum is non-zero, then applied by centered convolution with reflected boundary padding. The reflected padding reduces edge artifacts without changing the output length.

This implementation is intended for offline smoothing. Because it uses a centered window, values near time t depend on observations on both sides of t. Use it before fitting a forecasting model, not as a causal real-time filter.

Value

A ts_fil_gabor object.

References

  • D. Gabor (1946). Theory of communication. Journal of the Institution of Electrical Engineers - Part III: Radio and Communication Engineering, 93, 429-457.

Examples

# Gabor smoothing on a noisy seasonal signal
library(daltoolbox)
library(tspredit)
x <- seq(0, 6 * pi, length.out = 120)
y <- sin(x) + 0.3 * sin(8 * x)

filter <- ts_fil_gabor(window_size = 3, central_frequency = 0.05)
filter <- daltoolbox::fit(filter, y)
yhat <- transform(filter, y)

plot_ts_pred(y = y, yadj = yhat)

tspredit documentation built on Sept. 9, 2026, 9:08 a.m.