Ever wondered how to measure distance in a city grid?
Ever wondered how to measure distance in a city grid?
Imagine you're navigating through a city with streets laid out in a perfect grid pattern. You need to find the shortest path from your current location to your destination, but you can't just walk straight; you must follow the streets.
Picture the city grid as a chessboard. To get from one corner to the opposite corner, you don't just count the squares. Instead, you count the horizontal and vertical moves separately, adding them together to find the total number of steps.
Example
If you start 3 blocks east and 4 blocks north of your destination, you need to move 3 blocks west and 4 blocks south, totaling 7 blocks.
Remember this
The Manhattan distance is the sum of the absolute differences of their coordinates.
Text adapted from Wikipedia, licensed under CC BY-SA 4.0.
Distance transform
Manhattan distance formula: |x1 - x2| + |y1 - y2|
Great-circle distance
Ever wondered how to measure distance on a globe?
Euclidean distance
Euclidean distance formula: √((x2 - x1)² + (y2 - y1)²)
Mahalanobis distance
Mahalanobis distance formula: D^2 = (x - μ)'Σ^(-1)(x - μ)
Minkowski spacetime
Minkowski distance formula: D = (Σ |x_i - y_i|^p)^(1/p)
Euclidean geometry
Euclidean distance measures absolute position in space
Swipe through more Machine Learning concepts
Open Pocket Polymath