예제 #1
0
 def test_normal(self):
     """
     Weak test of normal distributions.
     """
     standard = NormalDistribution(0, 1)
     for idx in xrange(100000):
         event = standard.next()
         self.assertGreater(event, -5)
         self.assertLess(event, 5)
예제 #2
0
 def test_normal(self):
     """
     Weak test of normal distributions.
     """
     standard = NormalDistribution(0, 1)
     for idx in xrange(100000):
         event = standard.next()
         self.assertGreater(event, -5)
         self.assertLess(event, 5)
예제 #3
0
    def test_normal_mean(self):
        """
        Assert that the mean approximates the distribution.
        """
        dist = NormalDistribution(0, 1)
        samples = 1000000
        total = sum(dist.next() for idx in xrange(samples))
        mean = total / samples

        self.assertAlmostEqual(mean, 0.0, places=2)
예제 #4
0
    def test_normal_mean(self):
        """
        Assert that the mean approximates the distribution.
        """
        dist    = NormalDistribution(0, 1)
        samples = 1000000
        total   = sum(dist.next() for idx in xrange(samples))
        mean    = total / samples

        self.assertAlmostEqual(mean, 0.0, places=2)