statcompute

Hypothesis tests

Kruskal-Wallis Test Calculator

Compare three or more independent groups using ranks — the alternative to one-way ANOVA when the data are skewed, ordinal, or have outliers.

Updated August 2026Runs in your browser — nothing is uploadedVerified against R
One group per line, or separate groups with a blank line. A word at the start of a line names that group.
Conventionally 0.05. Decide before you look at the data.

The calculation runs in your browser, so this box needs JavaScript. The formula, the worked example and the interpretation below do not.

01

How to read this result

H measures how far the groups' mean ranks are from each other. Every value in the whole data set is replaced by its rank; if the groups are interchangeable, each should have a mean rank near the overall average. H grows as they separate.

Its null distribution is approximately chi-square with k − 1 degrees of freedom. The approximation is good once every group has about five observations; below that the p-value is indicative rather than exact.

A significant H says some group tends to produce larger values. It does not say which. The usual follow-up is pairwise Mann-Whitney tests with the p-values multiplied by the number of pairs (Bonferroni), or Dunn's test, which uses the same pooled ranks.

Two effect sizes are reported, because the names are routinely swapped. η²_H = (H − k + 1)/(N − k) is the analogue of η² in ANOVA. It is not bounded below: when H is smaller than k − 1 — which is what "no difference at all" looks like — the formula returns a negative number, and the reported value is clamped to 0. Read a clamped 0 as "no detectable group effect", not as a measurement. ε² = H/(N − 1) is the alternative normalisation, genuinely bounded between 0 and 1, and the one most statistics packages label "epsilon-squared". Quote whichever your field expects, and say which one it is.

02

The formula

H=12N(N+1)i=1kRi2ni3(N+1)
Ri
the sum of the ranks in group i
ni
the size of group i
N
the total number of observations
k
the number of groups

With ties, H is divided by 1 − Σ(t³ − t)/(N³ − N), where t is the size of each tied group. Compared against χ² on k − 1 degrees of freedom.

03

Worked example

Three fertilisers, small and uneven groups

Three groups with five, four and five observations. The values are close together, the groups are small, and there is no case for assuming normality.

A: 2.9, 3.0, 2.5, 2.6, 3.2 · B: 3.8, 2.7, 4.0, 2.4 · C: 2.8, 3.4, 3.7, 2.2, 2.0

  1. Rank all 14 values together, smallest to largest.
    2.0 → 1, 2.2 → 2, 2.4 → 3, 2.5 → 4, 2.6 → 5, 2.7 → 6, 2.8 → 7, 2.9 → 8, 3.0 → 9, 3.2 → 10, 3.4 → 11, 3.7 → 12, 3.8 → 13, 4.0 → 14
  2. Add the ranks within each group.
    A: 4+5+8+9+10 = 36 B: 3+6+13+14 = 36 C: 1+2+7+11+12 = 33
  3. Divide each squared rank sum by its group size and add them up.
    36²/5 + 36²/4 + 33²/5 = 259.2 + 324.0 + 217.8 = 801.0
  4. Apply the formula.
    H = 12/(14×15) × 801.0 − 3×15 = 0.057143 × 801.0 − 45 = 45.771 − 45 = 0.771
  5. Compare against χ² with k − 1 = 2 degrees of freedom.
    p = 0.680
H 0.771df 2p 0.680Conclusion no evidence of a difference

Fourteen observations across three groups gives this test very little power. A p-value of 0.68 here means “this study could not tell”, not “the fertilisers are equivalent”.

Checked against R's kruskal.test.

The calculator above is loaded with these numbers by the Load the worked example button.

04

Assumptions, and when to use something else

  • Independent observations and independent groups. Repeated measures on the same subjects need Friedman's test, which is not implemented here.
  • At least ordinal data. Rankable, not necessarily numeric.
  • Similar distribution shapes, if you want to read the result as a statement about medians. Without that assumption it is a statement about which group tends to produce larger values.
  • About five observations per group for the chi-square approximation to be dependable.
  • The groups are roughly normal with similar spreadOne-way ANOVAMore powerful when its assumptions hold, and it gives you means and effect sizes on the original scale.
  • Only two groupsMann-Whitney U testWith two groups, Kruskal-Wallis reduces to the Mann-Whitney test.
  • H is significant and you need to know which groups differPairwise Mann-Whitney testsRun each pair and multiply the p-values by the number of pairs (Bonferroni), or use Dunn's test in R or Python.
05

Questions people ask

Is Kruskal-Wallis just ANOVA on ranks?

Almost exactly. Replace every value by its rank in the pooled sample and run a one-way ANOVA, and the F you get is a monotone function of H. The two give very similar answers, and the rank transformation is what removes the normality assumption.

What do I do after a significant Kruskal-Wallis test?

Compare pairs. The simplest defensible approach is a Mann-Whitney test per pair with Bonferroni-adjusted p-values — multiply each by the number of comparisons. Dunn's test is the more efficient standard follow-up and uses the ranks already computed.

Can the groups be different sizes?

Yes, and unlike some alternatives the test handles it naturally: each group's rank sum is divided by its own size. Very small groups still cost power, and a group of two or three contributes almost nothing.

Does Kruskal-Wallis assume equal variances?

Not in the way ANOVA does. It does assume the groups' distributions have similar shapes if you want to interpret the result as a difference in medians — wildly different spreads can produce a significant H even with identical medians.