This page outlines, mainly for convenience, some useful measures/metrics utilised for several purposes.
The harmonic mean
It is the reciprocal of the mean of reciprocals:
h=∑i=1i=nxi1n
Common measures of distance/similarity
Euclidean
The euclidean distance of two vectors
va=(xi)a
and
vb=(xi)b
is the norm
l2
of the vector connecting them (it measures its length):
d=i∑(xai−xbi)2=∣∣vA−vB∣∣2
Hamming
The Hamming distance expresses the number of different elements in two lists/strings:
A=110101;B=111001;dAB=2
Jaccard (index)
Given two finite sets A and B, the Jaccard index gives a measure of how much they overlap, as
JAB=∣A∪B∣∣A∩B∣
Manhattan
Also called cityblock, the Manhattan distance between two points is the norm
l1
of the shortest path a car would take between these two points in Manhattan (which has a grid layout):
d=i∑∣ui−vi∣
Minkowski
The Minkowski distance is a generalisation of both the euclidean and the Manhattan to a generic p:
d=(i∑∣xi−yi∣p)1/p
Cosine
The cosine similarity is given by the cosine of the angle
θ
spanned by the two vectors
d=cosθ=∣uˉ∣∣vˉ∣uˉ⋅vˉ
So two perfectly overlapping vectors would have a cosine similarity of 1 and vectors at
90∘
would have a cosine similarity of 0.
Chebyshev
It is also called chessboard distance. In the game of chess, the Chebyshev distance between the centers of the squares is the minimum number of moves a king needs to go from a square to another one.
imax∣ui−vi∣
See the figure here, it reports in red all the Chebyshev distance value from where the king (well, there's a drawing for it ...) sits to cell; note that the king can move horizontally, vertically and diagonally.