![]() |
VOOZH | about |
Minkowski Distance is a generalized metric that unifies various distance measures used in mathematics and machine learning. It provides a flexible way to compute distances between points in an n-dimensional space.
It is a powerful distance function that encompasses several well-known distance metrics, such as Manhattan Distance and Euclidean Distance, as special cases, with different values of p leading to well-known distances such as Manhattan Distance (p=1), Euclidean Distance (p=2), and Chebyshev Distance (pāā).
The Minkowski Distance between two points A = (A1, A2, ā¦, An) and B = (B1, B2, ā¦, Bn) in an n-dimensional space is given by:
where p is a parameter that determines the nature of the distance metric.
The Minkowski Distance can represent different types of distances based on the value of p:
Also called Taxicab Distance, it represents movement along grid-based paths, such as city blocks where diagonal movement is restricted.
This is the straight-line distance between two points, making it the most commonly used metric in geometry, physics, and machine learning.
This measures the maximum absolute coordinate difference, often used in chess for king movement and in warehouse logistics for max-step constraints.
Consider two points in 3D space:
A = (2, 5, 8), B = (3, 1, 6)
For Manhattan Distance (p = 1)
For Euclidean Distance (p = 2)
For Chebyshev Distance (pāā)
Distance is always non-negative, meaning it can never be less than zero, ensuring a valid metric for measuring separations between points.
The distance between two points is zero if and only if they are identical, ensuring that distinct points always have a nonzero distance.
The distance remains unchanged when the order of points is swapped, making the metric independent of direction.
This ensures that taking a direct path between two points is always the shortest, reinforcing the foundational property of metric spaces.
As p increases, the Minkowski Distance approaches the Chebyshev Distance, meaning only the largest coordinate difference dominates the overall distance measure.
Below is the Python implementation of Minkowski Distance, including visualization:
Output:
The plot shows how Minkowski Distance varies for different p values.
Used in K-Nearest Neighbors (KNN) and K-Means Clustering to measure the similarity between data points.
Used in measuring similarity between images, especially in image retrieval systems.
Employed in portfolio analysis to compute risk distances between financial assets.
Manhattan and Euclidean distances (special cases) are widely used in robot motion planning and autonomous navigation.