@Reference(authors="P. C. Mahalanobis", title="On the generalized distance in statistics", booktitle="Proceedings of the National Institute of Sciences of India. 2 (1)", bibkey="journals/misc/Mahalanobis36") public class MahalanobisDistanceFunction extends MatrixWeightedQuadraticDistanceFunction
For a weight matrix M, this distance is defined as \[ \text{Mahalanobis}_M(\vec{x},\vec{y}) := \sqrt{(\vec{x}-\vec{y})^T \cdot M \cdot (\vec{x}-\vec{y})} \]
Reference:
P. C. Mahalanobis
On the generalized distance in statistics
Proceedings of the National Institute of Sciences of India. 2 (1)
This is the implementation as quadratic form distance function. In many cases
it will be more convenient to use the static function
VMath.mahalanobisDistance(double[][], double[], double[])
instead.
TODO: Add a factory with parameterizable weight matrix! Right now, this can only be used from Java and from subclasses, not from command line or MiniGUI.
weightMatrix
Constructor and Description |
---|
MahalanobisDistanceFunction(double[][] weightMatrix)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
double |
distance(NumberVector o1,
NumberVector o2)
Computes the distance between two given DatabaseObjects according to this
distance function.
|
boolean |
isMetric()
Is this distance function metric (satisfy the triangle inequality)
|
boolean |
isSquared()
Squared distances, that would become metric after square root.
|
double |
norm(NumberVector obj)
Compute the norm of object obj.
|
equals, getInputTypeRestriction, hashCode
dimensionality, dimensionality, dimensionality, dimensionality, dimensionality, dimensionality, dimensionality, dimensionality
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
instantiate
isSymmetric
public MahalanobisDistanceFunction(double[][] weightMatrix)
weightMatrix
- Weight matrix.public double distance(NumberVector o1, NumberVector o2)
PrimitiveDistanceFunction
distance
in interface NumberVectorDistanceFunction<NumberVector>
distance
in interface PrimitiveDistanceFunction<NumberVector>
distance
in class MatrixWeightedQuadraticDistanceFunction
o1
- first DatabaseObjecto2
- second DatabaseObjectpublic double norm(NumberVector obj)
Norm
norm
in interface Norm<NumberVector>
norm
in class MatrixWeightedQuadraticDistanceFunction
obj
- Objectpublic boolean isMetric()
DistanceFunction
true
when metric.public boolean isSquared()
DistanceFunction
isSquared
in interface DistanceFunction<NumberVector>
isSquared
in class MatrixWeightedQuadraticDistanceFunction
true
when squared.Copyright © 2019 ELKI Development Team. License information.