Class LeeDistance

java.lang.Object
smile.math.distance.LeeDistance
All Implemented Interfaces:
Serializable, ToDoubleBiFunction<int[],int[]>, Distance<int[]>, Metric<int[]>

public class LeeDistance extends Object implements Metric<int[]>
In coding theory, the Lee distance is a distance between two strings x1x2...xn and y1y2...yn of equal length n over the q-ary alphabet {0, 1, ..., q-1} of size q >= 2, defined as

sum min(|xi-yi|, q-|xi-yi|)

If q = 2 or q = 3 the Lee distance coincides with the Hamming distance.

See Also:
  • Constructor Details

    • LeeDistance

      public LeeDistance(int q)
      Constructor with a given size q of alphabet.
      Parameters:
      q - the size of q-ary alphabet.
  • Method Details

    • toString

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

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