Kruskal-Wallis Test Calculator

Kruskal-Wallis Test Calculator

Compare two or more independent groups without assuming normality — from pasted raw data or from group sizes and rank sums — with the tie-corrected H statistic, p-value, epsilon squared, Dunn’s post-hoc tests and a box plot.

One value per line, or separated by commas or spaces. Each group needs at least 1 value; use at least 5 per group for the chi-square approximation to be reliable.

H STATISTIC · DF 2
10.3432

Reject H₀ at α = 0.05 — with H = 10.3432 and a p-value of 0.0057, at least one group differs from the others.

P-value
0.0057
Epsilon squared (ε²)
0.7388
Degrees of freedom
2
Critical χ²
5.9915
Mean ranks
8.20, 3.40, 12.40
Total N
15

Calculation

    Dunn’s post-hoc tests

    Pairwise comparisons after a significant H, with Bonferroni-adjusted p-values (each raw p multiplied by the number of comparisons).

    Ranking

    Every value is replaced by its rank in the pooled sample; tied values share the average of their ranks.

    Box plot of the groups

    The boxes show the median and quartiles of each group; the dot marks the group mean.

    Decision rule: reject H₀ when H exceeds the critical χ² value. Here H = 10.3432 exceeds 5.9915, so the result is significant — but H alone does not say which groups differ; that is what Dunn’s table above is for.

    A Kruskal-Wallis test calculator compares three or more independent groups without assuming normality. Paste your raw data, or enter group sizes and rank sums, and it returns the tie-corrected H statistic, degrees of freedom, p-value, mean ranks, epsilon squared and Dunn’s post-hoc tests, with a box plot of the groups.

    How to use the Kruskal-Wallis test calculator

    Use Raw data when you have the individual measurements. Use Summary (rank sums) when you already know each group’s size and rank sum.

    1. Choose the number of groups (2 to 6) and your significance level (α).
    2. In Raw data mode, paste one group per box, one value per line, or separated by commas or spaces.
    3. In Summary mode, enter each group’s size (n) and rank sum (R). The rank sums must add to N(N + 1) / 2.
    4. Read the headline H statistic, then check the results grid for the p-value, epsilon squared, degrees of freedom and critical chi-square value. The calculation ledger shows every step, Dunn’s table tests each pair, and the box plot shows the groups side by side.

    Try it now: with the default data — A = 6, 8, 7, 9, 8; B = 5, 4, 6, 5, 7; C = 9, 10, 8, 9, 12 — the calculator gives H = 10.3432, df = 2 and a p-value of 0.0057, significant at the 5% level. The mean ranks are 8.20, 3.40 and 12.40.

    What is the Kruskal-Wallis test?

    The Kruskal-Wallis test is the rank version of a one-way ANOVA. Instead of comparing group means, it pools all the observations, replaces each value with its rank, and asks whether the average ranks differ more than chance would allow. Because it works with ranks, it makes no assumption that the data are normally distributed, and it is not pulled around by outliers or skew the way a test on means is.

    The null hypothesis is that the groups come from the same distribution — in practice, that their medians (or, more precisely, their distributions) are the same. The alternative is that at least one group differs from the others. A significant H tells you that something differs, but not which groups: that is what Dunn’s post-hoc tests are for.

    When to use it instead of ANOVA: if your data are approximately normal with similar variances, run the one-way ANOVA calculator — it is more powerful. If the data are skewed, ordinal, or the variances differ, use Kruskal-Wallis. Check normality first with the Shapiro-Wilk test calculator; if it is not normal, this page is the right next step.

    Kruskal-Wallis vs ANOVA: which one do you need?

    QuestionKruskal-Wallis testOne-way ANOVA
    What is compared?Mean ranks (distributions)Group means
    Normality needed?NoYes, approximately
    Equal variances needed?No (similar shape assumed)Yes
    Data typeOrdinal or continuous, skewed dataContinuous, roughly normal data
    Test statisticH, compared with chi-squareF, compared with the F-distribution
    Post-hoc testDunn’s testTukey’s HSD
    Groups3 or more independent groups3 or more independent groups

    With only two groups, Kruskal-Wallis reduces to the Mann-Whitney U test calculator — the two give the same p-value. With paired data (the same subjects measured twice), use the Wilcoxon signed-rank test calculator instead. If you are unsure which test fits your data, the which statistical test should I use guide walks through the choice.

    How the H statistic is calculated

    The test has three steps: rank, sum, compare.

    1. Rank everything together. Pool all N observations and rank them from smallest (rank 1) to largest (rank N). Tied values share the average of the ranks they cover. For example, two values tied at ranks 2 and 3 each get rank 2.5.
    2. Add the ranks per group. Each group’s rank sum is R, and its mean rank is R / n.
    3. Form H. The formula is H = [12 / (N(N + 1))] × Σ(R² / n) − 3(N + 1). When there are ties, H is divided by the correction factor C = 1 − Σ(t³ − t) / (N³ − N), where t is the size of each tie group. Without the correction, ties would make H too small.

    H is then compared with a chi-square distribution with k − 1 degrees of freedom, where k is the number of groups. That is a large-sample approximation: it is reliable when each group has at least 5 observations, treat results from groups smaller than 5 as approximate. The p-value is P(χ² with k − 1 df ≥ H).

    The effect size is epsilon squared: ε² = H / ((N² − 1) / (N + 1)). It is the share of the variation in ranks that the grouping explains. As a rough guide, 0.01 is small, 0.08 is medium and 0.26 is large — the worked example below, at 0.7388, is a very large effect. The same quantity is reported as eta squared by the one-way ANOVA calculator; for a Kruskal-Wallis test, epsilon squared is the standard name.

    Worked example 1: three groups, same data as the ANOVA example

    Three teaching methods are compared on test scores. The data are the same as the one-way ANOVA worked example, so you can compare the two tests directly.

    GroupScoresRank sum (R)Mean rank
    A6, 8, 7, 9, 841.08.20
    B5, 4, 6, 5, 717.03.40
    C9, 10, 8, 9, 1262.012.40

    There are N = 15 values. Pooling and ranking them (ties averaged) gives rank sums 41, 17 and 62, which add to 120 = 15 × 16 / 2, as they must. Then Σ(R² / n) = 41²/5 + 17²/5 + 62²/5 = 1162.8, so the uncorrected H is [12 / (15 × 16)] × 1162.8 − 48 = 10.1400. The tie groups are 5 (twice), 6 (twice), 7 (twice), 8 (three times) and 9 (three times), so Σ(t³ − t) = 66 and C = 1 − 66 / 3360 = 0.9804. The tie-corrected H is therefore 10.1400 / 0.9804 = 10.3432, with df = 2 and a p-value of 0.0057 (full value 0.0056755676). Epsilon squared is 0.7388. At α = 0.05 the result is significant: at least one method differs from the others.

    Dunn’s post-hoc tests for this example

    ComparisonzRaw pBonferroni pSignificant?
    A − B1.7140.08650.2596No
    A − C−1.49970.13370.4011No
    B − C−3.21370.00130.0039Yes

    Only B − C is significant after the Bonferroni correction. Dunn’s test is more conservative than Tukey’s HSD — on the same data, the one-way ANOVA calculator’s Tukey test called A − B significant, and Dunn’s does not. The rank test and the correction both cost power, so a real difference between A and B that ANOVA detects can slip past Kruskal-Wallis with Dunn’s. That is the price of not assuming normality, and it is why you should use ANOVA when its assumptions hold.

    Worked example 2: two groups

    With two groups the test is a check against the Mann-Whitney U test. Take [3, 5, 7] against [4, 6, 8, 10]. The ranks are 1, 3, 5 and 2, 4, 6, 7, giving rank sums 9 and 19. Then H = [12 / (7 × 8)] × (9²/3 + 19²/4) − 24 = 1.125, df = 1, p-value = 0.2888 — not significant, and identical to the Mann-Whitney result on the same data.

    Edge cases the calculator handles

    • Ties. With [1, 2, 2, 3] / [2, 3, 4, 4] / [5, 5, 6, 7], the tie-corrected H is 8.7625 and the p-value is 0.0125 — significant at 5%. Without the correction H would be smaller, so the correction matters whenever values repeat.
    • Identical groups. With [5, 5, 5] in all three groups, every value is tied and H = 0 with a p-value of 1.0. The calculator special-cases this: the tie-correction denominator would be zero, so it returns H = 0 directly instead of dividing by zero.
    • One group only. A single group cannot be compared with anything. The calculator shows an error message instead of a number — enter at least two groups.
    • Small groups. With fewer than 5 values per group, the chi-square approximation is rough. The p-value is still shown, but treat it as approximate and prefer larger samples when you can.

    Frequently asked questions

    When do I use Kruskal-Wallis instead of ANOVA?

    Use Kruskal-Wallis when your data are skewed, ordinal, or the group variances differ — in short, when ANOVA’s assumptions do not hold. Check with the Shapiro-Wilk test calculator: if the data are not normal, Kruskal-Wallis is the safer choice. When the data are normal with similar variances, ANOVA is more powerful and you should use the one-way ANOVA calculator instead.

    Why is H compared to chi-square?

    When the null hypothesis is true and the samples are large enough, the H statistic follows approximately a chi-square distribution with k − 1 degrees of freedom, where k is the number of groups. That is why the p-value is the upper tail of the chi-square distribution at H. The approximation needs at least about 5 observations per group; with very small samples, exact tables or a permutation test are better.

    What is Dunn’s test?

    Dunn’s test is the post-hoc test that follows a significant Kruskal-Wallis result. It compares each pair of groups using their mean ranks, giving a z statistic and a p-value for each pair. Because several comparisons are made at once, the p-values are adjusted — here with the Bonferroni correction, multiplying each raw p-value by the number of comparisons — so that the overall false-positive rate stays at your chosen α. Run Dunn’s test only after a significant H; running it after a non-significant H is fishing.

    Sources: Kruskal, W. H., & Wallis, W. A. (1952). Use of ranks in one-criterion variance analysis. Journal of the American Statistical Association, 47(260), 583–621; Dunn, O. J. (1964). Multiple comparisons using rank sums. Technometrics, 6(3), 241–252. All worked examples on this page were recomputed with scipy.stats.kruskal and scipy.stats.chi2. Last updated 19 November 2026.

    See all 91 free statistics tools — every calculator on this site in one place.