induwara.lk
induwara.lkStatistics · Non-parametric

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.

By Induwara AshinsanaUpdated Jul 10, 2026
Kruskal-Wallis H test
Ranks · tie-corrected · cross-checked
4 values

Numbers separated by commas, spaces, or new lines.

4 values

Numbers separated by commas, spaces, or new lines.

4 values

Numbers separated by commas, spaces, or new lines.

3 of 8 groups
Try an example

Any value from 0.0001 to 0.5. 0.05 is the usual default.

Tie correction
Fail to reject H₀ — no significant difference among the groups (H = 1.885, df = 2, p = 0.3897 ≥ 0.05).
H statistic (df = 2)
1.8846
No tie correction
p-value (upper tail)
0.3897
Critical χ² at α = 0.05
5.9915
H below χ²* → not significant
Total N / groups k
12 / 3

Per-group rank summary

GroupnRank sum (Rᵢ)Mean rank
Fertiliser A4266.5
Fertiliser B4338.25
Fertiliser C4194.75
All groups12786.5

Test statistics

Total observations N12
H (uncorrected)1.884615
Tie sum ΣT = Σ(t³ − t)(no ties)0
Correction factor C(1 − ΣT / (N³ − N))1
H (tie-corrected)1.884615
Degrees of freedom (k − 1)2
p-value0.3897

Cross-check: rank sums total 78, matching the identity N(N+1)/2 = 78. The uncorrected H from the Σ(Rᵢ²/nᵢ) formula (1.884615) and from the mean-rank deviation formula (1.884615) agree to floating-point precision.

At least one group has fewer than 5 values. The chi-square approximation of the p-value is less reliable for very small groups; treat a borderline result with caution or use an exact permutation test.
H is not significant, so the data give no evidence that the group distributions differ. Remember that failing to reject H₀ is not proof the groups are identical, especially with small samples.
The Kruskal-Wallis test assumes independent groups and at least ordinal data. It does not assume normality, which is why it suits skewed or small samples where one-way ANOVA's assumptions fail. The chi-square approximation of the null distribution is most accurate when each group has roughly five or more values.
Sources cited

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.

  1. 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.
  2. 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.
  3. H statistic. Compute H = [12 / (N(N+1))] · Σ(Rᵢ²/nᵢ) − 3(N + 1), where nᵢ is the size of group i.
  4. 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.
  5. 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).
  6. 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

Three fertilisers, no ties — not significant

A = {12, 15, 18, 20}, B = {14, 16, 22, 25}, C = {10, 11, 13, 30}

  1. Pool & rank (N = 12): 10→1, 11→2, 12→3, 13→4, 14→5, 15→6, 16→7, 18→8, 20→9, 22→10, 25→11, 30→12
  2. Rank sums: R_A = 26, R_B = 33, R_C = 19 (Σ = 78 = 12·13/2 ✓)
  3. Σ(Rᵢ²/nᵢ) = (26² + 33² + 19²)/4 = 531.5
  4. H = (12/156)·531.5 − 3·13 = 40.8846 − 39 = 1.885, df = 2
  5. p = e^(−1.885/2) = 0.390 → fail to reject H₀ (no difference)

Three groups with a tie — shows tie correction

A = {10, 12, 12, 15}, B = {12, 14, 16, 18}, C = {9, 11, 13, 20}

  1. The three 12's share ranks 4, 5, 6 → each gets rank 5
  2. Rank sums: R_A = 21, R_B = 34, R_C = 23 (Σ = 78 ✓)
  3. H (uncorrected) = (12/156)·531.5 − 39 = 1.8846
  4. Ties: one set of t = 3 → ΣT = 3³ − 3 = 24; C = 1 − 24/(12³−12) = 0.98601
  5. H (corrected) = 1.8846 / 0.98601 = 1.911, df = 2 → p = e^(−0.9556) = 0.385

Clean separation — clearly significant

G1 = {3,4,5,6,7}, G2 = {8,9,10,11,12}, G3 = {13,14,15,16,17}

  1. No ties (N = 15). Rank sums: R = 15, 40, 65 (Σ = 120 = 15·16/2 ✓)
  2. Σ(Rᵢ²/nᵢ) = (225 + 1600 + 4225)/5 = 1210
  3. H = (12/240)·1210 − 3·16 = 60.5 − 48 = 12.5, df = 2
  4. p = e^(−6.25) = 0.0019 → reject H₀ (at least one group differs)

Frequently asked questions

Sources & references

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

Rate this tool
Be the first to rate

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.