Documentation of 'smile.math.distance.ManhattanDistance' Java class
ManhattanDistance
smile.math.distance

Class ManhattanDistance

  • All Implemented Interfaces:
    java.io.Serializable, Distance<double[]>, Metric<double[]>


    public class ManhattanDistance
    extends java.lang.Object
    implements Metric<double[]>, java.io.Serializable
    Manhattan distance, also known as L1 distance or L1 norm, is the sum of the (absolute) differences of their coordinates. Use getInstance() to get the standard unweighted Manhattan distance. Or create an instance with a specified weight vector. For float or double arrays, missing values (i.e. NaN) are also handled. Also support sparse arrays of which zeros are excluded to save space.
    See Also:
    Serialized Form
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      double d(double[] x, double[] y)
      Manhattan distance between two arrays of type double.
      double d(float[] x, float[] y)
      Manhattan distance between two arrays of type float.
      double d(int[] x, int[] y)
      Manhattan distance between two arrays of type integer.
      java.lang.String toString() 
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • ManhattanDistance

        public ManhattanDistance()
        Constructor.
      • ManhattanDistance

        public ManhattanDistance(double[] weight)
        Constructor.
        Parameters:
        weight - the weight vector.
    • Method Detail

      • toString

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

        public double d(int[] x,
                        int[] y)
        Manhattan distance between two arrays of type integer.
      • d

        public double d(float[] x,
                        float[] y)
        Manhattan distance between two arrays of type float. NaN will be treated as missing values and will be excluded from the calculation. Let m be the number non-missing values, and n be the number of all values. The returned distance is n * d / m, where d is the distance between non-missing values.
      • d

        public double d(double[] x,
                        double[] y)
        Manhattan distance between two arrays of type double. NaN will be treated as missing values and will be excluded from the calculation. Let m be the number non-missing values, and n be the number of all values. The returned distance is n * d / m, where d is the distance between non-missing values.
        Specified by:
        d in interface Distance<double[]>

DataMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.