Python scipy chisquare returns different values than R chisquare

假如想象 提交于 2019-12-03 15:52:34

For this chisq.test call python equivalent is chi2_contingency:

This function computes the chi-square statistic and p-value for the hypothesis test of independence of the observed frequencies in the contingency table observed.

>>> arr = np.array([38,27,23,17,11,4,98,100,80,85,60,23]).reshape(2,-1)
>>> arr
array([[ 38,  27,  23,  17,  11,   4],
       [ 98, 100,  80,  85,  60,  23]])
>>> chi2, p, dof, expected = scipy.stats.chi2_contingency(arr)
>>> chi2, p, dof
(7.0762165124844367, 0.21503342516989818, 5)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!