Kruskal Wallis H test - mauriceling/mauriceling.github.io GitHub Wiki

Purpose: To test whether the medians of more than 2 samples are equal.

Null hypothesis: All medians are equal.

Alternate hypothesis: At least one median is not equal to the rest.

Code:

>>> from scipy import stats
>>> X1 = [9.07, 8.97, 6.41, 3.03, 1.19, 2.67, 2.81, 9.2]
>>> X2 = [3.82, 8.26, 5.99, 3.81, 1.07, 5.06, 5.66, 4.47]
>>> X3 = [8.46, 7.46, 4.48, 1.41, 3.16, 1.77, 5.33, 6.61]
>>> result = stats.kruskal(X1, X2, X3)
>>> print("H = %.3f" % result.statistic)
H = 0.155
>>> print("p-value = %.3f" % result.pvalue)
p-value = 0.925

Reference:

  1. Kruskal WH, Wallis WW. 1952. Use of Ranks in One-Criterion Variance Analysis. Journal of the American Statistical Association 47(260), 583-621.