SciPy

scipy.spatial.distance.minkowski

scipy.spatial.distance.minkowski(u, v, p)[source]

Computes the Minkowski distance between two 1-D arrays.

The Minkowski distance between 1-D arrays u and v, is defined as

\[{||u-v||}_p = (\sum{|u_i - v_i|^p})^{1/p}.\]
Parameters:

u : (N,) array_like

Input array.

v : (N,) array_like

Input array.

p : int

The order of the norm of the difference \({||u-v||}_p\).

Returns:

d : double

The Minkowski distance between vectors u and v.