Package elki.distance

• All Implemented Interfaces:
Distance<NumberVector>, Norm<NumberVector>, NumberVectorDistance<NumberVector>, PrimitiveDistance<NumberVector>
Direct Known Subclasses:
HSBHistogramQuadraticDistance, MahalanobisDistance, RGBHistogramQuadraticDistance

public class MatrixWeightedQuadraticDistance
extends AbstractNumberVectorDistance
implements Norm<NumberVector>
Matrix weighted quadratic distance, the squared form of MahalanobisDistance. 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.
Since:
0.1
Author:
Elke Achtert
• ### Field Summary

Fields
Modifier and Type Field Description
protected double[][] weightMatrix
The weight matrix.
• ### Constructor Summary

Constructors
Constructor Description
MatrixWeightedQuadraticDistance​(double[][] weightMatrix)
Constructor.
• ### Method Summary

All Methods
Modifier and Type Method 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.
• ### Methods inherited from class elki.distance.AbstractNumberVectorDistance

dimensionality, dimensionality, dimensionality, dimensionality, dimensionality, dimensionality, dimensionality, dimensionality
• ### Methods inherited from class java.lang.Object

clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
• ### Methods inherited from interface elki.distance.Distance

isMetric, isSymmetric
• ### Methods inherited from interface elki.distance.PrimitiveDistance

instantiate
• ### Field Detail

• #### weightMatrix

protected double[][] weightMatrix
The weight matrix.
• ### Constructor Detail

public MatrixWeightedQuadraticDistance​(double[][] weightMatrix)
Constructor.
Parameters:
weightMatrix - weight matrix
• ### Method Detail

• #### distance

public double distance​(NumberVector o1,
NumberVector o2)
Description copied from interface: PrimitiveDistance
Computes the distance between two given DatabaseObjects according to this distance function.
Specified by:
distance in interface NumberVectorDistance<NumberVector>
Specified by:
distance in interface PrimitiveDistance<NumberVector>
Parameters:
o1 - first DatabaseObject
o2 - second DatabaseObject
Returns:
the distance between two given DatabaseObjects according to this distance function
• #### isSquared

public boolean isSquared()
Description copied from interface: Distance
Squared distances, that would become metric after square root.

E.g. squared Euclidean.

Specified by:
isSquared in interface Distance<NumberVector>
Returns:
true when squared.
• #### norm

public double norm​(NumberVector obj)
Description copied from interface: Norm
Compute the norm of object obj.
Specified by:
norm in interface Norm<NumberVector>
Parameters:
obj - Object
Returns:
Norm
• #### equals

public boolean equals​(java.lang.Object obj)
Overrides:
equals in class java.lang.Object
• #### hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object
• #### getInputTypeRestriction

public VectorFieldTypeInformation<? super NumberVector> getInputTypeRestriction()
Description copied from interface: Distance
Get the input data type of the function.
Specified by:
getInputTypeRestriction in interface Distance<NumberVector>
Specified by:
getInputTypeRestriction in interface PrimitiveDistance<NumberVector>
Overrides:
getInputTypeRestriction in class AbstractNumberVectorDistance
Returns:
Type restriction