Kruskal-Wallis Test Calculator

Compare two or more independent groups using rank-based nonparametric analysis of variance. Compute the H statistic, degrees of freedom, p-value, and interpret results at α = 0.05. Visualize group distributions with interactive box plots.

Enter numeric values for each group separated by commas, spaces, or newlines. Each group should have at least 3 observations for reliable results.

? Three groups (plant growth): A: 5,6,7,8; B: 4,5,6,7; C: 8,9,10,11
? Five groups (fertilizer trial): 4 groups with 5 reps each
? Unequal group sizes: A: 2,3,4; B: 5,6,7,8; C: 1,2
? Clinical trial: Placebo, Low, High dose
Privacy first: All calculations are performed locally in your browser. No data is sent to any server.

What Is the Kruskal-Wallis Test?

The Kruskal-Wallis test (also known as Kruskal-Wallis one-way ANOVA on ranks) is a nonparametric statistical procedure used to determine whether there are statistically significant differences between the medians of three or more independent groups. It is the nonparametric alternative to the one-way analysis of variance (ANOVA) and does not assume that the data are normally distributed.

Developed by William Kruskal and W. Allen Wallis in 1952, this test ranks all observations from all groups together and then evaluates whether the sum of ranks in each group differs more than would be expected by chance. The test statistic, denoted H, follows a chi-square distribution with k − 1 degrees of freedom when the null hypothesis is true (where k is the number of groups), provided each group has at least 5 observations.

H = ( 12 / N(N+1) ) · Σi=1k ( Ri2 / ni ) − 3(N+1)

where N = total sample size, k = number of groups, ni = sample size of group i, and Ri = sum of ranks in group i.

When to Use the Kruskal-Wallis Test

  • Non-normal data: When your dependent variable is ordinal, skewed, or has outliers that violate normality assumptions.
  • Three or more groups: When you have three or more independent samples to compare.
  • Heterogeneous variances: When group variances are unequal (though the test is somewhat robust to variance heterogeneity).
  • Small sample sizes: Works well with small samples, though power increases with sample size.
Case Study: Agricultural Crop Yield

An agronomist tests the effect of four different fertilizers on corn yield (bushels per acre). The data are not normally distributed due to weather variability. Using the Kruskal-Wallis test, the agronomist can compare the median yields across the four fertilizer groups without assuming normality. If the test is significant (p < 0.05), post-hoc pairwise comparisons (e.g., Dunn's test) can identify which fertilizers differ.

Try the "Five groups" preset to see this example in action.

Assumptions of the Kruskal-Wallis Test

  • Independence: Observations within and across groups are independent.
  • Ordinal or continuous data: The dependent variable should be at least ordinal.
  • Identical distribution shape: The test assumes that the distributions of the groups have the same shape (though it is robust to moderate violations).
  • Random sampling: Data should be a random sample from the population of interest.

Unlike parametric ANOVA, the Kruskal-Wallis test does not require normality or homogeneity of variances. However, it does assume that the underlying distributions are continuous and identically shaped (except for location).

How the Calculator Works

Our calculator implements the full Kruskal-Wallis procedure:

  1. Data aggregation: All observations from all groups are pooled and ranked from smallest to largest (with ties handled by assigning the average rank).
  2. Rank sum calculation: For each group, the sum of ranks (Ri) is computed.
  3. H statistic: The test statistic H is computed using the formula above. A correction for ties is applied when present.
  4. p-value: The p-value is derived from the chi-square distribution with k − 1 degrees of freedom. For small samples, exact permutation p-values can be approximated.
  5. Interpretation: If p < 0.05, we reject the null hypothesis that all group medians are equal, concluding that at least one group differs.

Interpreting the Results

  • H statistic: Larger values indicate greater differences between groups. The H statistic is approximately chi-square distributed under the null.
  • Degrees of freedom: df = k − 1, where k is the number of groups.
  • p-value: The probability of observing an H statistic as extreme as the one calculated, assuming the null hypothesis is true. If p < 0.05, the result is statistically significant.
  • Conclusion: Our calculator provides a clear, plain‑English interpretation of the results at the α = 0.05 significance level.

Null hypothesis (H₀): All group medians are equal.
Alternative hypothesis (H₁): At least one group median differs from the others.

Post-Hoc Comparisons

If the Kruskal-Wallis test is significant, you may want to perform post-hoc pairwise comparisons to determine which specific groups differ. Common methods include:

  • Dunn's test: Pairwise comparisons with Bonferroni correction for multiple testing.
  • Conover-Iman test: A more powerful post-hoc procedure for nonparametric ANOVA.
  • Nemenyi test: Pairwise comparisons based on rank sums.

While this calculator does not perform post-hoc tests directly, we provide guidance on next steps. For pairwise comparisons, consider using our Dunn's Test Calculator (coming soon).

Real-World Applications

  • Medicine: Comparing the effectiveness of different treatments (e.g., drug dosages) on patient outcomes when data are skewed.
  • Education: Evaluating test scores across multiple teaching methods when scores are not normally distributed.
  • Psychology: Analyzing Likert-scale responses (ordinal data) across experimental conditions.
  • Environmental science: Comparing pollutant levels across different sites with non-normal distributions.
  • Market research: Comparing customer satisfaction scores across multiple product variants.
  • Quality control: Assessing process outputs across different production lines.

Comparison with Parametric ANOVA

Feature Kruskal-Wallis (Nonparametric) One-Way ANOVA (Parametric)
Normality assumption Not required Required
Variance homogeneity Not required (robust) Required (homoscedasticity)
Data type Ordinal or continuous Continuous (interval/ratio)
Test statistic H (chi-square distribution) F (F-distribution)
Power Slightly less powerful than ANOVA when assumptions are met More powerful when assumptions are satisfied
Outlier sensitivity Robust to outliers Sensitive to outliers

Frequently Asked Questions

There is no strict minimum, but each group should ideally have at least 5 observations for the chi‑square approximation to be valid. With smaller samples, exact permutation methods are recommended. Our calculator provides a warning if any group has fewer than 3 observations.

Tied values are assigned the average of the ranks they would have received if they were distinct. Our calculator automatically applies the tie correction factor to the H statistic, reducing the risk of inflated Type I error.

A significant p‑value (p < 0.05) indicates that at least one group differs from the others in terms of median rank. However, it does not tell you which groups differ. Post‑hoc tests (e.g., Dunn's test) are needed for pairwise comparisons.

Yes, but for two groups, the Mann‑Whitney U test is more commonly used and is equivalent to the Kruskal‑Wallis test with k = 2. Our calculator supports two groups as well.

The p‑value is derived from the chi‑square distribution with k − 1 degrees of freedom. Our calculator uses an implementation of the regularized incomplete Gamma function to compute the upper‑tail probability of the chi‑square distribution.

The Kruskal‑Wallis test assumes independence. If your data are paired or repeated measures, consider the Friedman test instead, which is the nonparametric alternative to repeated‑measures ANOVA.

Rooted in statistical best practice – This tool implements the Kruskal‑Wallis test as described in Kruskal & Wallis (1952) and is consistent with the methodology recommended in standard texts (Conover, 1999; Hollander, Wolfe & Chicken, 2013). The numerical implementation has been verified against R's kruskal.test() and SPSS output. Reviewed by the GetZenQuery tech team, last updated July 2026.

References: 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. Conover, W.J. (1999). Practical Nonparametric Statistics, 3rd ed. Wiley. Hollander, M., Wolfe, D.A. & Chicken, E. (2013). Nonparametric Statistical Methods, 3rd ed. Wiley. Wikipedia: Kruskal-Wallis test.