Kruskal–Wallis H test calculator
Paste the values of each group, separated by semicolons, to test whether the groups come from the same distribution without assuming normal data. You get H, the p-value, the mean rank of each group and an effect size.
Runs in your browser: nothing you enter is sent anywhere.
How to use it
- Type or paste each group’s values, separating the groups with semicolons.
- Set the significance level, usually 0.05.
- Read H, the p-value and the mean rank of each group.
How the test works
All N values are ranked together; tied values share the average of their ranks. With k groups, Rᵢ the rank sum and nᵢ the size of group i:
- H = 12/(N(N + 1)) × Σ Rᵢ²/nᵢ − 3(N + 1)
- Tie correction: C = 1 − Σ(t³ − t)/(N³ − N), where t is the size of each group of ties; the reported H is H/C.
- p-value: upper tail of the χ² distribution with k − 1 degrees of freedom.
- Effect size: η²_H = (H − k + 1)/(N − k).
Worked example
Three groups: 1, 2, 3; 4, 5, 6; 7, 8, 9. The ranks equal the values, so the rank sums are 6, 15 and 24.
Σ Rᵢ²/nᵢ = 36/3 + 225/3 + 576/3 = 279. H = 12/(9 × 10) × 279 − 3 × 10 = 37.2 − 30 = 7.2, with 2 degrees of freedom. For χ² with 2 degrees of freedom the upper tail is e^(−H/2), so p = e^(−3.6) = 0.027: significant at 0.05. η²_H = (7.2 − 2)/(9 − 3) = 0.87.
Tips and common mistakes
- The groups must be independent. For repeated measurements on the same subjects use the Friedman test instead.
- A semicolon starts a new group: an extra one creates an unwanted group.
- With only two groups, the Mann–Whitney U test also gives the direction and an exact p-value.
Frequently asked questions
When should I use the Kruskal–Wallis test?
When you compare three or more independent groups and the data are ordinal, skewed or have outliers, so one-way ANOVA's normality assumption is doubtful. With two groups it gives the same p-value as a two-tailed Mann–Whitney test using the normal approximation without continuity correction.
How is the p-value calculated?
H is compared with the chi-square distribution with k − 1 degrees of freedom, where k is the number of groups. This approximation is the standard one; it is less accurate when groups are very small.
The test is significant. Which groups differ?
The test only says that at least one group differs. To find which, run pairwise follow-up tests such as Dunn's test or Mann–Whitney tests with a correction for multiple comparisons; the mean ranks show where to look.
What does eta squared mean here?
η²_H = (H − k + 1)/(N − k) estimates the share of rank variation explained by the groups, from 0 to 1. It can come out slightly below 0 when there is no effect.