Measure the distance between two spectra/signals using optimal transport and related metrics
Author baggepinnen
20 Stars
Updated Last
10 Months Ago
Started In
September 2019

CI codecov

This repository implements all optimal-transport based distances between spectra detailed in the following pre print

"New Metrics Between Rational Spectra and their Connection to Optimal Transport", Bagge Carlson and Chitre 2020

Supplementary material to the paper is provided in a separate repository.

The package also contains a number of generic solvers for optimal transport problems:

  • Fixed support in 1d (histograms)
  • Varying discrete support (atoms/dirac masses) with non-uniform masses in any dimension
  • Barycenters supported on fixed number of atoms, but possibly with non-uniform masses
  • Barycentric coordinates
  • Continuous support in 1d

See the documentation for instructions.


using Pkg
pkg"add SpectralDistances"


Interpolation between two rational spectra under four different metrics.


Barycenter of three spectra and mixed spectrum which can be decomposed into a combination of the three input spectra

Example: Barycentric interpolation of spectrograms

The image below illustrates interpolation between 4 Mel spectrograms, each one representing a short whistle. See the folder examples for the code.


See the docs for more examples.