{ } Raw JSON

bundles / scipy 1.18.0 / scipy / spatial / distance / minkowski

function

scipy.spatial.distance:minkowski

source: /scipy/spatial/distance.py:433

Signature

def minkowski(u, v, p = 2, w = None)

Summary

Compute the Minkowski distance between two arrays.

Extended Summary

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

Parameters

u : (..., N) array_like

Input array.

v : (..., N) array_like

Input array.

p : scalar

The order of the norm of the difference . Note that for , the triangle inequality only holds with an additional multiplicative factor, i.e. it is only a quasi-metric.

w : (N,) array_like, optional

The weights for each value in u and v. Default is None, which gives each value a weight of 1.0

Returns

minkowski : float or ndarray

The Minkowski distance between vectors u and v.

Examples

from scipy.spatial import distance
✓
distance.minkowski([1, 0, 0], [0, 1, 0], 1)
distance.minkowski([1, 0, 0], [0, 1, 0], 2)
distance.minkowski([1, 0, 0], [0, 1, 0], 3)
distance.minkowski([1, 1, 0], [0, 1, 0], 1)
distance.minkowski([1, 1, 0], [0, 1, 0], 2)
distance.minkowski([1, 1, 0], [0, 1, 0], 3)
✗
np.float64(1.0)

Aliases

  • scipy.spatial._kdtree.minkowski

Referenced by