def test_t_two_sample_switch(self): """t_two_sample should call t_one_observation if 1 item in sample.""" sample = Numbers([4.02, 3.88, 3.34, 3.87, 3.18]) x = Numbers([3.02]) self.assertFloatEqual(t_two_sample(x, sample), (-1.5637254, 0.1929248)) self.assertFloatEqual(t_two_sample(sample, x), (-1.5637254, 0.1929248)) # can't do the test if both samples have single item self.assertEqual(t_two_sample(x, x), (None, None))
def test_t_two_sample_no_variance(self): """t_two_sample should return None if lists are invariant""" x = Numbers([1, 1, 1]) y = Numbers([0, 0, 0]) self.assertEqual(t_two_sample(x, x), (None, None)) self.assertEqual(t_two_sample(x, y), (None, None))
def test_t_two_sample(self): """t_two_sample should match example on p.225 of Sokal and Rohlf""" I = Numbers([7.2, 7.1, 9.1, 7.2, 7.3, 7.2, 7.5]) II = Numbers([8.8, 7.5, 7.7, 7.6, 7.4, 6.7, 7.2]) self.assertFloatEqual(t_two_sample(I, II), (-0.1184, 0.45385 * 2), 0.001)