(Some) mathematical measures
This page outlines, mainly for convenience, some useful measures/metrics utilised for several purposes.
It is the reciprocal of the mean of reciprocals:
The euclidean distance of two vectors
is the norm
of the vector connecting them (it measures its length):
The Hamming distance expresses the number of different elements in two lists/strings:
Given two finite sets A and B, the Jaccard index gives a measure of how much they overlap, as
Also called cityblock, the Manhattan distance between two points is the norm
of the shortest path a car would take between these two points in Manhattan (which has a grid layout):
The Minkowski distance is a generalisation of both the euclidean and the Manhattan to a generic p:
The cosine similarity is given by the cosine of the angle
spanned by the two vectors
So two perfectly overlapping vectors would have a cosine similarity of 1 and vectors at
would have a cosine similarity of 0.
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.
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.