def test_chi_square2(self): obs = np.array([[10,0], [0, 10]]) ct = stats.ContingencyTable(observed=obs) xpd = stats.expected_nway(obs) chi2 = ((np.abs(obs - xpd) - 0.5)**2 / xpd).sum() assert_equal(ct.dof, 1) assert_equal(ct.chi_square(correction=True), chi2)
def test_p_value2(self): obs = np.array([[10,0], [0, 10]]) ct = stats.ContingencyTable(observed=obs) xpd = stats.expected_nway(obs) chi2 = ((np.abs(obs - xpd) - 0.5)**2 / xpd).sum() p = special.chdtrc(ct.dof, chi2) assert_equal(ct.dof, 1) assert_equal(ct.p_value(correction=True), p)
def test_chi_square1(self): obs = np.array([[10,0], [0, 10]]) ct = stats.ContingencyTable(observed=obs) xpd = stats.expected_nway(obs) chi2 = ((obs - xpd)**2 / xpd).sum() assert_equal(ct.chi_square(), chi2)