seuclidean#
- scipy.spatial.distance.seuclidean(u, v, V)[source]#
Return the standardized Euclidean distance between two arrays.
The standardized Euclidean distance between arrays u and v is
\[\sqrt{\sum\limits_i \frac{1}{V_i} \left(u_i-v_i \right)^2}\]Vis the variance vector;V[I]is the variance computed over all the i-th components of the points. If not passed, it is automatically computed.- Parameters:
- u(…, N) array_like
Input array.
- v(…, N) array_like
Input array.
- V(…, N) array_like
V is an array of component variances. It is usually computed among a larger collection of vectors.
- Returns:
- seuclideanfloat or array
The standardized Euclidean distance between vectors u and v.
Notes
Array API Standard Support
seuclideanhas support for Python Array API Standard compatible backends in addition to NumPy. The following combinations of backend and device (or other capability) are supported.Library
CPU
GPU
NumPy
✅
n/a
CuPy
n/a
✅
PyTorch
✅
✅
JAX
✅
✅
Dask
✅
n/a
See Support for the array API standard for more information.
Examples
>>> from scipy.spatial import distance >>> distance.seuclidean([1, 0, 0], [0, 1, 0], [0.1, 0.1, 0.1]) 4.4721359549995796 >>> distance.seuclidean([1, 0, 0], [0, 1, 0], [1, 0.1, 0.1]) 3.3166247903553998 >>> distance.seuclidean([1, 0, 0], [0, 1, 0], [10, 0.1, 0.1]) 3.1780497164141406