A metric is a function that outputs a distance between 2 elements of a set & meets certain strict criteria (some 'distance' functions are not metrics).
A metric is a function that outputs a distance between 2 elements of a set. To meet the definition of a metric, a distance function must fulfill the following criteria:
- There is no distance between an element and itself: $d(x_i,x_i)=0$.
- If the distance between two elements is $0$, those elements are equivalent: $d(x_i,x_j)=0\implies x_i=x_j$.
- All distances are non-negative: $d(x_i,x_j)\ge0$.
- The distance between two elements is the same in either direction: $d(x_i,x_j)=d(x_j,x_i)$.
- The distance between two elements is less than or equal to the sum of the distances between those elements and a third: $d(x_i,x_j)\le d(x_i,x_k)+d(x_j,x_k)$