What is the difference between Euclidean, Manhattan and Hamming Distances?
Euclidean distance is one of the most used distance metrics. It is calculated using Minkowski Distance formula by setting p’s value to 2. This will update the distance ‘d’ formula as below:
Euclidean distance formula can be used to calculate the distance between two data points in a plane.
Manhattan Distance is used to calculate the distance between two data points in a grid like path.
Distance d will be calculated using an absolute sum of difference between its cartesian co-ordinates as below:
where, n- number of variables, xi and yi are the variables of vectors x and y respectively, in the two-dimensional vector space. i.e. x = (x1, x2, x3, …) and y = (y1, y2, y3, …).
Now the distance d will be calculated as-
(x1 – y1) + (x2 – y2) + (x3 – y3) + … + (xn – yn).
Hamming distance is one of several string metrics for measuring the edit distance between two sequences. Hamming distance can be used to measure how many attributes must be changed in order to match one another.