def test_t_paired_specific_difference(self): """t_paired should allow a specific difference to be passed""" x, y = self.x, self.y # difference is 0.2, so test should be non-significant if 0.2 passed self.assertFalse(t_paired(y, x, exp_diff=0.2)[0] > 1e-10) # same, except that reversing list order reverses sign of difference self.assertFalse(t_paired(x, y, exp_diff=-0.2)[0] > 1e-10) # check that there's no significant difference from the true mean np.testing.assert_allclose( t_paired(y, x, exp_diff=0.2)[1], 1, 1e-4)
def test_t_paired_1tailed(self): """t_paired should match pre-calculated 1-tailed values""" x, y = self.x, self.y # check probability for 1-tailed low and high np.testing.assert_allclose( t_paired(y, x, "low")[1], 1 - (1.301439e-11 / 2), 1e-4) np.testing.assert_allclose( t_paired(x, y, "high")[1], 1 - (1.301439e-11 / 2), 1e-4) np.testing.assert_allclose( t_paired(y, x, "high")[1], 1.301439e-11 / 2, 1e-4) np.testing.assert_allclose( t_paired(x, y, "low")[1], 1.301439e-11 / 2, 1e-4)
def test_t_paired_no_variance(self): """t_paired should return None if lists are invariant""" x = [1, 1, 1] y = [0, 0, 0] self.assertEqual(t_paired(x, x), (None, None)) self.assertEqual(t_paired(x, y), (None, None))
def test_t_paired_2tailed(self): """t_paired should match values from Sokal & Rohlf p 353""" x, y = self.x, self.y # check value of t and the probability for 2-tailed np.testing.assert_allclose(t_paired(y, x)[0], 19.7203, 1e-4) np.testing.assert_allclose(t_paired(y, x)[1], 1.301439e-11, 1e-4)