Ora

What are the properties of a distance metric?

Published in Distance Metrics 4 mins read

A distance metric, fundamental in mathematics and various fields like computer science and statistics, defines a way to measure the "distance" between elements in a set. To qualify as a true distance metric, a function must satisfy four specific properties, ensuring it behaves consistently and intuitively.

Key Properties of a Distance Metric

A function $d(x, y)$ that calculates the distance between two points $x$ and $y$ must adhere to the following four axioms:

1. Non-Negativity (or Positivity)

The distance between any two points must always be greater than or equal to zero. You cannot have a negative distance.

  • Property: $d(x, y) \ge 0$
  • Explanation: This property simply states that distance is a non-negative quantity. For instance, whether you measure the distance between two cities or two data points, the result will always be zero or a positive value.
  • Example: The distance from New York to Los Angeles is 3,936 km, not -3,936 km.

2. Identity of Indiscernibles (or Zero Property)

The distance between a point and itself is zero. Conversely, if the distance between two points is zero, then those two points must be identical.

  • Property: $d(x, y) = 0 \iff x = y$
  • Explanation: This means that an object has no distance from itself, and if two objects have zero distance between them, they are effectively the same object in the context of that metric.
  • Example: The distance from a specific GPS coordinate to itself is zero. If a navigation system calculates zero distance between two coordinates, they refer to the exact same location.

3. Symmetry

The distance from point $x$ to point $y$ is the same as the distance from point $y$ to point $x$. The order of the points does not affect the measured distance.

  • Property: $d(x, y) = d(y, x)$
  • Explanation: This ensures that distance is a reciprocal measure. Moving from point A to point B covers the same "ground" as moving from point B to point A.
  • Example: The driving distance from London to Paris is approximately the same as the driving distance from Paris to London.

4. Triangle Inequality

This property states that the direct distance between two points is always less than or equal to the sum of the distances obtained by passing through a third intermediate point. In other words, the shortest path between two points is a straight line.

  • Property: $d(x, z) \le d(x, y) + d(y, z)$
  • Explanation: This principle, crucial in Euclidean geometry, implies that taking a detour can never make the journey shorter. For example, the distance from one sample unit (say, point A) to another (point C) is always smaller than or equal to the combined distance from the first to the other by way of a third point (e.g., A to B and then B to C).
  • Example: If you want to travel from your home (A) to a friend's house (C), going directly is always as short as, or shorter than, stopping at a coffee shop (B) on the way.

These four properties collectively define a metric space, providing a consistent and intuitive framework for measuring separation between elements.

Summary of Distance Metric Properties

Property Description Mathematical Notation
Non-Negativity Distance is always zero or positive. $d(x, y) \ge 0$
Identity of Indiscernibles Distance is zero if and only if the points are identical. $d(x, y) = 0 \iff x = y$
Symmetry The distance from x to y is the same as from y to x. $d(x, y) = d(y, x)$
Triangle Inequality The shortest path between two points is a direct one. $d(x, z) \le d(x, y) + d(y, z)$