Class HammingDistance

java.lang.Object
smile.math.distance.HammingDistance
All Implemented Interfaces:
Serializable, ToDoubleBiFunction<BitSet,BitSet>, Distance<BitSet>

public class HammingDistance extends Object implements Distance<BitSet>
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
    Constructor
    Description
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    d(byte[] x, byte[] y)
    Returns Hamming distance between the two byte arrays.
    static int
    d(byte x, byte y)
    Returns Hamming distance between the two bytes.
    static int
    d(int[] x, int[] y)
    Returns Hamming distance between the two integer arrays.
    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.
    static int
    d(short x, short y)
    Returns Hamming distance between the two shorts.
    double
    d(BitSet x, BitSet y)
    Returns the distance measure between two objects.
     

    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, D, D
  • Constructor Details

    • HammingDistance

      public HammingDistance()
      Constructor.
  • Method Details

    • toString

      public String toString()
      Overrides:
      toString in class Object
    • d

      public double d(BitSet x, BitSet y)
      Description copied from interface: Distance
      Returns the distance measure between two objects.
      Specified by:
      d in interface Distance<BitSet>
      Parameters:
      x - an object.
      y - an object.
      Returns:
      the distance.
    • d

      public static int d(byte x, byte y)
      Returns Hamming distance between the two bytes.
      Parameters:
      x - a byte.
      y - a byte.
      Returns:
      the distance.
    • d

      public static int d(short x, short y)
      Returns Hamming distance between the two shorts.
      Parameters:
      x - a short.
      y - a short.
      Returns:
      the distance.
    • 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

      public static int d(int[] x, int[] y)
      Returns Hamming distance between the two integer arrays.
      Parameters:
      x - an integer vector.
      y - an integer vector.
      Returns:
      the distance.