Package elki.distance
Class MatrixWeightedQuadraticDistance
- java.lang.Object
-
- elki.distance.AbstractNumberVectorDistance
-
- elki.distance.MatrixWeightedQuadraticDistance
-
- 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 ofMahalanobisDistance. 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[][]weightMatrixThe weight matrix.
-
Constructor Summary
Constructors Constructor Description MatrixWeightedQuadraticDistance(double[][] weightMatrix)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description doubledistance(NumberVector o1, NumberVector o2)Computes the distance between two given DatabaseObjects according to this distance function.booleanequals(java.lang.Object obj)VectorFieldTypeInformation<? super NumberVector>getInputTypeRestriction()Get the input data type of the function.inthashCode()booleanisSquared()Squared distances, that would become metric after square root.doublenorm(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
-
-
-
-
Method Detail
-
distance
public double distance(NumberVector o1, NumberVector o2)
Description copied from interface:PrimitiveDistanceComputes the distance between two given DatabaseObjects according to this distance function.- Specified by:
distancein interfaceNumberVectorDistance<NumberVector>- Specified by:
distancein interfacePrimitiveDistance<NumberVector>- Parameters:
o1- first DatabaseObjecto2- second DatabaseObject- Returns:
- the distance between two given DatabaseObjects according to this distance function
-
isSquared
public boolean isSquared()
Description copied from interface:DistanceSquared distances, that would become metric after square root.E.g. squared Euclidean.
- Specified by:
isSquaredin interfaceDistance<NumberVector>- Returns:
truewhen squared.
-
norm
public double norm(NumberVector obj)
Description copied from interface:NormCompute the norm of object obj.- Specified by:
normin interfaceNorm<NumberVector>- Parameters:
obj- Object- Returns:
- Norm
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
getInputTypeRestriction
public VectorFieldTypeInformation<? super NumberVector> getInputTypeRestriction()
Description copied from interface:DistanceGet the input data type of the function.- Specified by:
getInputTypeRestrictionin interfaceDistance<NumberVector>- Specified by:
getInputTypeRestrictionin interfacePrimitiveDistance<NumberVector>- Overrides:
getInputTypeRestrictionin classAbstractNumberVectorDistance- Returns:
- Type restriction
-
-