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[][]
weightMatrix
The weight matrix.
-
Constructor Summary
Constructors Constructor Description MatrixWeightedQuadraticDistance(double[][] weightMatrix)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete 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
-
-
-
-
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 interfaceNumberVectorDistance<NumberVector>
- Specified by:
distance
in 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:Distance
Squared distances, that would become metric after square root.E.g. squared Euclidean.
- Specified by:
isSquared
in interfaceDistance<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 interfaceNorm<NumberVector>
- Parameters:
obj
- Object- Returns:
- Norm
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.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 interfaceDistance<NumberVector>
- Specified by:
getInputTypeRestriction
in interfacePrimitiveDistance<NumberVector>
- Overrides:
getInputTypeRestriction
in classAbstractNumberVectorDistance
- Returns:
- Type restriction
-
-