Class EarthMoversDistance
java.lang.Object
org.hipparchus.clustering.distance.EarthMoversDistance
- All Implemented Interfaces:
Serializable
,DistanceMeasure
Calculates the Earh Mover's distance (also known as Wasserstein metric) between two distributions.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiondouble
compute
(double[] a, double[] b) Compute the distance between two n-dimensional vectors.
-
Constructor Details
-
EarthMoversDistance
public EarthMoversDistance()Empty constructor.This constructor is not strictly necessary, but it prevents spurious javadoc warnings with JDK 18 and later.
- Since:
- 3.0
-
-
Method Details
-
compute
Compute the distance between two n-dimensional vectors.The two vectors are required to have the same dimension.
- Specified by:
compute
in interfaceDistanceMeasure
- Parameters:
a
- the first vectorb
- the second vector- Returns:
- the distance between the two vectors
- Throws:
MathIllegalArgumentException
- if the array lengths differ.
-