bundles / scipy 1.17.1 / scipy / cluster / hierarchy / maxdists
function
scipy.cluster.hierarchy:maxdists
Signature
def maxdists ( Z ) Summary
Return the maximum distance between any non-singleton cluster.
Parameters
Z: ndarrayThe hierarchical clustering encoded as a matrix. See
linkagefor more information.
Returns
maxdists: ndarrayA
(n-1)sized numpy array of doubles;MD[i]represents the maximum distance between any cluster (including singletons) below and including the node with index i. More specifically,MD[i] = Z[Q(i)-n, 2].max()whereQ(i)is the set of all node indices below and including node i.
Notes
Array API Standard Support
maxdists has experimental support for Python Array API Standard compatible backends in addition to NumPy. Please consider testing these features by setting an environment variable SCIPY_ARRAY_API=1 and providing CuPy, PyTorch, JAX, or Dask arrays as array arguments. The following combinations of backend and device (or other capability) are supported.
==================== ==================== ==================== Library CPU GPU ==================== ==================== ==================== NumPy ✅ n/a CuPy n/a ⛔ PyTorch ✅ ⛔ JAX ✅ ⛔ Dask ⚠️ merges chunks n/a ==================== ==================== ====================
See
dev-arrayapifor more information.
Examples
from scipy.cluster.hierarchy import median, maxdists from scipy.spatial.distance import pdist✓
X = [[0, 0], [0, 1], [1, 0], [0, 4], [0, 3], [1, 4], [4, 0], [3, 0], [4, 1], [4, 4], [3, 4], [4, 3]]✓
Z = median(pdist(X))
✓Z maxdists(Z)✗
See also
- is_monotonic
for testing for monotonicity of a linkage matrix.
- linkage
for a description of what a linkage matrix is.
Aliases
-
scipy.cluster.hierarchy.maxdists