public class TaxicabDistance extends Object implements Distance<Vector>, Serializable
TaxicabDistance class implements standard taxicab,
or Manhattan distance between vectors. The taxicab distance forms
a metric. The taxicab distance is often called the
L1 distance, because it is 1-norm Minkowski
distance after the inventor of the general family of vector
distance metrics and related geometries.
The definition of the taxicab distance over vectors
v1 and v2 is:
withdistance(v1,v2) = Σi abs(v1[i] - v2[i])
v1[i] standing for the method call
v1.value(i) and i ranging over the
dimensions of the vectors, which must be the same.
An understandable explanation of the taxicab distance and related distances may be found at:
| Modifier and Type | Field and Description |
|---|---|
static TaxicabDistance |
DISTANCE
The taxicab distance.
|
| Constructor and Description |
|---|
TaxicabDistance()
Construct a new taxicab distance.
|
public static final TaxicabDistance 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.