Enum Class DistanceMeasure
- All Implemented Interfaces:
Serializable, Comparable<DistanceMeasure>, Constable
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 ConstantsEnum ConstantDescriptionAngular 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 -
Method Summary
Modifier and TypeMethodDescriptionstatic DistanceMeasureReturns the enum constant of this class with the specified name.static DistanceMeasure[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
ANGULAR
Angular distance arccos((a·b)/(||a||·||b||)). A metric on the unit sphere; values in [0, π]. -
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
Chebyshev (L-infinity) norm – maximum absolute coordinate difference. -
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
Cosine distance defined as 1 − (a·b)/(||a||·||b||). Range [0, 2]. Not a metric. -
EUCLIDEAN
Euclidean (L2) norm of the coordinate differences; a metric. -
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
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
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
Manhattan (L1) norm – sum of absolute coordinate differences; a metric. -
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
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
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 nameNullPointerException- if the argument is null
-