org.apache.commons.math3.ml.distance

## Class EuclideanDistance

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

- All Implemented Interfaces:
    Serializable, DistanceMeasure

      public class EuclideanDistance
      extends Object
      implements DistanceMeasure

  Calculates the L2 (Euclidean) distance between two points.
  Since:
    3.2
  See Also:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `EuclideanDistance()`

  - ### 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

    - #### EuclideanDistance

          public EuclideanDistance()

  - ### Method Detail

    - #### compute

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

      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:
        `DimensionMismatchException` - if the array lengths differ.

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