Compute the Kruskal-Wallis H-test for independent samples

The Kruskal-Wallis H-test tests the null hypothesis that the population median of all of the groups are equal. It is a non-parametric version of ANOVA. The test works on 2 or more independent samples, which may have different sizes. Note that rejecting the null hypothesis does not indicate which of the groups differs. Post-hoc comparisons between groups are required to determine which groups are different.


sample1, sample2, ... : array_like

Two or more arrays with the sample measurements can be given as arguments.


statistic : float

The Kruskal-Wallis H statistic, corrected for ties

pvalue : float

The p-value for the test using the assumption that H has a chi square distribution


Due to the assumption that H has a chi square distribution, the number of samples in each group must not be too small. A typical rule is that each sample must have at least 5 measurements.