org.apache.commons.math3.ml.distance

## Class EarthMoversDistance

- java.lang.Object
- - org.apache.commons.math3.ml.distance.EarthMoversDistance

- All Implemented Interfaces:
    Serializable, DistanceMeasure

      public class EarthMoversDistance
      extends Object
      implements DistanceMeasure

  Calculates the Earh Mover's distance (also known as Wasserstein metric) between two distributions.
  Since:
    3.3
  Version:
    $Id: EarthMoversDistance.java 1519185 2013-08-31 15:32:49Z tn $
  See Also:
    Earth Mover's distance (Wikipedia), Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `EarthMoversDistance()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `double` | `compute(double[] a, double[] b)` Compute the distance between two n-dimensional vectors.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### EarthMoversDistance

          public EarthMoversDistance()

  - ### Method Detail

    - #### compute

          public double compute(double[] a,
                       double[] b)

      Compute the distance between two n-dimensional vectors.

      The two vectors are required to have the same dimension.

      Specified by:
        `compute` in interface `DistanceMeasure`
      Parameters:
        `a` - the first vector
        `b` - the second vector
      Returns:
        the distance between the two vectors

Copyright © 2003–2014 The Apache Software Foundation. All rights reserved.