from scipy import stats
from statsmodels.stats.proportion import proportions_ztest
stats.chisquare([502,498],[500,500])[1]
proportions_ztest(count=502, nobs=1000, value=0.5)[1]
stats.chisquare([502,498],[500,500])[1] - proportions_ztest(count=502, nobs=1000, value=0.5)[1]
stats.chisquare([600,400],[500,500])[1]
proportions_ztest(count=400, nobs=1000, value=0.5)[1]
stats.chisquare([600,400],[500,500])[1] -proportions_ztest(count=400, nobs=1000, value=0.5)[1]
python
Python 2.7.16 (default, Oct 10 2019, 22:02:15)
[GCC 8.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from scipy import stats
>>> from statsmodels.stats.proportion import proportions_ztest
>>>
>>> stats.chisquare([502,498],[500,500])[1]
0.8993431885613663
>>> proportions_ztest(count=502, nobs=1000, value=0.5)[1]
0.8993423875828498
>>> stats.chisquare([502,498],[500,500])[1] - proportions_ztest(count=502, nobs=1000, value=0.5)[1]
8.009785165130623e-07
>>>
>>> stats.chisquare([600,400],[500,500])[1]
2.5396285894708634e-10
>>> proportions_ztest(count=400, nobs=1000, value=0.5)[1]
1.082387390934913e-10
>>> stats.chisquare([600,400],[500,500])[1] -proportions_ztest(count=400, nobs=1000, value=0.5)[1]
1.4572411985359504e-10
At first glance, this seems to be more sensitive.