gov.sandia.cognition.learning.function.distance
Class ManhattanDistanceMetric

java.lang.Object
  extended by gov.sandia.cognition.util.AbstractCloneableSerializable
      extended by gov.sandia.cognition.learning.function.distance.ManhattanDistanceMetric
All Implemented Interfaces:
DivergenceFunction<Vectorizable,Vectorizable>, Metric<Vectorizable>, Semimetric<Vectorizable>, CloneableSerializable, Serializable, Cloneable

public class ManhattanDistanceMetric
extends AbstractCloneableSerializable
implements Metric<Vectorizable>

The ManhattanDistanceMetric class implements a distance metric between two vectors that is implemented as the sum of the absolute value of the difference between the elements in the vectors. This is also known as the city-block distance, taxicab distance, rectilinear distance, L1 distance, and absolute value distance. d(x, y) = sum_{i=1 to d} |x_i - y_i|

Since:
2.1
Author:
Justin Basilico
See Also:
Serialized Form

Field Summary
static ManhattanDistanceMetric INSTANCE
          An instance of the ManhattanDistanceMetric to use since this class has no internal data.
 
Constructor Summary
ManhattanDistanceMetric()
          Creates a new instance of ManhattanDistanceMetric.
 
Method Summary
 double evaluate(Vectorizable first, Vectorizable second)
          Evaluates the Manhattan distance between the two given vectors.
 
Methods inherited from class gov.sandia.cognition.util.AbstractCloneableSerializable
clone
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface gov.sandia.cognition.util.CloneableSerializable
clone
 

Field Detail

INSTANCE

public static final ManhattanDistanceMetric INSTANCE
An instance of the ManhattanDistanceMetric to use since this class has no internal data.

Constructor Detail

ManhattanDistanceMetric

public ManhattanDistanceMetric()
Creates a new instance of ManhattanDistanceMetric.

Method Detail

evaluate

public double evaluate(Vectorizable first,
                       Vectorizable second)
Evaluates the Manhattan distance between the two given vectors.

Specified by:
evaluate in interface DivergenceFunction<Vectorizable,Vectorizable>
Parameters:
first - The first Vector.
second - The second Vector.
Returns:
The Manhattan distance between the two given vectors.