|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.aliasi.matrix.MinkowskiDistance
public class MinkowskiDistance
The MinkowskiDistance class 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 p is often called
Lp or the p-norm distance.
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
distance classes TaxicabDistance and EuclideanDistance are more efficient in that they do not require
exponentiation to be calculated.
The definition of Minkowski distance of order p
over vectors v1 and v2 is:
withdistance(v1,v2,p) = (Σi abs(v1[i] - v2[i])p)(1/p)
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 Minkowski distances,
including the special cases of Taxicab (L1 norm)
and Euclidean (L2 norm) may be
found at:
| Constructor Summary | |
|---|---|
MinkowskiDistance(int order)
Construct a new Minkowski distance of the specified order. |
|
| Method Summary | |
|---|---|
double |
distance(Vector v1,
Vector v2)
Returns the Minkowski distance between the specified pair of vectors. |
int |
order()
Returns the order of this Minkowski distance. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public MinkowskiDistance(int order)
order - Order of metric.
IllegalArgumentException - If the order is not 1 or greater.| Method Detail |
|---|
public int order()
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.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||