Skip to main content
Calcimator

Kruskal-Wallis Test Calculator

Perform a Kruskal-Wallis H test to compare rank distributions across multiple independent groups.

About this calculator

This calculator computes the Kruskal-Wallis H statistic from each group's size and rank sum: H = (12 / (N(N+1))) × Σ(Rank Sum² / n) − 3(N+1) (lines 21-29), then converts H to an approximate p-value through the same chi-square-to-normal approximation used elsewhere on this site (lines 34-44), rather than an exact permutation distribution. Degrees of Freedom is Number of Groups (k) minus 1 (line 31) — it does not depend on Total Observations or any group's size or rank sum at all, since it comes purely from how many groups you're comparing, hard-capped at 5 and floored at 2 (line 5). At the defaults (3 groups, N=30), H comes to 2.5161 with an approximate p-value of 0.2837 — not significant at α=0.05, despite three groups whose rank sums (120, 165, 180) look meaningfully different at a glance.

Total Observations (N) moves H the most when nudged up or down, more than any single group's rank sum, because N appears twice in the formula — once in the leading 12/(N(N+1)) coefficient and once again in the −3(N+1) term subtracted at the end (line 28). Effect Size (η²H) is derived directly from H via (H − k + 1) / (N − k) (lines 50-53) and is floored at 0 rather than allowed to go negative when H is small relative to the group count. What this does not account for: tied ranks needing a correction factor (the standard Kruskal-Wallis formula divides by a tie-correction term this implementation omits), and post-hoc pairwise comparisons after a significant result.

Inputs

Results

H Statistic

2.52

P-Value (approx)

0.28

Degrees of Freedom2
Significant at α=0.05 (1=Yes)0
Effect Size (η²H)0.02
How to Use This Calculator
  1. Enter Total Observations (N), Number of Groups (k), and Group 1 Size (n₁).
  2. Set Group 1 Rank Sum (R₁), Group 2 Size (n₂), and Group 2 Rank Sum (R₂).
  3. Adjust Group 3 Size (n₃), Group 3 Rank Sum (R₃) as needed.
  4. Review H Statistic and P-Value (approx).
  5. Use Degrees of Freedom and Significant at α=0.05 (1=Yes) to inform your decision.

How the result changes with Total Observations (N)

Total Observations (N)H StatisticP-Value (approx)
15322.130
2388.920
45-95.091
75-212.421

What each input means

Total Observations (N)
Total number of observations across all groups combined.
Number of Groups (k)
Number of independent groups being compared (2-5).
Group 1 Size (n₁)
Number of observations in the first group.
Group 1 Rank Sum (R₁)
Sum of ranks for Group 1 after ranking all observations together.
Group 2 Size (n₂)
Number of observations in the second group.
Group 2 Rank Sum (R₂)
Sum of ranks for Group 2 after ranking all observations together.
Group 3 Size (n₃)
Number of observations in the third group.
Group 3 Rank Sum (R₃)
Sum of ranks for Group 3 after ranking all observations together.

How this is calculated

Worked example, using the default values

  1. Identify Input Parameters
    4 parameters
    Total Observations (N) = 30, Number of Groups (k) = 3, Group 1 Size (n₁) = 10, Group 1 Rank Sum (R₁) = 120 = 8 input(s) provided
  2. Calculate H Statistic
    H Statistic
    2.5161 = 2.5161
  3. Calculate P-Value
    P-Value
    0.2837 = 0.2837
  4. Calculate Degrees of Freedom
    Degrees of Freedom = df
    2 = 2
  5. Calculate Significant at α=0.05
    Significant at α=0.05
    0 = 0

Engine last updated . Checked against 1 independently-derived test — how we verify calculators. Built by Paul Gunder, a software engineer, not a licensed financial, medical, or legal professional.

Frequently Asked Questions

Why does Degrees of Freedom never respond to Total Observations or any group's rank sum?

Because it's computed purely from how many groups you're comparing — `groupCount - 1` (line 31) — and nothing else. Total Observations, every group's size, and every group's rank sum all feed the H Statistic and p-value calculations, but none of them appear anywhere in the Degrees of Freedom formula itself.

Why does Total Observations move the H Statistic more than any individual group's rank sum?

Total Observations (N) appears twice in the H formula: once in the leading coefficient 12/(N(N+1)) that scales the entire sum, and once again in the −3(N+1) term subtracted at the end (line 28). A single group's rank sum only enters through its own squared term, so N's dual role gives it outsized leverage when you nudge values up or down by the same proportion.

Does this calculator correct for tied ranks the way the standard Kruskal-Wallis formula does?

No — the textbook Kruskal-Wallis H statistic divides by a tie-correction factor that shrinks toward 1 as ties become rarer and adjusts the statistic upward when many observations share the same rank; this implementation's formula (lines 21-29) omits that correction entirely, so results with heavily tied data will read slightly low compared to a tie-corrected calculation.

Can Effect Size (η²H) ever show as negative?

No — even though its formula, (H − k + 1) / (N − k) (lines 50-53), can mathematically go negative when H is small relative to the number of groups, the calculator wraps it in `Math.max(0, …)` before rounding, so any negative result from the raw formula displays as 0 rather than a negative effect size, which wouldn't be meaningful anyway.

The questions that sit next to this one — chosen by subject, including calculators filed under a different category.

More in Math & Statistics.