This is a method used to calculate the distances between objects in a N-Dimensional vector space. It is an alternative to Euclidean distance. In Euclidean distance we calculate the distance using the squares and the addition of the distances of an object from a point and then take square root of it. While in Manhattan distance we subtract the distances of points and take the absolute value of the difference and then add them. This is how Manhattan distance works.
In the above picture we can see that from a point we are calculating the distances of an object or in our case apples and oranges. The formula that we will be using is,
There are some properties that are displayed by Manhattan distance. Some of them are,
- It is also known as L1 norm and L1 metric.
- There can be an infinite number of possibilities of distance between two points that can be equal to Manhattan distances.
- The straight line that is equal to Manhattan distance can only move in two directions, that is, horizontal and vertical directions.
Manhattan Distance in N-D Space:
Here, since there will be n x’s and y’s we will update our little formula, such that if any range of dimensions shows up we can solve them. The formula would be,
Hence, this is the formula for n dimension space for calculating the distance between the object and the point.
Applications of Manhattan Distance:
- Regression Analysis
- Compressed Sensing
- Frequency Distribution