The Wasserstein-Fourier Distance for Stationary Time Series

Elsa Cazelles, Arnaud Robert, Felipe Tobar

Abstract

We propose the Wasserstein-Fourier (WF) distance to measure the (dis)similarity between time series by quantifying the displacement of their energy across frequencies. The WF distance operates by calculating the Wasserstein distance between the (normalised) power spectral densities (NPSD) of time series. Yet this rationale has been considered in the past, we fill a gap in the open literature providing a formal introduction of this distance, together with its main properties from the joint perspective of Fourier analysis and optimal transport. As the main aim of this work is to validate WF as a general-purpose metric for time series, we illustrate its applicability on three broad contexts. First, we rely on WF to implement a PCA-like dimensionality reduction for NPSDs which allows for meaningful visualisation and pattern recognition applications. Second, we show that the geometry induced by WF on the space of NPSDs admits a geodesic interpolant between time series, thus enabling data augmentation on the spectral domain, by averaging the dynamic content of two signals. Third, we implement WF for time series classification using parametric/non-parametric classifiers and compare it to other classical metrics. Supported on theoretical results, as well as synthetic illustrations and experiments on real-world data, this work establishes WF as a meaningful and capable resource pertinent to general distance-based applications of time series.

Introduction

Traditional methods for comparing time series in the spectral domain—such as Euclidean distance, Kullback-Leibler (KL) divergence, or Itakura-Saito (IS) distance—are primarily "vertical" metrics. They compare the power of two signals at the exact same frequency. This approach has a major flaw: if two signals have similar shapes but are slightly shifted in frequency (e.g., two bird calls at different pitches), vertical distances will see them as completely different because their "peaks" do not overlap. Furthermore, these metrics often require signals to share the same "support," making them brittle when dealing with real-world noise or varying acquisition conditions.

Comparison of vertical and horizontal distances between spectral densities. Vertical distances compare values at fixed frequencies, while horizontal distances measure the displacement of energy.

The Wasserstein-Fourier (WF) distance addresses this by providing a "horizontal" distance that quantifies the displacement of energy, effectively capturing how much one spectrum must be "warped" to match another. This creates an equivalence class for time series where signals shifted in time or scaled in magnitude are treated as identical, focusing instead on the intrinsic "shape" of the oscillation.

Methods

The core of the framework involves converting a signal's Power Spectral Density (PSD) into a Normalized PSD (NPSD), treating the distribution of energy like a probability distribution. The $W_2$ Wasserstein distance is then calculated between these NPSDs. Because NPSDs are one-dimensional distributions, the Wasserstein distance has a closed-form solution using inverse cumulative distribution functions (CDFs), ensuring computational efficiency with linear complexity.

The authors extend this distance into three specific frameworks:

  1. Geodesic Interpolation: Creating "in-between" signals that smoothly transition frequencies.
  2. Principal Geodesic Analysis (PGA): A non-linear version of PCA designed for the Wasserstein space, allowing for dimensionality reduction that respects spectral geometry.
  3. Spectral Classifiers: Equipping standard models like K-Nearest Neighbors (KNN) and Logistic Regression with the WF distance.

Key Results and Applications

The WF distance was validated across diverse datasets, including synthetic signals, C. elegans behavioral data, fungal melt curves, and urban sounds.

Sparse Interpolation

A key advantage of the WF distance is its behavior during interpolation. Unlike Euclidean interpolation, which creates "ghosting" (a blurry superposition of two signals), WF interpolation moves the energy peaks. For example, when interpolating between a 10Hz and 20Hz signal, the WF midpoint is a 15Hz signal, whereas the Euclidean midpoint is a weak 10Hz signal mixed with a weak 20Hz signal.

Comparison of geodesic interpolation using Wasserstein-Fourier (top) vs. Euclidean (bottom) distances on real worm signals. The WF method smoothly transitions the signal features, whereas the Euclidean method results in a superposition of the two source signals.

Classification and Robustness

On the UrbanSound8k dataset, the WF-based KNN classifier was a top performer, particularly when aggregated with other distances. In synthetic tests, PGA using the WF distance was able to linearly separate cosine signals from sinc signals, a task where standard Functional PCA (FPCA) failed. The metric also proved highly effective for the GunPoint dataset, showing tighter error bars and higher accuracy in body motion classification compared to traditional distances.

Conclusion

The Wasserstein-Fourier distance offers a robust alternative to vertical spectral metrics by focusing on the horizontal displacement of energy. While it provides significant advantages in robustness to frequency shifts and data augmentation, it currently ignores phase information and absolute magnitude. Future work will explore "unbalanced" optimal transport to compare signals without normalization and develop new training procedures for Gaussian Processes based on these geodesic paths.

Summary updated

Abstract

We propose the Wasserstein-Fourier (WF) distance to measure the (dis)similarity between time series by quantifying the displacement of their energy across frequencies. The WF distance operates by calculating the Wasserstein distance between the (normalised) power spectral densities (NPSD) of time series. Yet this rationale has been considered in the past, we fill a gap in the open literature providing a formal introduction of this distance, together with its main properties from the joint perspective of Fourier analysis and optimal transport. As the main aim of this work is to validate WF as a general-purpose metric for time series, we illustrate its applicability on three broad contexts. First, we rely on WF to implement a PCA-like dimensionality reduction for NPSDs which allows for meaningful visualisation and pattern recognition applications. Second, we show that the geometry induced by WF on the space of NPSDs admits a geodesic interpolant between time series, thus enabling data augmentation on the spectral domain, by averaging the dynamic content of two signals. Third, we implement WF for time series classification using parametric/non-parametric classifiers and compare it to other classical metrics. Supported on theoretical results, as well as synthetic illustrations and experiments on real-world data, this work establishes WF as a meaningful and capable resource pertinent to general distance-based applications of time series.
BibTeX
@article{cazelles2021wasserstein,
  author = {Elsa Cazelles and Arnaud Robert and Felipe Tobar},
  title = {{The Wasserstein-Fourier Distance for Stationary Time Series}},
  journal = {IEEE Trans. Signal Process.},
  year = {2021},
  url = {https://openreview.net/forum?id=TMiUeOzdf8a},
}
Figure