The Kruskal-Wallis is a non-parametric hypothesis test used to compare the difference of two or more population median. It’s like the One-way ANOVA but for nonnormal distribution.

For run this test it’s important that:

  • All samples are random from the respective population;
  • The data of the two samples need to be ordinal so the value are comparable;
  • The distribution of the k samples isn’t normal;
  • The k samples are independent of each other;
  • In each sample, the observation is independent.

In this case the hypothesis are like:

  • H0: all the k population median are equal
  • H1at least one of the median are different.

The way to conduct the hypothesis test is like the one-sample t-tests, but we use another statistics.

The statistics for this test is the one in image1:

image1 - Kruskal-Wallis statistic
image1 – Kruskal-Wallis statistic


  • k is the number of sample;
  • ni is the number of observation in each of the K sample;
  • Ri is the sum of the rank of each sample (*).
  • n is the total number of observation in all the sample.

(*) like the Mann-Whitney, you are working with an ordinal variable. In this case, you need to put together all the observations and give an ordinal rank. See the Mann-Whitney chapter for a practical example of this.

For the critical value you need to look at the chi-square distribution table, using k-1 as degree of freedom.

Now you can conduct the test like all the tests comparing the statistics to the critical value.

Share on: