|
Mobios v0.91 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectmobios.dist.LMetric
public class LMetric
This class computes the L family distance function on two vectors. Given two vectors x(x1,x2,...,xk), y(y1,y2,...,yk), the distance between x,y: Ls(x,y) = sum( |xi-yi|^s )^(1/s), i= 1,..,k where s=1,2,...,infinity. For infinite distance, L(x,y) = max( |xi-yi| ), i = 1,...,k. L1 is called Manhattan distance, L2 is called Euclidean distance. In this implementation, L0 is used to represent L infinity.
| Field Summary | |
|---|---|
static LMetric |
EuclideanDistanceMetric
L2 distance (Euclidean distance) metric for two non-null double arrays of the same length. |
static LMetric |
LInfinityDistanceMetric
L infinity distance metric for two non-null double arrays of the same length. |
static LMetric |
ManhattanDistanceMetric
L1 distance (Manhattan distance) metric for two non-null double arrays of the same length. |
| Constructor Summary | |
|---|---|
LMetric(int dim)
Constructor. |
|
| Method Summary | |
|---|---|
int |
getDimension()
|
double |
getDistance(double[] a1,
double[] a2)
Computes the distance between two double arrays with the same dimension. |
double |
getDistance(DoubleVector dv1,
DoubleVector dv2)
Computes the distance between two DoubleVectors with the same dimension. |
double |
getDistance(IndexObject o1,
IndexObject o2)
Computes the distance between two objects. |
static void |
main(String[] args)
main method, for test, 3 arguments argument 1: dimension of the metric argument 2,3: the two vectors, dimension by dimension, seperated by comma, no space. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final LMetric ManhattanDistanceMetric
public static final LMetric EuclideanDistanceMetric
public static final LMetric LInfinityDistanceMetric
| Constructor Detail |
|---|
public LMetric(int dim)
dim - the dimension of the distance function| Method Detail |
|---|
public double getDistance(IndexObject o1,
IndexObject o2)
Metric
getDistance in interface Metrico1 - the first IndexObject to compute distance ono2 - the second IndexObject to compute distance on
public double getDistance(DoubleVector dv1,
DoubleVector dv2)
DoubleVectors with the same dimension.
dv1 - the first DoubleVector to compute distance on.dv2 - the second DoubleVector to compute distance on.
DoubleVectors
public double getDistance(double[] a1,
double[] a2)
a1 - the first double arraya2 - the second double array
public int getDimension()
public static void main(String[] args)
|
Mobios v0.91 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||