public class EuclideanDistance extends Object implements Distance<Vector>, Serializable
EuclideanDistance class implements standard
Euclidean distance between vectors. Euclidean distance forms a
metric. Euclidean distance is often called the
L2 distance, because it is 2-norm Minkowski
distance.
The definition of Euclidean distance over vectors
v1 and v2 is:
withdistance(v1,v2) = sqrt(Σi (v1[i] - v2[i])2 )
v1[i] standing for the method call
v1.value(i) and i ranging over the
dimensions of the vectors, which must be the same.
Note that the Euclidean distance is equivalent to the
Minkowski distance metric of order 2. See the class
documentation for MinkowskiDistance for more information.
An understandable explanation of Euclidean and related distances may be found at:
| Modifier and Type | Field and Description |
|---|---|
static EuclideanDistance |
DISTANCE
The Euclidean distance.
|
| Constructor and Description |
|---|
EuclideanDistance()
Construct a new Euclidean distance.
|
public static final EuclideanDistance DISTANCE
public double distance(Vector v1, Vector v2)
distance in interface Distance<Vector>v1 - First vector.v2 - Second vector.IllegalArgumentException - If the vectors are not of the
same dimensionality.Copyright © 2016 Alias-i, Inc.. All rights reserved.