com.aliasi.util
Interface Distance<E>

Type Parameters:
E - the type of objects over which distances are defined
All Known Implementing Classes:
EditDistance, EuclideanDistance, FixedWeightEditDistance, JaccardDistance, JaroWinklerDistance, MinkowskiDistance, TaxicabDistance, TfIdfDistance, TokenizedDistance, WeightedEditDistance

public interface Distance<E>

The Distance interface provides a general method for defining distances between two objects. Distance is a kind of dissimilarity measure, because the larger the distance between two objects, the less similar they are. The distance interface provides a single method distance(Object,Object) returning the distance between objects.

A proper distance is said to form a metric if it satisfies the following four properties:

For example, the Euclidean distance between vectors is a proper metric.

 distance(x,y) = sqrt(Σi (x[i] * y[i])2)
as is the Manhattan metric, or taxicab distance:
 distance(x,y) = Σi abs(x[i] - y[i])
Cosine is also popular for vectors:
 distance(x,y) = dotProduct(x,y) / (length(x) * length(y))

A good introduction to distance may be found at:

Since:
LingPipe3.0
Version:
3.0
Author:
Bob Carpenter

Method Summary
 double distance(E e1, E e2)
          Returns the distance between the specified pair of objects.
 

Method Detail

distance

double distance(E e1,
                E e2)
Returns the distance between the specified pair of objects.

Parameters:
e1 - First object.
e2 - Second object.
Returns:
Distance between the two objects.