bundles / scipy 2.0.0.dev0+git20260907.41eeb59 / scipy / cluster / hierarchy / _hierarchy_impl / maxdists
function
scipy.cluster.hierarchy._hierarchy_impl:maxdists
source: build-install/usr/lib/python3.14/site-packages/scipy/cluster/hierarchy/_hierarchy_impl.py:3806
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.
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)✗
array([1. , 1. , 1. , 1. , 1.11803, 1.11803, 1.11803,
1.11803, 3. , 3.5 , 3.5 ])
Note that while the distance between the two clusters merged when creating the
last cluster is 3.25, there are two children (clusters 16 and 17) whose distance
is larger (3.5). Thus, `scipy.cluster.hierarchy.maxdists` returns 3.5 in
this case.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