Exact Earth Mover's Distance (NOT Mallows Distance) Python Code

327 Views Asked by At

Is there any python library for computing EMD between two signatures? There are multiple options to compute EMD between two distributions (e.g. pyemd). But I didn't find any implementation for the exact EMD value. For example, consider Signature_1 = {(1,1), (4,1)} and Signature_2 = {(1,1), (2,1), (3,1), (4,1)}, where first coordinate is the position and second coordinate is the weight. True EMD(Signature_1, Signature_2) = 0 whereas if we consider these as distributions then the distance is 0.5 (the emd_samples in pyemd gives this answer). But I would be interested in the implementation of True EMD. Any help in this regard would be appreciated.

1

There are 1 best solutions below

0
On

No worries. I got the answer. You can just use "normalized" = False, "extra_mass_penalty" = 0 in the arguments of "emd_samples" function of pyemd.