bundles / scipy 2.0.0.dev0+git20260907.41eeb59 / scipy / cluster / hierarchy / _hierarchy_impl / maxRstat
function
scipy.cluster.hierarchy._hierarchy_impl:maxRstat
source: build-install/usr/lib/python3.14/site-packages/scipy/cluster/hierarchy/_hierarchy_impl.py:3996
Signature
def maxRstat(Z, R, i)Summary
Return the maximum statistic for each non-singleton cluster and its children.
Parameters
Z: array_likeThe hierarchical clustering encoded as a matrix. See linkage for more information.
R: array_likeThe inconsistency matrix.
i: intThe column of
Rto use as the statistic.
Returns
MR: ndarrayCalculates the maximum statistic for the i'th column of the inconsistency matrix
Rfor each non-singleton cluster node.MR[j]is the maximum overR[Q(j)-n, i], whereQ(j)the set of all node ids corresponding to nodes below and includingj.
Examples
from scipy.cluster.hierarchy import median, inconsistent, maxRstat 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)) R = inconsistent(Z)✓
R
✗array([[1. , 0. , 1. , 0. ],
[1. , 0. , 1. , 0. ],
[1. , 0. , 1. , 0. ],
[1. , 0. , 1. , 0. ],
[1.05902, 0.08346, 2. , 0.70711],
[1.05902, 0.08346, 2. , 0.70711],
[1.05902, 0.08346, 2. , 0.70711],
[1.05902, 0.08346, 2. , 0.70711],
[1.74536, 1.08655, 3. , 1.1547 ],
[1.91202, 1.37523, 3. , 1.1547 ],
[3.25 , 0.25 , 3. , 0. ]])
`scipy.cluster.hierarchy.maxRstat` can be used to compute
the maximum value of each column of ``R``, for each non-singleton
cluster and its children:
maxRstat(Z, R, 0) maxRstat(Z, R, 1) maxRstat(Z, R, 3)✗
array([0. , 0. , 0. , 0. , 0.70711, 0.70711, 0.70711,
0.70711, 1.1547 , 1.1547 , 1.1547 ])
See also
- inconsistent
for the creation of a inconsistency matrix.
- linkage
for a description of what a linkage matrix is.
Aliases
scipy.cluster.hierarchy.maxRstat