How it’s calculated
The Kruskal-Wallis test is the rank-based alternative to one-way ANOVA. It compares two or more independent groups without assuming the data are normally distributed. All the values are ranked together (1 = smallest), tied values share the average of their ranks, and H measures how far each group’s mean rank is from the overall mean rank (N + 1)/2.
Rᵢ is the rank sum and nᵢ the size of group i, N the total and k the number of groups. The p-value uses the chi-square approximation, which works well when each group has at least 5 values. With two groups, the test gives the same p-value as the Mann-Whitney U test without a continuity correction.
Example (Johns Hopkins Biostatistics notes): blood coagulation times on four diets, A: 62 60 63 59; B: 63 67 71 64 65 66; C: 68 66 71 67 68 68; D: 56 62 60 61 63 64 63 59. N = 24, and the mean ranks are 6.25, 16.25, 20.25 and 7.00 against an expected 12.5. H = 12/(24 × 25) × [4(6.25 − 12.5)² + 6(16.25 − 12.5)² + 6(20.25 − 12.5)² + 8(7 − 12.5)²] = 16.86. The ties give D = 0.991, so H′ = 16.86 ÷ 0.991 ≈ 17.02 with 3 degrees of freedom and p ≈ 0.0007. These are the default values.
A significant result says at least one group differs in its ranks; follow-up pairwise comparisons (with a correction for multiple tests) are needed to say which.
Frequently asked questions
When should I use Kruskal-Wallis instead of ANOVA?
When the data are ranks, or strongly skewed with small groups. One-way ANOVA is fairly robust to non-normal data and is more powerful when its assumptions hold.
Does Kruskal-Wallis compare medians?
Only if every group has a distribution of the same shape. In general it tests whether the mean ranks differ, that is, whether values in some groups tend to be larger.
Why correct for ties?
Ties reduce the spread of the ranks, so without the correction H is slightly too small. Dividing by D fixes this; with few ties D is close to 1 and the correction barely matters.
What if my groups have fewer than 5 values?
The chi-square approximation becomes rough. Treat the p-value as a guide and consider an exact or permutation test.
Embed this calculator
Add this free calculator to your own website. Copy the code below into your page’s HTML:
Need this calculator branded, changed or built around your own prices?See custom business solutions →
Sources
- Non-parametric ANOVA: the Kruskal-Wallis test (lecture notes, Biostatistics) — Johns Hopkins Bloomberg School of Public Health
- Handbook of Biological Statistics (McDonald), 4.8 Kruskal–Wallis Test — LibreTexts
Formulas are taken from the free public references above. Results are provided “as is” for informational and educational purposes only. See our disclaimer.
Added · Last updated · How we check our calculators
Spotted a mistake or missing option? Report a problem· Suggest a calculator