public class MinkowskiDistance extends Object implements Distance<Vector>, Serializable
MinkowskiDistanceclass implements Minkowski distance of a fixed order between vectors. or Manhattan distance between vectors. Minkowski distance of any order forms a metric. The Minkowski distance of order
pis often called
Minkowski distance generalizes taxicab and Euclidean distance,
which are just the Minkowski distances of order 1 and 2
respectively. For orders 1 and 2, the taxicab and Euclidean
EuclideanDistance are more efficient in that they do not require
exponentiation to be calculated.
The definition of Minkowski distance of order
withdistance(v1,v2,p) = (Σi abs(v1[i] - v2[i])p)(1/p)
v1[i]standing for the method call
iranging over the dimensions of the vectors, which must be the same.
An understandable explanation of the Minkowski distances,
including the special cases of Taxicab (
and Euclidean (
L2 norm) may be
|Constructor and Description|
Construct a new Minkowski distance of the specified order.
|Modifier and Type||Method and Description|
Returns the Minkowski distance between the specified pair of vectors.
Returns the order of this Minkowski distance.
public MinkowskiDistance(int order)
order- Order of metric.
IllegalArgumentException- If the order is not 1 or greater.
public int order()