SciPy

scipy.spatial.minkowski_distance_p

scipy.spatial.minkowski_distance_p(x, y, p=2)[source]

Compute the p-th power of the L**p distance between two arrays.

For efficiency, this function computes the L**p distance but does not extract the pth root. If p is 1 or infinity, this is equal to the actual L**p distance.

Parameters:

x : (M, K) array_like

Input array.

y : (N, K) array_like

Input array.

p : float, 1 <= p <= infinity

Which Minkowski p-norm to use.

Examples

>>> minkowski_distance_p([[0,0],[0,0]], [[1,1],[0,1]])
array([2, 1])