All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.TKnudsen.ComplexDataObject.model.distanceMeasure.Double.EarthMoverDistance Maven / Gradle / Ivy

Go to download

A library that models real-world objects in Java, referred to as ComplexDataObjects. Other features: IO and preprocessing of ComplexDataObjects.

The newest version!
package com.github.TKnudsen.ComplexDataObject.model.distanceMeasure.Double;

import org.apache.commons.math3.ml.distance.EarthMoversDistance;

public class EarthMoverDistance extends DoubleDistanceMeasure {

	/**
	 * 
	 */
	private static final long serialVersionUID = -9139238493346028987L;

	EarthMoversDistance emd = new EarthMoversDistance();

	@Override
	public double getDistance(double[] o1, double[] o2) {
		if (o1 == null || o2 == null)
			throw new NullPointerException(getName() + ": given array was null");

		if (o1.length != o2.length)
			throw new IllegalArgumentException(getName() + ": given arrays have different length");

		return emd.compute(o1, o2);
	}

	@Override
	public String getName() {
		return "Earth Mover Distance";
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy