Overview:
-
The Manhattan distance or City Block distance is computed by summing the distances in each axis of the given two points.
-
It is never the shortest distance between the two points in real co-ordinate space as it involves traversing in each direction given by the data point.
-
The Manhattan distance is greater in value than the Euclidean distance. Euclidean distance is the shortest distance between two points in real co-ordinate space.
Example:
The example uses the first two points of the dataset from the hierarchical clustering using Python. The Euclidean distance between the two points is 0.05040794 whereas the Manhattan distance between the two points is 0.05639999.
# Example Python program that finds the import scipy.spatial.distance as dist # Body weights and brain weights of crow and parrot # Compute the Manhattan distance # Compute the Euclidean distance # Compare the Manhattan distance with the Euclidean distance |
Output:
Manhattan distance between the points: |