SciPy

scipy.spatial.distance.chebyshev

scipy.spatial.distance.chebyshev(u, v, w=None)[source]

Compute the Chebyshev distance.

Computes the Chebyshev distance between two 1-D arrays u and v, which is defined as

\[\max_i {|u_i-v_i|}.\]
Parameters:
u : (N,) array_like

Input vector.

v : (N,) array_like

Input vector.

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:
chebyshev : double

The Chebyshev distance between vectors u and v.

Examples

>>> from scipy.spatial import distance
>>> distance.chebyshev([1, 0, 0], [0, 1, 0])
1
>>> distance.chebyshev([1, 1, 0], [0, 1, 0])
1

Previous topic

scipy.spatial.distance.canberra

Next topic

scipy.spatial.distance.cityblock