VOOZH about

URL: https://www.geeksforgeeks.org/maths/minskowski-distance/

⇱ Minkowski Distance - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Minkowski Distance

Last Updated : 23 Jul, 2025

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.

Generalization of Other Distance Metrics

The Minkowski Distance can represent different types of distances based on the value of p:

1. Manhattan Distance (p = 1)

Also called Taxicab Distance, it represents movement along grid-based paths, such as city blocks where diagonal movement is restricted.

2. Euclidean Distance (p = 2)

This is the straight-line distance between two points, making it the most commonly used metric in geometry, physics, and machine learning.

3. Chebyshev Distance (pā†’āˆž)

This measures the maximum absolute coordinate difference, often used in chess for king movement and in warehouse logistics for max-step constraints.

šŸ‘ min-min
Distance Metrics

Numerical Example

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ā†’āˆž)

Mathematical Properties

1. Non-negativity

Distance is always non-negative, meaning it can never be less than zero, ensuring a valid metric for measuring separations between points.

2. Identity of Indiscernibles

The distance between two points is zero if and only if they are identical, ensuring that distinct points always have a nonzero distance.

3. Symmetry

The distance remains unchanged when the order of points is swapped, making the metric independent of direction.

4. Triangle Inequality (Only for p≄1)

This ensures that taking a direct path between two points is always the shortest, reinforcing the foundational property of metric spaces.

5. Generalization

As p increases, the Minkowski Distance approaches the Chebyshev Distance, meaning only the largest coordinate difference dominates the overall distance measure.

Implementation in Python

Below is the Python implementation of Minkowski Distance, including visualization:

Output:

šŸ‘ imp
Minkowski Parameters

The plot shows how Minkowski Distance varies for different p values.

Real-Life Applications

1. Machine Learning & Clustering

Used in K-Nearest Neighbors (KNN) and K-Means Clustering to measure the similarity between data points.

2. Image Processing

Used in measuring similarity between images, especially in image retrieval systems.

3. Finance & Risk Analysis

Employed in portfolio analysis to compute risk distances between financial assets.

4. Robotics & Path Planning

Manhattan and Euclidean distances (special cases) are widely used in robot motion planning and autonomous navigation.

Related Articles

Comment
Article Tags:
Article Tags:

Explore