de.aitools.aq.algebra.vector.functions
Class ManhattanDistance

java.lang.Object
  extended by de.aitools.aq.algebra.vector.functions.ManhattanDistance
All Implemented Interfaces:
Distance<Vector>, Proximity<Vector>

public final class ManhattanDistance
extends java.lang.Object
implements Distance<Vector>

A Distance measure for Vectors.
The Manhattan Distance of two points is defined as the sum of the lengths of the projections of the segment between them onto the coordinate system axis. In the vector application, for each vector the point is taken that would be the position of a point translated from the origin by the vector.
It is calculated as the sum of the absolute differences of each coordinate of the vectors.
If one vector is of a lower dimension (range) than the other vector, the missing dimensions of the vector will be treated as zero.
The Proximity of two vectors is computed as the negative similarity. The normalized proximity is one minus the distance divided by the highest double value (Double.MAX_VALUE). And it is 0 if the distance would be infinite.

Version:
$Id: ManhattanDistance.java,v 1.3 2011/02/24 17:48:08 dogu3912 Exp $
Author:
johannes.kiesel(/\t)uni-weimar.de

Constructor Summary
ManhattanDistance()
          Construct a new ManhattanDistance.
 
Method Summary
 double computeDistance(Vector v1, Vector v2)
          Compute a kind of distance between two objects.
 double computeNormalizedProximity(Vector v1, Vector v2)
          Compute a kind of proximity between two objects.
The value returned by this method has to be between 0 (meaning they are as far away (according to the proximity measure) from each other as possible) and 1 (identical objects according to the proximity measure).
 double computeProximity(Vector v1, Vector v2)
          Compute a kind of proximity between two objects.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ManhattanDistance

public ManhattanDistance()
Construct a new ManhattanDistance.

Method Detail

computeDistance

public double computeDistance(Vector v1,
                              Vector v2)
Description copied from interface: Distance
Compute a kind of distance between two objects. A higher value signals higher distance.

Specified by:
computeDistance in interface Distance<Vector>
Parameters:
v1 - One object, to be compared to the...
v2 - ...second object
Returns:
Computed distance

computeProximity

public double computeProximity(Vector v1,
                               Vector v2)
Description copied from interface: Proximity
Compute a kind of proximity between two objects. A higher value signals higher proximity.

Specified by:
computeProximity in interface Proximity<Vector>
Parameters:
v1 - One object, to be compared to the...
v2 - ...second object
Returns:
Computed proximity

computeNormalizedProximity

public double computeNormalizedProximity(Vector v1,
                                         Vector v2)
Description copied from interface: Proximity
Compute a kind of proximity between two objects.
The value returned by this method has to be between 0 (meaning they are as far away (according to the proximity measure) from each other as possible) and 1 (identical objects according to the proximity measure).

Specified by:
computeNormalizedProximity in interface Proximity<Vector>
Parameters:
v1 - One object, to be compared to the...
v2 - ...second object
Returns:
Computed normalized proximity