scipy.spatial.minkowski_distance_p#

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

Compute the pth 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.

The last dimensions of x and y must be the same length. Any other dimensions must be compatible for broadcasting.

Parameters:
x(…, K) array_like

Input array.

y(…, K) array_like

Input array.

pfloat, 1 <= p <= infinity

Which Minkowski p-norm to use.

Returns:
distndarray

pth power of the distance between the input arrays.

Examples

>>> from scipy.spatial import minkowski_distance_p
>>> minkowski_distance_p([[0, 0], [0, 0]], [[1, 1], [0, 1]])
array([2, 1])