analistica/ex-6/dist.h

21 lines
660 B
C
Raw Permalink Normal View History

#include <math.h>
#include <gsl/gsl_histogram.h>
/* Computes the earth mover's distance, aka 1-Wasserstein
* metric, of two histograms. It gives the minimum cost
* (weight * distance) associated to shifting around the
* weights of the bins to turn one histogram into the other.
*
* For a 1D normalised histogram the distance can be proven
* to be equal to the Lยน distance of the CDF. If the bins are
* equally sized this can be futher simplified to give a simple
* O(n) solution.
*/
2020-05-13 01:20:51 +02:00
double emd_between(gsl_histogram *a, gsl_histogram *b);
/* Normalise a histogram: ie rescaling the bin
* weights to sum to 1
*/
void normalise(gsl_histogram *h);