Skip to content
Maurice HT Ling edited this page Aug 14, 2021 · 1 revision

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.power_divergence(observed, expected, lambda_="log-likelihood")
>>> print("statistic = %.2f" % result.statistic)
statistic = 3.33
>>> print("p-value = %.2f" % result.pvalue)
p-value = 0.65

Reference:

  1. McDonald JH. 2014. G–test of goodness-of-fit. Handbook of Biological Statistics (Third edition). Baltimore, Maryland: Sparky House Publishing. pp. 53–58.
Clone this wiki locally