Interface Distance<T>

Type Parameters:
T - the input type of distance function.
All Superinterfaces:
Serializable, ToDoubleBiFunction<T,T>
All Known Subinterfaces:
Metric<T>
All Known Implementing Classes:
ChebyshevDistance, CorrelationDistance, DynamicTimeWarping, EditDistance, EuclideanDistance, HammingDistance, JaccardDistance, JensenShannonDistance, LeeDistance, MahalanobisDistance, ManhattanDistance, MinkowskiDistance, SparseChebyshevDistance, SparseEuclideanDistance, SparseManhattanDistance, SparseMinkowskiDistance, TaxonomicDistance

public interface Distance<T> extends ToDoubleBiFunction<T,T>, Serializable
An interface to calculate a distance measure between two objects. A distance function maps pairs of points into the non-negative reals and has to satisfy
  • non-negativity: d(x, y) >= 0
  • isolation: d(x, y) = 0 if and only if x = y
  • symmetry: d(x, y) = d(x, y)
Note that a distance function is not required to satisfy triangular inequality |x - y| + |y - z| >= |x - z|, which is necessary for a metric.
  • Method Summary

    Modifier and Type
    Method
    Description
    default double
    apply(T x, T y)
    Returns the distance measure between two objects.
    default double
    applyAsDouble(T x, T y)
     
    double
    d(T x, T y)
    Returns the distance measure between two objects.
    default Matrix
    D(T[] x)
    Returns the pairwise distance matrix.
    default Matrix
    D(T[] x, T[] y)
    Returns the pairwise distance matrix.
  • Method Details

    • d

      double d(T x, T y)
      Returns the distance measure between two objects.
      Parameters:
      x - an object.
      y - an object.
      Returns:
      the distance.
    • apply

      default double apply(T x, T y)
      Returns the distance measure between two objects. This is simply for Scala convenience.
      Parameters:
      x - an object.
      y - an object.
      Returns:
      the distance.
    • applyAsDouble

      default double applyAsDouble(T x, T y)
      Specified by:
      applyAsDouble in interface ToDoubleBiFunction<T,T>
    • D

      default Matrix D(T[] x)
      Returns the pairwise distance matrix.
      Parameters:
      x - samples.
      Returns:
      the pairwise distance matrix.
    • D

      default Matrix D(T[] x, T[] y)
      Returns the pairwise distance matrix.
      Parameters:
      x - samples.
      y - samples.
      Returns:
      the pairwise distance matrix.