Understanding Manhattan Distance: Beyond the City Blocks
Manhattan Distance, often referred to as "L1 distance" or "Taxicab" or "City block" distance, is grounded in a fascinating blend of geometry and real-world practicality. Let's further unravel this concept.
Historical Origins
The name "Manhattan Distance" comes from the grid layout of the streets in Manhattan, which is one of the boroughs of New York City. When you travel from one point to another in Manhattan, you can't go directly if buildings are in the way. Instead, you have to navigate the grid, moving horizontally and vertically, much like taxis do. Hence, the distance traveled is not the direct route (as a bird might fly) but is instead the sum of the horizontal and vertical distances.
Mathematical Perspective
From a geometric perspective, the Manhattan distance is the distance between two points measured along axes at right angles. In a plane with p_1 = (x_1, y_1)
and p_2 = (x_2, y_2)
, it is |x_1 - x_2| + |y_1 - y_2|
.
However, the concept extends beyond 2 dimensions. In an n
-dimensional space, the Manhattan distance between two points P
and Q
is:
Applications
Computer Vision: Manhattan distance can be used in image processing to compare the similarity between two images or shapes. For instance, it helps in contour matching, where the goal is to find the best match for a contour from a set of contours.
Games: In games like Chess or the 8-puzzle, Manhattan distance can be used as a heuristic to estimate the minimum number of moves required to reach the target state from a given state.
Robotics: Robots, especially those moving in grid-like environments, can use Manhattan distance to estimate paths and distances to targets.
Economics: In economic geography, the concept is applied to measure the shortest path that consumers take to reach a given facility.
Advantages over Euclidean Distance
Computationally Faster: In environments where direction can only be changed on a grid (like streets in a city), Manhattan distance is computationally faster to calculate than the Euclidean distance.
Less Sensitive to Outliers: Manhattan distance, due to its nature of calculation, can sometimes be less sensitive to outliers than Euclidean distance.
Drawbacks
Not always the Shortest Path: Especially in non-grid environments, Manhattan distance might not represent the most efficient path.
Over-simplification: In many real-world scenarios, there might be other obstacles or considerations, making the Manhattan estimate too simplistic.