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 class
HammingDistance.Par
Parameterization class.
-
Field Summary
Fields Modifier and Type Field Description static HammingDistance
STATIC
Static 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 double
distance(FeatureVector<?> o1, FeatureVector<?> o2)
Computes the distance between two given DatabaseObjects according to this distance function.double
distance(NumberVector o1, NumberVector o2)
Computes the distance between two given vectors according to this distance function.boolean
equals(java.lang.Object obj)
SimpleTypeInformation<? super FeatureVector<?>>
getInputTypeRestriction()
Get the input data type of the function.private double
hammingDistanceNumberVector(NumberVector o1, NumberVector o2)
Version for number vectors.int
hashCode()
boolean
isMetric()
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:Distance
Is this distance function metric (satisfy the triangle inequality)- Specified by:
isMetric
in interfaceDistance<FeatureVector<?>>
- Returns:
true
when metric.
-
distance
public double distance(FeatureVector<?> o1, FeatureVector<?> o2)
Description copied from interface:PrimitiveDistance
Computes the distance between two given DatabaseObjects according to this distance function.- Specified by:
distance
in 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:NumberVectorDistance
Computes the distance between two given vectors according to this distance function.- Specified by:
distance
in 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:Distance
Get the input data type of the function.- Specified by:
getInputTypeRestriction
in interfaceDistance<FeatureVector<?>>
- Specified by:
getInputTypeRestriction
in interfacePrimitiveDistance<FeatureVector<?>>
- Returns:
- Type restriction
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
-