Esempio n. 1
0
    def test__bootstrap__computation(self):
        """ Result of bootstrap() equals expected result. """
        # Computing bootstrap
        result1 = statx.bootstrap(self.samples.temperature, [0], min_observations=1)
        # Checking if lower percentile of result2 is correct
        self.assertAlmostEqual(result1[0][2.5], 98.1220, 2)
        # Checking if upper percentile of result2 is correct
        self.assertAlmostEqual(result1[0][97.5], 98.3708, 2)
        # Checking if no bootstrap data was passed
        self.assertIsNone(result1[1])

        # Defining data and computing bootstrap
        zero_3 = np.array([0., 0., 0.])
        one_3 = np.array([1., 1., 1.])
        result2 = statx.bootstrap(zero_3, one_3, min_observations=3)
        # Checking if lower percentile of result2 is correct
        self.assertEqual(result2[0][2.5], -1.0)
        # Checking if upper percentile of result2 is correct
        self.assertEqual(result2[0][97.5], -1.0)
        # Checking if no bootstrap data was passed
        self.assertIsNone(result2[1])

        # Defining data and computing bootstrap
        sample1 = self.samples.temperature[self.samples.gender == 1]
        sample2 = self.samples.temperature[self.samples.gender == 2]
        result3 = statx.bootstrap(sample1, sample2)
        # Checking if lower percentile of result3 is correct
        self.assertAlmostEqual(result3[0][2.5], -0.53384615384615619)
        # Checking if upper percentile of result3 is correct
        self.assertAlmostEqual(result3[0][97.5], -0.049192307692299965)
        # Checking if no bootstrap data was passed
        self.assertIsNone(result3[1])
Esempio n. 2
0
    def test__bootstrap__computation(self):
        """ Result of bootstrap() equals expected result. """
        # Computing bootstrap
        result1 = statx.bootstrap(self.samples.temperature, [0],
                                  min_observations=1)
        # Checking if lower percentile of result2 is correct
        self.assertAlmostEqual(result1[0][2.5], 98.1220, 2)
        # Checking if upper percentile of result2 is correct
        self.assertAlmostEqual(result1[0][97.5], 98.3708, 2)
        # Checking if no bootstrap data was passed
        self.assertIsNone(result1[1])

        # Defining data and computing bootstrap
        zero_3 = np.array([0., 0., 0.])
        one_3 = np.array([1., 1., 1.])
        result2 = statx.bootstrap(zero_3, one_3, min_observations=3)
        # Checking if lower percentile of result2 is correct
        self.assertEqual(result2[0][2.5], -1.0)
        # Checking if upper percentile of result2 is correct
        self.assertEqual(result2[0][97.5], -1.0)
        # Checking if no bootstrap data was passed
        self.assertIsNone(result2[1])

        # Defining data and computing bootstrap
        sample1 = self.samples.temperature[self.samples.gender == 1]
        sample2 = self.samples.temperature[self.samples.gender == 2]
        result3 = statx.bootstrap(sample1, sample2)
        # Checking if lower percentile of result3 is correct
        self.assertAlmostEqual(result3[0][2.5], -0.53384615384615619)
        # Checking if upper percentile of result3 is correct
        self.assertAlmostEqual(result3[0][97.5], -0.049192307692299965)
        # Checking if no bootstrap data was passed
        self.assertIsNone(result3[1])