Package smile.math.distance
Class HammingDistance
java.lang.Object
smile.math.distance.HammingDistance
- All Implemented Interfaces:
Serializable
,ToDoubleBiFunction<int[],
,int[]> Distance<int[]>
In information theory, the Hamming distance between two strings of equal
length is the number of positions for which the corresponding symbols are
different. Put another way, it measures the minimum number of substitutions
required to change one into the other, or the number of errors that
transformed one string into the other. For a fixed length n, the Hamming
distance is a metric on the vector space of the words of that length.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic int
d
(byte[] x, byte[] y) Returns Hamming distance between the two byte arrays.double
d
(int[] x, int[] y) Returns the distance measure between two objects.static int
d
(int x, int y) Returns Hamming distance between the two integers.static int
d
(long x, long y) Returns Hamming distance between the two long integers.static int
d
(short[] x, short[] y) Returns Hamming distance between the two short arrays.double
Returns Hamming distance between the two bit sets.toString()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface smile.math.distance.Distance
apply, applyAsDouble, pdist, pdist
-
Constructor Details
-
HammingDistance
public HammingDistance()Constructor.
-
-
Method Details
-
toString
-
d
public double d(int[] x, int[] y) Description copied from interface:Distance
Returns the distance measure between two objects. -
d
public static int d(int x, int y) Returns Hamming distance between the two integers.- Parameters:
x
- an integer.y
- an integer.- Returns:
- the distance.
-
d
public static int d(long x, long y) Returns Hamming distance between the two long integers.- Parameters:
x
- a long integer.y
- a long integer.- Returns:
- the distance.
-
d
public static int d(byte[] x, byte[] y) Returns Hamming distance between the two byte arrays.- Parameters:
x
- a byte vector.y
- a byte vector.- Returns:
- the distance.
-
d
public static int d(short[] x, short[] y) Returns Hamming distance between the two short arrays.- Parameters:
x
- a short vector.y
- a short vector.- Returns:
- the distance.
-
d
Returns Hamming distance between the two bit sets.- Parameters:
x
- a bit set.y
- a bit set.- Returns:
- the distance.
-