public class MatrixWeightedQuadraticDistanceFunction extends AbstractNumberVectorDistanceFunction implements Norm<NumberVector>
MahalanobisDistanceFunction
.
For a weight matrix M, this distance is defined as
\[ \text{Mahalanobis}^2_M(\vec{x},\vec{y}) := (\vec{x}-\vec{y})^T * M *
(\vec{x}-\vec{y}) \]
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.Modifier and Type | Field and Description |
---|---|
protected double[][] |
weightMatrix
The weight matrix.
|
Constructor and Description |
---|
MatrixWeightedQuadraticDistanceFunction(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 |
equals(java.lang.Object obj) |
VectorFieldTypeInformation<? super NumberVector> |
getInputTypeRestriction()
Get the input data type of the function.
|
int |
hashCode() |
boolean |
isSquared()
Squared distances, that would become metric after square root.
|
double |
norm(NumberVector obj)
Compute the norm of object obj.
|
dimensionality, dimensionality, dimensionality, dimensionality, dimensionality, dimensionality, dimensionality, dimensionality
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
instantiate
isMetric, isSymmetric
public MatrixWeightedQuadraticDistanceFunction(double[][] weightMatrix)
weightMatrix
- weight matrixpublic double distance(NumberVector o1, NumberVector o2)
PrimitiveDistanceFunction
distance
in interface NumberVectorDistanceFunction<NumberVector>
distance
in interface PrimitiveDistanceFunction<NumberVector>
o1
- first DatabaseObjecto2
- second DatabaseObjectpublic boolean isSquared()
DistanceFunction
isSquared
in interface DistanceFunction<NumberVector>
true
when squared.public double norm(NumberVector obj)
Norm
norm
in interface Norm<NumberVector>
obj
- Objectpublic boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public VectorFieldTypeInformation<? super NumberVector> getInputTypeRestriction()
DistanceFunction
getInputTypeRestriction
in interface DistanceFunction<NumberVector>
getInputTypeRestriction
in interface PrimitiveDistanceFunction<NumberVector>
getInputTypeRestriction
in class AbstractNumberVectorDistanceFunction
Copyright © 2019 ELKI Development Team. License information.