Kruskal Wallis Calculator
Run the Kruskal-Wallis H test, the non-parametric alternative to one-way ANOVA, to compare three or more independent groups by rank.
Kruskal Wallis Calculator
Calculator
Adjust values & calculateEnter your values below. Every result is computed in your browser — no data is sent to any server.
Formula: H = (12/(N(N+1))) × Σ(Rᵢ²/nᵢ) - 3(N+1)
Worked example — H = 7.20 with df = 2 | Above the 5.991 critical value, so the groups differ (p ≈ 0.027)
Formula
H = (12/(N(N+1))) × Σ(Rᵢ²/nᵢ) - 3(N+1)
Non-parametric alternative to one-way ANOVA for comparing 3+ groups.
Worked Examples
Example 1: Three groups with no ties
Problem:G1: 3, 4, 6 | G2: 8, 10, 12 | G3: 15, 18, 20
Solution:Pool all N = 9 values and rank them 1 to 9: 3=1, 4=2, 6=3, 8=4, 10=5, 12=6, 15=7, 18=8, 20=9. Rank sums: R1 = 1+2+3 = 6, R2 = 4+5+6 = 15, R3 = 7+8+9 = 24. Check: 6 + 15 + 24 = 45 = 9 x 10 / 2, so the ranking is complete. H = 12/(9 x 10) x (6²/3 + 15²/3 + 24²/3) - 3 x 10 = 0.13333 x (12 + 75 + 192) - 30 = 37.2 - 30 = 7.20.
Result:H = 7.20 with df = 2 | Above the 5.991 critical value, so the groups differ (p ≈ 0.027)
Example 2: Groups that overlap heavily
Problem:G1: 5, 9, 14 | G2: 6, 11, 13 | G3: 7, 10, 12
Solution:Ranks over the pooled sample: 5=1, 6=2, 7=3, 9=4, 10=5, 11=6, 12=7, 13=8, 14=9. R1 = 1 + 4 + 9 = 14, R2 = 2 + 6 + 8 = 16, R3 = 3 + 5 + 7 = 15 (total 45, as required). H = 12/90 x (14²/3 + 16²/3 + 15²/3) - 30 = 0.13333 x (65.333 + 85.333 + 75) - 30 = 30.089 - 30 = 0.089.
Result:H = 0.089 with df = 2 | Far below 5.991, so there is no evidence the groups differ
Frequently Asked Questions
What does the Kruskal-Wallis test measure?
The Kruskal-Wallis H test determines whether three or more independent groups come from the same distribution. It works by replacing raw values with their overall ranks and comparing the average ranks across groups. A large H statistic indicates that at least one group's distribution differs from the others.
How do you interpret the H statistic and p-value?
The H statistic follows a chi-square distribution with df = k − 1, where k is the number of groups. Compare H to the critical chi-square value at your significance level α. For two degrees of freedom (3 groups), the critical value at α = 0.05 is approximately 5.991. If H exceeds this, reject the null hypothesis that all groups have equal medians.
When should I use Kruskal-Wallis instead of one-way ANOVA?
Choose Kruskal-Wallis when your data is ordinal, when group distributions are clearly non-normal (especially with small samples), or when variances are very unequal across groups. If ANOVA assumptions are met, ANOVA has more statistical power. If the result is significant, use post-hoc Dunn's test to identify which specific pairs differ.
What are the assumptions of the Kruskal-Wallis test?
The groups must be independent; observations within each group must be independent; each group should have at least 5 observations for the chi-square approximation of H to be reliable; and observations should be from continuous or at least ordinal distributions. Unlike one-way ANOVA, normality and equal variance are not required.
How should tied values be handled when ranking the data?
The standard procedure gives every tied observation the average of the ranks they would otherwise have occupied, so two values sharing ranks 4 and 5 both become 4.5, after which H is divided by the tie correction 1 - sum(t^3 - t) / (N^3 - N). Kruskal Wallis Calculator does not do that: it assigns plain sequential ranks, so ties are split arbitrarily by input order and H is badly inflated, not conservative. Two groups of five identical values return H = 6.8182 and three groups of three identical values return H = 7.2000, both above the 5.991 note, for data with zero real difference. Use a tie-corrected routine whenever your data contains repeated values.
What is the null hypothesis actually being tested?
Formally the null is that all k samples are drawn from the same distribution, so that any observation is equally likely to outrank any other regardless of group. It is commonly described as a test of equal medians, but that reading is only valid when the group distributions share a similar shape and spread. If the groups differ in skew or dispersion, a significant H tells you the distributions differ in some way, not specifically that the medians do.
How can I check that the ranking was done correctly?
The ranks assigned across all groups are the whole numbers 1 to N, so they must total N(N + 1) / 2. With nine observations spread over three groups that sum is 9 x 10 / 2 = 45, and the three group rank sums Ri must add to exactly that. If they do not, a value was mistyped or a group was truncated. It is the quickest hand check on any Kruskal-Wallis calculation.
How does Kruskal-Wallis relate to the Mann-Whitney U test?
Kruskal-Wallis is the extension of Mann-Whitney U to more than two groups, in the same way that one-way ANOVA extends the two-sample t-test. Run with exactly two groups it is equivalent to a two-sided Mann-Whitney U test and will lead to the same decision, with H referred to a chi-square distribution on one degree of freedom. For two groups, prefer Mann-Whitney because it also reports the U statistic and supports exact small-sample p-values.
What effect size can I report alongside H?
H itself grows with sample size, so it is a poor description of magnitude. Epsilon squared, computed as H / (N - 1), rescales it to run from 0 to 1 and estimates the proportion of rank variability explained by group membership. An alternative is eta squared for ranks, (H - k + 1) / (N - k). Reporting one of these together with each group's median and rank sum makes the practical size of the difference visible.
Why does the significance note in the output assume two degrees of freedom?
The threshold of 5.991 built into the message is the upper 5 percent point of the chi-square distribution with df = 2, which is the right comparison only when you have entered three groups. With just two groups df = 1 and the corresponding critical value is about 3.841, so the on-screen note is too strict. Always read your own df from the output and compare H against the matching chi-square value.
References
Reviewed for accuracy by Manoj Kumar, Mathematics Educator · Editorial policy
Related Calculators
🧮Annulus Area Calculator
Calculate annulus area with inputs, formulas, and instant results.
🧮Area Calculator
Calculate area with inputs, formulas, and instant results.
🧮Area of a Rectangle Calculator
Calculate the area, perimeter, and diagonal of a rectangle. Find missing sides from known area. Convert between metric and imperial area units.
🧮Area of Crescent Calculator
Calculate area of crescent with inputs, formulas, and instant results.
🧮Center of Mass Calculator
Calculate center of mass with inputs, formulas, and instant results.
🧮Centroid Calculator
Calculate centroid with inputs, formulas, and instant results.
🧮Chord Length Calculator
Calculate chord length with inputs, formulas, and instant results.
🧮Conic Sections Calculator
Calculate conic sections with inputs, formulas, and instant results.