Calculate the generalized Minkowski distance between two vectors with a configurable order.
Minkowski distance generalizes both Euclidean (p=2) and Manhattan (p=1) distances using a configurable p parameter. Higher p values give more weight to the largest single-dimension difference, while lower p values spread weight more evenly across dimensions.
Minkowski Distance
d(a, b) = (sum(|a_i - b_i|^p))^(1/p)
p=1 (Manhattan), p=2 (Euclidean), and p=∞ (Chebyshev, max absolute difference) are the most commonly used. Fractional p values between 0 and 1 are sometimes used in high-dimensional data.
As p increases, the metric becomes more sensitive to the single largest coordinate difference. In the limit (p→∞), Minkowski distance equals the maximum absolute difference across all dimensions.