Пример #1
0
 def testVariance_ShortList_UsesPopulationVariance(self):
   self.assertAlmostEqual(6.25, sum([12.25, 0.25, 0.25, 12.25]) / 4.0)
   self.assertAlmostEqual(6.25, math_utils.Variance([-3, 0, 1, 4]))
Пример #2
0
 def testVariance_EmptyList_ReturnsNan(self):
   self.assertTrue(math.isnan(math_utils.Variance([])))
Пример #3
0
 def testVariance_OneValue_ReturnsZero(self):
   self.assertEqual(0.0, math_utils.Variance([0]))
   self.assertEqual(0.0, math_utils.Variance([4.3]))
Пример #4
0
def _MakeSampleStats(sample):
    """Calculates relevant stats for a sample and makes a SampleStats object."""
    return SampleStats(math_utils.Mean(sample), math_utils.Variance(sample),
                       len(sample))