Package elki.distance.set
Class HammingDistance
- java.lang.Object
-
- elki.distance.set.AbstractSetDistance<FeatureVector<?>>
-
- elki.distance.set.HammingDistance
-
- All Implemented Interfaces:
Distance<FeatureVector<?>>,NumberVectorDistance<FeatureVector<?>>,PrimitiveDistance<FeatureVector<?>>
@Reference(authors="R. W. Hamming", title="Error detecting and error correcting codes", booktitle="Bell System technical journal, 29(2)", url="https://doi.org/10.1002/j.1538-7305.1950.tb00463.x", bibkey="doi:10.1002/j.1538-7305.1950.tb00463.x") public class HammingDistance extends AbstractSetDistance<FeatureVector<?>> implements NumberVectorDistance<FeatureVector<?>>
Computes the Hamming distance of arbitrary vectors - i.e. counting, on how many places they differ.Reference:
R. W. Hamming
Error detecting and error correcting codes
Bell System technical journal, 29(2)TODO: add a sparse (but not binary) optimized version?
- Since:
- 0.7.0
- Author:
- Erich Schubert
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classHammingDistance.ParParameterization class.
-
Field Summary
Fields Modifier and Type Field Description static HammingDistanceSTATICStatic instance.-
Fields inherited from class elki.distance.set.AbstractSetDistance
DOUBLE_NULL, INTEGER_NULL, STRING_NULL
-
-
Constructor Summary
Constructors Constructor Description HammingDistance()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description doubledistance(FeatureVector<?> o1, FeatureVector<?> o2)Computes the distance between two given DatabaseObjects according to this distance function.doubledistance(NumberVector o1, NumberVector o2)Computes the distance between two given vectors according to this distance function.booleanequals(java.lang.Object obj)SimpleTypeInformation<? super FeatureVector<?>>getInputTypeRestriction()Get the input data type of the function.private doublehammingDistanceNumberVector(NumberVector o1, NumberVector o2)Version for number vectors.inthashCode()booleanisMetric()Is this distance function metric (satisfy the triangle inequality)-
Methods inherited from class elki.distance.set.AbstractSetDistance
isNull
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface elki.distance.Distance
isSquared, isSymmetric
-
Methods inherited from interface elki.distance.PrimitiveDistance
instantiate
-
-
-
-
Field Detail
-
STATIC
public static final HammingDistance STATIC
Static instance.
-
-
Method Detail
-
isMetric
public boolean isMetric()
Description copied from interface:DistanceIs this distance function metric (satisfy the triangle inequality)- Specified by:
isMetricin interfaceDistance<FeatureVector<?>>- Returns:
truewhen metric.
-
distance
public double distance(FeatureVector<?> o1, FeatureVector<?> o2)
Description copied from interface:PrimitiveDistanceComputes the distance between two given DatabaseObjects according to this distance function.- Specified by:
distancein interfacePrimitiveDistance<FeatureVector<?>>- Parameters:
o1- first DatabaseObjecto2- second DatabaseObject- Returns:
- the distance between two given DatabaseObjects according to this distance function
-
distance
public double distance(NumberVector o1, NumberVector o2)
Description copied from interface:NumberVectorDistanceComputes the distance between two given vectors according to this distance function.- Specified by:
distancein interfaceNumberVectorDistance<FeatureVector<?>>- Parameters:
o1- first vectoro2- second vector- Returns:
- the distance between two given vectors according to this distance function
-
hammingDistanceNumberVector
private double hammingDistanceNumberVector(NumberVector o1, NumberVector o2)
Version for number vectors.- Parameters:
o1- First vectoro2- Second vector- Returns:
- hamming distance
-
getInputTypeRestriction
public SimpleTypeInformation<? super FeatureVector<?>> getInputTypeRestriction()
Description copied from interface:DistanceGet the input data type of the function.- Specified by:
getInputTypeRestrictionin interfaceDistance<FeatureVector<?>>- Specified by:
getInputTypeRestrictionin interfacePrimitiveDistance<FeatureVector<?>>- Returns:
- Type restriction
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
-