public class ManhattanDistanceMetric extends AbstractCloneableSerializable implements Metric<Vectorizable>
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|Modifier and Type | Field and Description |
---|---|
static ManhattanDistanceMetric |
INSTANCE
An instance of the
ManhattanDistanceMetric to use since this
class has no internal data. |
Constructor and Description |
---|
ManhattanDistanceMetric()
Creates a new instance of
ManhattanDistanceMetric . |
Modifier and Type | Method and Description |
---|---|
double |
evaluate(Vectorizable first,
Vectorizable second)
Evaluates the Manhattan distance between the two given vectors.
|
clone
public static final ManhattanDistanceMetric INSTANCE
ManhattanDistanceMetric
to use since this
class has no internal data.public ManhattanDistanceMetric()
ManhattanDistanceMetric
.public double evaluate(Vectorizable first, Vectorizable second)
evaluate
in interface DivergenceFunction<Vectorizable,Vectorizable>
first
- The first Vector.second
- The second Vector.