Cramér von Mises test - mauriceling/mauriceling.github.io GitHub Wiki

Purpose: To test whether 2 distributions are equal.

Null hypothesis: Observed distribution = Expected distribution

Alternate hypothesis: Observed distribution ≠ Expected distribution

Code:

>>> from scipy import stats
>>> observed = [16, 18, 16, 14, 12, 12]
>>> expected = [16, 16, 16, 16, 16, 8]
>>> result = stats.cramervonmises_2samp(observed, expected)
>>> print("statistic = %.2f" % result.statistic)
statistic = 0.16
>>> print("p-value = %.2f" % result.pvalue)
p-value = 0.41

Reference:

  1. Cramér H. 1928. On the Composition of Elementary Errors. Scandinavian Actuarial Journal 1928(1), 13–74.
  2. Anderson TW. 1962. On the distribution of the two-sample Cramer-von-Mises criterion. The Annals of Mathematical Statistics 33(3): 1148–1159.