The Kruskal-Wallis test is a nonparametric
version of classical one-way ANOVA, and an extension of the Wilcoxon
rank sum test to more than two groups. It compares the medians of
the groups of data in `x`

to determine if the samples
come from the same population (or, equivalently, from different populations
with the same distribution).

The Kruskal-Wallis test uses ranks of the data, rather than
numeric values, to compute the test statistics. It finds ranks by
ordering the data from smallest to largest across all groups, and
taking the numeric index of this ordering. The rank for a tied observation
is equal to the average rank of all observations tied with it. The *F*-statistic
used in classical one-way ANOVA is replaced by a chi-square statistic,
and the *p*-value measures the significance of
the chi-square statistic.

The Kruskal-Wallis test assumes that all samples come from populations
having the same continuous distribution, apart from possibly different
locations due to group effects, and that all observations are mutually
independent. By contrast, classical one-way ANOVA replaces the first
assumption with the stronger assumption that the populations have
normal distributions.