Kruskal-Wallis Test Calculator

The Kruskal-Wallis test compares three or more independent groups when your data doesn't meet the normality assumptions ANOVA needs. It pools every observation, ranks them together, sums the ranks per group, and converts those sums into a statistic H that follows a chi-square distribution with k−1 degrees of freedom under the null hypothesis.

—
—
—
—
—
—
—
—
—
—

What This Calculator Actually Computes

Type in two to five groups of numbers, one group per box, separated by commas. The calculator pools every value from every group, ranks them from smallest to largest (tied values share the average of the ranks they'd otherwise occupy), and works out the Kruskal-Wallis H statistic with the standard tie correction applied automatically. Alongside H you get the degrees of freedom (k minus 1, where k is your number of groups), the p-value from the chi-square approximation, a plain decision at the conventional alpha = 0.05 threshold, each group's sample size and mean rank, the total N, and the tie-correction factor C itself.

What it will not do: it won't run a post-hoc pairwise test such as Dunn's, it won't give you an exact small-sample p-value from permutation tables, and it won't compute an effect size like epsilon-squared. Those are separate calculations, useful ones, but outside the scope of this tool. If you only have two groups, the Mann-Whitney U calculator is the right choice - with two groups, Kruskal-Wallis gives the same result as a two-sided Mann-Whitney test anyway.

A Worked Example You Can Check by Hand

Say you're comparing three teaching methods and recorded quiz-improvement scores for six students each: Group A: 27, 2, 4, 18, 7, 9. Group B: 20, 8, 14, 36, 21, 22. Group C: 34, 31, 3, 23, 30, 6.

Pool all 18 values, sort them, and rank 1 through 18. Nobody ties here, so every rank is a whole number:

ValueGroupRank
2A1
3C2
4A3
6C4
7A5
8B6
9A7
14B8
18A9
20B10
21B11
22B12
23C13
27A14
30C15
31C16
34C17
36B18

Rank sums come out to 39 for A, 65 for B, and 67 for C, which checks out against 1+2+...+18 = 171:

GroupnRank sum (R)Mean rank
A6396.500
B66510.833
C66711.167

With N = 18, H = [12 / (18×19)] × (39²/6 + 65²/6 + 67²/6) − 3×19 = 59.854 − 57 = 2.854. Degrees of freedom equal k − 1 = 2. There are no ties, so the correction factor C = 1 and the tie-adjusted H equals the raw H.

Comparing H to chi-square with 2 df, p = e^(−H/2) = e^(−1.427) ≈ 0.240, a shortcut that only works this cleanly at exactly 2 degrees of freedom. Since 0.240 is well above 0.05, we fail to reject the null hypothesis: these three samples are entirely consistent with coming from the same distribution.

What the Test Actually Tests (It's Not Just Medians)

Textbooks often shorthand Kruskal-Wallis as a test of medians, and that's only strictly true under one condition: the distributions being compared need the same shape and spread, differing only in location. What the test genuinely detects is stochastic dominance, whether values from one group tend to rank higher than values from another across the whole distribution, not just at the middle. If your groups have wildly different variances or skew, a significant H can show up even when the medians are identical, so treat “different medians” as a convenient summary rather than a guarantee.

If your data does satisfy the normality assumption ANOVA needs, that test usually has more statistical power for the same sample size, so it's worth running the ANOVA calculator alongside this one and comparing what each says.

When the Chi-Square Approximation Gets Shaky

H only approximately follows a chi-square distribution, and the approximation improves as your samples grow. NIST's engineering statistics handbook frames the rule of thumb as each group needing more than about four observations for the approximation to behave reasonably; other sources round that up to “at least five per group.” Either way, it's a rule of thumb, not a hard cutoff, Three groups of six, like the example above, clear both versions of the rule, but not by much - if a result like that lands close to 0.05, an exact or permutation-based p-value is worth a second look.

Below that threshold, exact tables (Kruskal and Wallis published some in their original 1952 paper) or a permutation approach are the more honest option, and most statistical software offers one as an alternative to the chi-square shortcut.

After a Significant Result: What Comes Next

A significant Kruskal-Wallis result tells you at least one group differs from the others - it doesn't say which one. The standard follow-up is Dunn's test, a pairwise rank-based comparison that reuses the same rankings and pooled variance from the omnibus test, run for every pair of groups with a multiplicity correction such as Bonferroni or the less conservative Holm procedure, so the overall false-positive rate stays near 5%. This calculator doesn't compute Dunn's test; it hands you the omnibus result, and the pairwise step needs a separate tool or a stats package.

If you only end up comparing two of your original groups afterward, the Mann-Whitney U calculator covers that case, or the t-test calculator if you're willing to assume normality for that particular pair. For the rest of the nonparametric and parametric tests on this site, browse the statistics calculators hub.

Frequently Asked Questions

What does the Kruskal-Wallis test actually tell you?

It tells you whether three or more independent groups are likely drawn from the same underlying distribution. A small p-value means at least one group tends to produce systematically higher or lower ranked values than the others - it doesn't tell you which group, or by how much.

How is the H statistic calculated?

Pool and rank every observation across all groups, sum the ranks within each group, then plug those rank sums into H = [12/(N(N+1))] × Σ(Rᵢ²/nᵢ) − 3(N+1). A tie-correction factor divides this further whenever repeated values appear in the data.

What's the difference between Kruskal-Wallis and one-way ANOVA?

ANOVA compares group means and assumes normally distributed, equal-variance residuals; Kruskal-Wallis compares rank sums and makes no distributional assumption at all. Use Kruskal-Wallis when your data is skewed, ordinal, or contains outliers that would otherwise distort a mean-based test like ANOVA.

Can I say Kruskal-Wallis compares medians?

Only loosely, and only when the group distributions share the same shape and spread. Strictly speaking, the test detects stochastic dominance - whether one group's values rank consistently higher than another's across the entire distribution, not just around its center or median.

What should I do after getting a significant Kruskal-Wallis result?

Run a post-hoc pairwise test such as Dunn's test with a multiplicity correction like Bonferroni or Holm. That step, which this calculator doesn't perform, tells you which specific pairs of groups differ rather than just confirming a difference exists somewhere.

How does the calculator handle tied values?

Tied observations receive the average of the ranks they would have occupied if they weren't tied, and H is automatically adjusted with a tie-correction factor C. Ties shrink the raw H slightly, so the correction restores its accuracy before comparing it to chi-square.

How many groups can this calculator handle?

Between two and five groups, entered as comma-separated numbers in separate input boxes. With exactly two groups the result matches a two-sided Mann-Whitney U test, so the dedicated Mann-Whitney U calculator on this site is the more natural tool - it reports U directly, which is what most write-ups expect.

Is the chi-square p-value always accurate?

Only approximately, and the approximation weakens as groups get smaller. NIST's rule of thumb suggests each group should have more than about four observations for the chi-square approximation to hold up; below that, an exact or permutation-based p-value is the safer, more defensible choice.