Class EuclideanDistance

java.lang.Object
org.hipparchus.clustering.distance.EuclideanDistance
All Implemented Interfaces:
Serializable, DistanceMeasure

public class EuclideanDistance extends Object implements DistanceMeasure
Calculates the L2 (Euclidean) distance between two points.
See Also:
  • Constructor Details

    • EuclideanDistance

      public EuclideanDistance()
      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

      public double compute(double[] a, double[] b) throws MathIllegalArgumentException
      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
      Throws:
      MathIllegalArgumentException - if the array lengths differ.