scipy.stats.chisquare

scipy.stats.chisquare(f_obs, f_exp=None, ddof=0)[source]

Calculates a one-way chi square test.

The chi square test tests the null hypothesis that the categorical data has the given frequencies.

Parameters :

f_obs : array

observed frequencies in each category

f_exp : array, optional

expected frequencies in each category. By default the categories are assumed to be equally likely.

ddof : int, optional

adjustment to the degrees of freedom for the p-value

Returns :

chisquare statistic : float

The chisquare test statistic

p : float

The p-value of the test.

Notes

This test is invalid when the observed or expected frequencies in each category are too small. A typical rule is that all of the observed and expected frequencies should be at least 5. The default degrees of freedom, k-1, are for the case when no parameters of the distribution are estimated. If p parameters are estimated by efficient maximum likelihood then the correct degrees of freedom are k-1-p. If the parameters are estimated in a different way, then then the dof can be between k-1-p and k-1. However, it is also possible that the asymptotic distributions is not a chisquare, in which case this test is not appropriate.

References

[R171]Lowry, Richard. “Concepts and Applications of Inferential Statistics”. Chapter 8. http://faculty.vassar.edu/lowry/ch8pt1.html

Previous topic

scipy.stats.kstest

Next topic

scipy.stats.ks_2samp