Earth Mover's Distance (EMD)
This is a wrapper around
pyemd for computing the EMD (or Wasserstein)
By default, it uses Euclidean distance as a cost function, but this
can be changed by using the generic distance function
It allows computing the distance between two vectors (e.g., histograms):
extern crate emd; #[macro_use(array)] extern crate ndarray; use emd::*; use ndarray::*; let x = array![0., 1.]; let y = array![5., 3.]; assert_eq!(distance(&x.view(), &y.view()), 3.5);
Or between matrices (e.g., multivariate histograms). Note that in this case the two matrices must have the same number of columns.
extern crate emd; #[macro_use(array)] extern crate ndarray; use emd::*; use ndarray::*; let x = array![[4., 3.], [3., 6.], [2., 3.]]; let y = array![[2., 3.], [1., 3.]]; assert_eq!(distance_multi(&x.view(), &y.view()), 2.035183758487996);
Alternatively, one can compute EMD for matrices (and, by extension,
vectors) with a chosen distance as cost function by using
Computes the EMD between two vectors.
Computes the EMD with a desired cost function (i.e., distance).
Computes the EMD between two matrices.
Returns the Euclidean distance between two vectors of f64 values.