Kruskal-Wallis Test: How Group Ranks Contribute to H
2026-11-07

Kruskal-Wallis Test: How Group Ranks Contribute to H

The Kruskal-Wallis test asks whether independent groups show systematic differences in where their observations fall on a shared rank scale. In a robot study, those groups might be separate trials assigned to three fixture designs. The output, H, pools evidence across the entire comparison. Understanding how the statistic pools that evidence is the key to explaining what a single result can tell you.

The null hypothesis is about the underlying distributions

The NIST Dataplot reference formally states the null as identical population distributions. When the distributions have comparable shapes and the relevant alternative is a shift in location, a median interpretation can be appropriate. If the shapes differ, a difference in average ranks cannot automatically be attributed to the medians. Describing the result in terms of ranks keeps the interpretation tied to the evidence the procedure actually uses.

Each group supplies independent observations that can be ordered on a common scale. Unequal group sizes are allowed. Several runs from the same robot or specimen may remain related even when they appear in separate spreadsheet rows. In that setting the sampling unit, assignment, and grouping deserve attention before a test result is interpreted.

Why group size matters in the calculation

The procedure ranks all observations together and then adds the ranks separately for each group. Under the null, groups of different sizes have the same expected average rank, even though a large group has a larger expected rank sum. Dividing by the group size turns a rank sum into the group's average rank. The overall average rank for N observations is (N + 1) divided by two.

The H calculation can be understood by comparing each group's average rank with that common center. Square the difference, weight it by the group size, and add the weighted contributions. A scaling factor places that total on the H scale. This is equivalent to the uncorrected formula in the NIST reference. Squaring means a group far below the center contributes evidence just as a group far above it does.

In a hypothetical pool of eighteen observations, three groups of six might have average ranks of 6.5, 9.5, and 12.5. The rank center is 9.5. The outside groups each contribute six times three squared before scaling. The center group contributes zero. The signs disappear from H, while the group averages preserve their directions.

Three hypothetical mean ranks at 6.5, 9.5 and 12.5 around the overall rank center of 9.5.
Mean ranks preserve the direction of each group’s difference from the center. Source: Zhilianhai editorial desk, original AI-assisted conceptual illustration.

Shared measurements reduce the rank variation

When two readings tie for the fourth and fifth positions, each receives rank four and a half. Their group labels are retained. Ties can arise from repeated results or from measurements rounded to a fixed resolution. Assigning tied observations different ranks according to their original row order would let the layout of the spreadsheet affect the test.

The SciPy function reference specifies that its reported H is corrected for ties. This accounts for the reduction in rank variation caused by tied values. In practice, it helps to record the precision of the measurement and whether any rounding was applied before ranking. Changing the resolution can change which observations share a rank, even when the units and group labels stay the same.

Read the reference distribution alongside H

For k independent groups, the usual chi-square approximation has k minus one degrees of freedom. The group rank averages are linked because the total of all ranks is fixed. Once k minus one weighted group averages are known, the last is determined by that total. The p-value reported by SciPy is the upper tail of the reference distribution at the tie-corrected H.

The approximation needs adequate observations in each group. SciPy cites at least five observations per group as a typical guideline. The total sample size alone can hide a very small group. Also record any missing value rule, because dropping values can change group sizes, the combined rank pool, and the adequacy of the approximation in the same calculation.

Two equal positive bars for the groups away from the center and a zero bar for the middle group.
Weighted squared rank deviations feed the overall H statistic. Source: Zhilianhai editorial desk, original AI-assisted conceptual illustration.

Read the overall finding before asking about particular pairs

Suppose three hypothetical groups represent three fixture designs. A large H can be driven by one group with consistently higher ranks or by multiple groups on opposite sides of the common center. The same total can hide different patterns of group contributions. A report can show each group’s sample size and average rank to make that structure visible, while leaving statistical claims about specific pairs to a follow-up procedure.

Such follow-up comparisons should identify which pairs were examined, the procedure used, and how the analysis accounted for multiple comparisons. The overall p-value describes the joint test and belongs on its own line. The comparison also benefits from original unit summaries alongside rank information, so the reader can see the practical size and shape of any differences. Related explanations are available in the robot statistics section and the technical article directory.

18028484626 CONTACT US

公司:智联海(惠州)科技有限公司

地址:惠州仲恺高新区陈江街道白云山工业大道 5 号六楼 601

Q Q:18028484626

Copyright © 2002-2026

粤xxx

咨询 在线留言 电话:18028484626
微信 微信扫码添加我