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 intd(byte[] x, byte[] y) Returns Hamming distance between the two byte arrays.doubled(int[] x, int[] y) Returns the distance measure between two objects.static intd(int x, int y) Returns Hamming distance between the two integers.static intd(long x, long y) Returns Hamming distance between the two long integers.static intd(short[] x, short[] y) Returns Hamming distance between the two short arrays.doubleReturns Hamming distance between the two bit sets.toString()Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface Distance
apply, applyAsDouble, pdist, pdist
-
Constructor Details
-
HammingDistance
public HammingDistance()Constructor.
-
-
Method Details
-
toString
-
d
-
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
-