Class MahalanobisDistance

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

public class MahalanobisDistance extends Object implements Metric<double[]>
In statistics, Mahalanobis distance is based on correlations between variables by which different patterns can be identified and analyzed. It is a useful way of determining similarity of an unknown sample set to a known one. It differs from Euclidean distance in that it takes into account the correlations of the data set and is scale-invariant, i.e. not dependent on the scale of measurements.
See Also:
  • Constructor Details

    • MahalanobisDistance

      public MahalanobisDistance(double[][] cov)
      Constructor.
      Parameters:
      cov - the covariance matrix.
  • Method Details

    • toString

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

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