get_earthmover_distance - Computes the earthmover's distance.


#include "lsm/lsm_emd.h"

Example compile flags (system dependent):
   -L/home/kobus/misc/load/linux_x86_64_opteron -L/usr/lib/x86_64-linux-gnu
  -lKJB                               -lfftw3  -lgsl -lgslcblas -ljpeg  -lSVM -lstdc++                    -lpthread -lSLATEC -lg2c    -lacml -lacml_mv -lblas -lg2c      -lncursesw 

int get_earthmover_distance
	Signature *sig1,
	Signature *sig2,
	int (*distance_fn)(Vector *,Vector *,double *),
	Flow *flow_vec,
	int *num_flows_ptr,
	double *em_distance_ptr


Signature *sig1
First input signature
Signature *sig2
Second input signature
Flow *flow_vec
Output array of flows
int *num_flows_ptr
Number of valid flows
double *em_distance_ptr
Earthmover's Distance


This routine computes the earthmover's distance between two distributions. Distributions are stored in "signatures" which consist of an array of "features" and a corresponding array of feature weights. In the emd_lib.c module, a "feature" is simply a "Vector". A "signature" is defined as follows: | typedef struct Signature
        int      num_features; Number of features in the signature
        Vector** feature_vec;  Pointer to array of features
        double*    weights_vec;  Pointer to array of feature weights
    } Signature;
Each feature in a signature has a corresponding weight indicating its relative abundance in the distribution. A distance function must be supplied that computes the distance between two features. A function that computes the Euclidean distance between two features as defined above is provided: See the "distance" function. This routine will optionally return the flow that was required to map one input distribution to the other. If "flow_vec" is NULL, then no flow is computed. If output flows are required, then "flow_vec" must be preallocated, and contain n1 + n2 - 1 elements, where n1 and n2 are the numbers of elements in the two input signatures. Note that the earthmover's distance is a true metric ONLY when the two input signatures are the same size. Uses code written by Yosi Rubner. See


Either NO_ERROR, or ERROR, with an appropriate error message being set.


This software is not adequatedly tested. It is recomended that results are checked independantly where appropriate.


Yossi Rubner, Lindsay Martin


Lindsay Martin


euclidean_distance , get_target_signature , free_signature , copy_signature , set_signature_features , set_signature_weights , get_target_signature_db