-
Notifications
You must be signed in to change notification settings - Fork 10
Chi Square test
Maurice HT Ling edited this page Aug 14, 2021
·
6 revisions
Purpose: To test whether 2 distributions are equal.
Null hypothesis: Observed distribution = Expected distribution
Alternate hypothesis: Observed distribution ≠ Expected distribution
Note: This test is also known as Pearson's Chi-Square test.
Code:
>>> from scipy import stats
>>> observed = [16, 18, 16, 14, 12, 12]
>>> expected = [16, 16, 16, 16, 16, 8]
>>> result = stats.chisquare(observed, expected)
>>> print("statistic = %.2f" % result[0])
statistic = 3.50
>>> print("p-value = %.2f" % result[1])
p-value = 0.62
Reference:
- Pearson K. 1900. On the criterion that a given system of deviations from the probable in the case of a correlated system of variables is such that it can be reasonably supposed to have arisen from random sampling. Philosophical Magazine 5(50), 157-175.
Copyright (c) 2008-2024, Maurice HT Ling
Refereed Publications and Technical Reports
Abstracts and Other Un-Refereed Works
Autobiographic Verses (Poems that I wrote) and My Sayings