Enum Class DistanceMeasure

java.lang.Object
java.lang.Enum<DistanceMeasure>
org.ojalgo.data.proximity.DistanceMeasure
All Implemented Interfaces:
Serializable, Comparable<DistanceMeasure>, Constable

public enum DistanceMeasure extends Enum<DistanceMeasure>
Enumeration of common distance and dissimilarity measures for coordinate feature vectors.

A distance assigns a non-negative number to each pair of points; smaller means more alike. Measures that satisfy the metric axioms (non-negativity; identity of indiscernibles; symmetry; triangle inequality) are metrics; others listed here may be semimetrics but remain useful in practice.

  • Nested Class Summary

    Nested classes/interfaces inherited from class Enum

    Enum.EnumDesc<E>
  • Enum Constant Summary

    Enum Constants
    Enum Constant
    Description
    Angular distance arccos((a·b)/(||a||·||b||)).
    Canberra distance: Σ_i |a_i − b_i| / (|a_i| + |b_i|), with 0/0 taken as 0 per term.
    Chebyshev (L-infinity) norm – maximum absolute coordinate difference.
    Correlation distance defined as 1 − ρ, where ρ is the Pearson correlation between coordinate vectors (after centering).
    Cosine distance defined as 1 − (a·b)/(||a||·||b||).
    Euclidean (L2) norm of the coordinate differences; a metric.
    Hamming distance counts coordinate mismatches; arrays of different length incur the absolute length difference as additional mismatches.
    Hellinger distance for non-negative vectors: H = (1/√2) · ||√a − √b||₂.
    Jaccard distance on the sets of non-zero coordinate indices: 1 − |A ∩ B|/|A ∪ B|.
    Manhattan (L1) norm – sum of absolute coordinate differences; a metric.
    Sum of squared coordinate differences.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the enum constant of this class with the specified name.
    Returns an array containing the constants of this enum class, in the order they are declared.

    Methods inherited from class Object

    getClass, notify, notifyAll, wait, wait, wait
  • Enum Constant Details

    • ANGULAR

      public static final DistanceMeasure ANGULAR
      Angular distance arccos((a·b)/(||a||·||b||)). A metric on the unit sphere; values in [0, π].
    • CANBERRA

      public static final DistanceMeasure CANBERRA
      Canberra distance: Σ_i |a_i − b_i| / (|a_i| + |b_i|), with 0/0 taken as 0 per term. Emphasises small values; range [0, ∞). A metric under the conventional definition.
    • CHEBYSHEV

      public static final DistanceMeasure CHEBYSHEV
      Chebyshev (L-infinity) norm – maximum absolute coordinate difference.
    • CORRELATION

      public static final DistanceMeasure CORRELATION
      Correlation distance defined as 1 − ρ, where ρ is the Pearson correlation between coordinate vectors (after centering). Invariant to affine scaling per vector. Not a metric in general.
    • COSINE

      public static final DistanceMeasure COSINE
      Cosine distance defined as 1 − (a·b)/(||a||·||b||). Range [0, 2]. Not a metric.
    • EUCLIDEAN

      public static final DistanceMeasure EUCLIDEAN
      Euclidean (L2) norm of the coordinate differences; a metric.
    • HAMMING

      public static final DistanceMeasure HAMMING
      Hamming distance counts coordinate mismatches; arrays of different length incur the absolute length difference as additional mismatches. Range [0, ∞). A metric in its standard domain.
    • HELLINGER

      public static final DistanceMeasure HELLINGER
      Hellinger distance for non-negative vectors: H = (1/√2) · ||√a − √b||₂. For probability vectors it lies in [0, 1] and satisfies the metric axioms.
    • JACCARD

      public static final DistanceMeasure JACCARD
      Jaccard distance on the sets of non-zero coordinate indices: 1 − |A ∩ B|/|A ∪ B|. Range [0, 1]; a metric on sets (binary incidence).
    • MANHATTAN

      public static final DistanceMeasure MANHATTAN
      Manhattan (L1) norm – sum of absolute coordinate differences; a metric.
    • SQUARED_EUCLIDEAN

      public static final DistanceMeasure SQUARED_EUCLIDEAN
      Sum of squared coordinate differences. Common in clustering (e.g. k‑means) because it preserves order with respect to Euclidean and is cheaper to compute, but it is not a metric (triangle inequality fails).
  • Constructor Details

    • DistanceMeasure

      private DistanceMeasure()
  • Method Details

    • values

      public static DistanceMeasure[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static DistanceMeasure valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null