Kruskal-Wallis Test Calculator

Compare 2 to 10 independent groups with the Kruskal-Wallis H test: mean ranks, H with tie correction, degrees of freedom and a chi-square p-value.

Put each group on its own line, optionally starting with a name and a colon. 2 to 10 groups. Use a point for decimals (1.5), no thousands separators, and separate numbers with spaces or a comma and a space.

Results

p-value (chi-square approximation)
0.0007
What this means
If all the groups came from the same distribution, mean ranks this far apart would be unusual (p below 0.05). This is evidence that at least one group tends to have larger or smaller values; it does not say which one, and it is not proof.
H (corrected for ties)
17.0154
H before the tie correction
16.86
Tie correction factor D = 1 − Σ(t³ − t)/(N³ − N)
0.99087
Degrees of freedom (k − 1)
3
Total number of values (N)
24
Expected mean rank under the null, (N + 1)/2
12.50
Rank sums and mean ranks
A: n = 4, rank sum = 25, mean rank = 6.25 B: n = 6, rank sum = 97.5, mean rank = 16.25 C: n = 6, rank sum = 121.5, mean rank = 20.25 D: n = 8, rank sum = 56, mean rank = 7
Ties
9 groups of tied values share average ranks.
Reliability
At least one group has fewer than 5 values, so the chi-square approximation may be poor; treat the p-value with caution.

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.

H = 12 / (N(N + 1)) × Σ (Rᵢ² / nᵢ) − 3(N + 1) tie correction: D = 1 − Σ(t³ − t) / (N³ − N) (t = size of each group of tied values) H′ = H / D, degrees of freedom = k − 1 p-value = P(χ² with k − 1 df ≥ H′)

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

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