Kruskal–Wallis Test Calculator

Kruskal–Wallis Test Calculator

Growing AI Skill PRO

Enter Calculation

Formula

C=1−∑j(tj3−tj)n3−n,H=H0/CC=1-\frac{\sum_j (t_j^3-t_j)}{n^3-n},\quad H=H_0/C
Show calculation steps (2)
  1. p-value

    p=P(χk−12≥H)vsSignificance level (alpha)p=P(\chi^2_{k-1}\ge H)\;\text{vs}\;\text{Significance level (alpha)}

    Upper tail of chi-square with k-1 degrees of freedom, compared with alpha.

  2. H without tie correction

    H0=12n(n+1)∑i=1kRi2ni−3(n+1) with ranks from Group 1 values,Group 2 values,Group 3 values,Group 4 values,Group 5 values,Group 6 valuesH_0=\frac{12}{n(n+1)}\sum_{i=1}^{k}\frac{R_i^2}{n_i}-3(n+1)\;\text{ with ranks from }\text{Group 1 values},\text{Group 2 values},\text{Group 3 values},\text{Group 4 values},\text{Group 5 values},\text{Group 6 values}

    Statistic from the NIST Dataplot manual, computed from rank sums of the groups.

Usage stats

Advertisement

Results

H statistic (tie-corrected)
2.8538
H before tie correction 2.8538
Tie correction factor C 1.0000
Degrees of freedom 2
p-value 0.2401
Critical value 5.9915
Reject H0 No
Total observations 18
Number of groups 3
Rank sums 39.0,65.0,67.0
Small sample warning No

Report an error on this page

What the Kruskal–Wallis calculator does

The Kruskal–Wallis test is a rank-based, one-factor test of whether k independent samples come from identical populations. It is the non-parametric counterpart of one-way ANOVA and is used when data are ordinal, skewed or contain outliers. The calculator pools the observations, assigns ranks (average ranks for ties), computes the rank sums, the tie-corrected H statistic, the chi-square p-value, the critical value and a reject or retain decision.

How to use it

Enter the observations for Group 1, Group 2 and Group 3 as numbers separated by commas, semicolons or spaces. Groups 1 to 3 are required. Groups 4, 5 and 6 are optional: type - in any group that is not used. Then set the significance level alpha (default 0.05). Group sizes may differ, group order does not change H, and the total may not exceed 5000 observations.

Formula

Without ties the statistic is

$$H_0=\frac{12}{n(n+1)}\sum_{i=1}^{k}\frac{R_i^2}{n_i}-3(n+1)$$

where \(n_i\) = observations in group i, \(R_i\) = rank sum of group i, \(n\) = total observations and \(k\) = number of groups. With ties:

$$C=1-\frac{\sum_j (t_j^3-t_j)}{n^3-n},\qquad H=\frac{H_0}{C}$$

where \(t_j\) = size of the j-th group of tied values. The p-value is

$$p=P(\chi^2_{k-1}\ge H)$$

The test rejects the null hypothesis when H exceeds the chi-square percent point at 1 − alpha with k − 1 degrees of freedom.

Advertisement
Observations from three groups pooled onto a single number line, ranked 1 to 12, with the ranks summed for each group
All observations are ranked together, then the ranks are added up within each group to give the rank sums R_i.

Conventions and assumptions

  • Tied values receive the average of the ranks they span. The reported H is the tie-corrected value, equal to the uncorrected H when there are no ties. The tie correction is the standard Conover/Kruskal–Wallis form, chosen as a design decision because the NIST page does not print it.
  • H is compared with a chi-square distribution with k − 1 degrees of freedom, using the upper tail.
  • Decision rule: reject H0 if H is above the critical value. Default alpha is 0.05.
  • If any group has fewer than 5 observations, a small-sample warning is shown because the chi-square approximation may be unreliable. The result is still computed.
  • If all values are identical, C = 0 and H is undefined, so the calculator reports an error. At least two groups are needed. H = 0 gives p = 1.
  • Raw values are used internally. Display: H, p, critical value and C to 4 decimals, rank sums to 1 decimal.

Worked example

Three groups of six values: Group 1 = 27, 2, 4, 18, 7, 9; Group 2 = 20, 8, 14, 36, 21, 22; Group 3 = 34, 31, 3, 23, 30, 6; alpha = 0.05. Here \(n=18\), \(k=3\), and there are no ties.

$$R_1=39.0,\quad R_2=65.0,\quad R_3=67.0$$$$H_0=\frac{12}{18\times 19}\left(\frac{39^2}{6}+\frac{65^2}{6}+\frac{67^2}{6}\right)-3\times 19=2.8538$$

The tie factor is \(C=1\), so \(H=2.8538\) (the same as before correction). Degrees of freedom are 2, the p-value is 0.2401 and the critical value is 5.9915. Since 2.8538 is below 5.9915, H0 is not rejected. No small-sample warning applies because each group has 6 observations.

Reading the result and limitations

A small p-value (below alpha) suggests at least one group tends to give larger or smaller values than another. The test does not say which groups differ; follow a significant result with pairwise comparisons. It assumes independent samples and, for an interpretation as a difference in medians, similarly shaped distributions. With groups smaller than 5, exact tables are preferable to the chi-square approximation.

Advertisement
Chi-square distribution curve with a shaded right tail beyond the critical value and an observed H value marked on the axis
H is compared with a chi-square distribution with k − 1 degrees of freedom, and the area in the right tail beyond H is the p-value.

FAQ

When should I use Kruskal–Wallis instead of ANOVA?

Use it when normality is doubtful, data are ordinal, or outliers are present.

How are ties handled?

Tied values share the average of their ranks, and H is divided by the correction factor C.

What does the small-sample warning mean?

At least one group has fewer than 5 values, so the chi-square p-value is only approximate.

Can I use unequal group sizes?

Yes. The formula weights each rank sum by its own group size.

Why do I need to type - for unused groups?

A blank field is replaced with its default, so the dash marks a group as unused. Only groups 4 to 6 can be unused.

Sources

Sources & References

  • Dataplot KRUSKAL WALLIS command reference — NIST Information Technology Laboratory. Gives H, chi-square with k-1 df, the critical region and the n_i >= 5 guidance. Cites Conover (1999) for the formulation; the tie-correction formula is not printed. · Effective from 2023-12-11 · Verified 2026-11-04
Last updated:

Most popular in Math and Statistics

View all Math and Statistics calculators