Kruskal-Wallis H Test Calculator
Paste two or more groups of numbers and get the Kruskal-Wallis H statistic, tie correction, degrees of freedom, and a chi-square p-value — the non-parametric alternative to one-way ANOVA. Every ranking step is shown, it runs in your browser, no signup.
How it works
The Kruskal-Wallis H test — full name “one-criterion analysis of variance by ranks” — checks whether several independent groups come from the same distribution, without assuming the data are normal. It replaces each raw value with its rank among all the data pooled together, so it is unaffected by skewness or outliers. It generalises the Mann-Whitney U test from two groups to any number of groups, and it is the rank-based counterpart of one-way ANOVA.
- Pool and rank. Combine all N observations, sort ascending, and assign ranks 1 to N. Tied values each get the average of the ranks they span — three values sharing ranks 4, 5, 6 all become rank 5.
- Rank sums. Add up the ranks inside each group to get Rᵢ. As a built-in check, the rank sums must total N(N+1)/2.
- H statistic. Compute
H = [12 / (N(N+1))] · Σ(Rᵢ²/nᵢ) − 3(N + 1), where nᵢ is the size of group i. - Tie correction. For each set of tied values of size t, add (t³ − t) to ΣT. The correction factor is
C = 1 − ΣT / (N³ − N), and the corrected statistic is H / C. With no ties, C = 1 and nothing changes. - p-value. Under the null hypothesis, H is approximately chi-square distributed with df = k − 1 degrees of freedom, where k is the number of groups. The p-value is the right-tail probability P(χ²₍ₖ₋₁₎ ≥ H), computed from the regularised upper incomplete gamma function Q(df/2, H/2). For df = 2 this reduces exactly to p = e^(−H/2).
- Decision.Reject the null hypothesis if p < α. A rejection means at least one group's distribution differs — not which pair, which needs a post-hoc test.
These formulas are from Kruskal & Wallis' original 1952 paper and PennState's STAT 415 course notes; the chi-square right-tail follows the NIST/SEMATECH e-Handbook. The calculator cross-checks itself two ways — it verifies the rank sums add to N(N+1)/2, and it recomputes H through the equivalent mean-rank-deviation formula H = [12 / (N(N+1))] · Σ nᵢ(R̄ᵢ − (N+1)/2)² — so a wrong answer would show up as a mismatch.
Worked examples
Frequently asked questions
Sources & references
- Kruskal, W. H. & Wallis, W. A. (1952), “Use of Ranks in One-Criterion Variance Analysis”, JASA 47(260): 583–621
- PennState Eberly College of Science — STAT 415, Kruskal-Wallis Test
- NIST/SEMATECH e-Handbook of Statistical Methods — rank-based methods & the chi-square right-tail
The H formula, tie-correction factor, and chi-square p-value on this page were last cross-checked against these sources on 2026-07-10. The three worked examples above are reconciled to the code to the last decimal shown.
Related tools
Comments & feedback
Spotted a bug or want an improvement? Tell us — our team reviews every comment, and good ideas get built. Comments are public and anonymous.
Found a bug, edge case, or want to suggest an improvement?
Email me at [email protected] — most fixes ship within 24 hours.