Metric space

A metric space is an ordered pair where is a set and is a metric on , i.e. a (“distance/metric”) function , satisfying the following four axioms :

  1. identity of indiscernables: The distance from a point to itself is zero:
  2. Positivity: The distance between two distinct points is always positive:
  3. Symmetry: The distance from to is always the same as the distance from to :
  4. The triangle inequality holds:

Common distances that are proper metrics

manhattan distance (): - “taxicab” distance on a grid
euclidean distance (): - the “straight line” distance
Chebyshev distance (): - maximum coordinate difference
hamming distancen: Number of positions where symbols differ (for strings/vectors of equal length)
graph geodesic: Shortest path length between nodes (satisfies all metric axioms on the graph)
cosine distance: where is angle between vectors (metric for normalized vectors)
Jaccard distance: for sets A, B
levenshtein distance : Minimum edits to transform one string into another
Wasserstein distance: Optimal transport cost between probability distributions
Hausdorff distance: Maximum distance from any point in one set to its nearest neighbor in another set