def test_uniform_bad_type(self): """ Test unknown type error in uniform distribution. """ with self.assertRaises(UnknownType): dist = UniformDistribution(10, 12, 'bob') with self.assertRaises(UnknownType): dist = UniformDistribution(1, 21.2)
def test_uniform_float(self): """ Weak test of uniform float distributions. """ dist = UniformDistribution(1.0, 10.0) self.assertEqual(dist.dtype, 'float') for idx in xrange(100000): self.assertGreaterEqual(dist.next(), 1.0) self.assertLessEqual(dist.next(), 10.0)
def test_uniform_type_detection(self): """ Test type detection of uniform distribution. """ self.assertEqual(UniformDistribution(1, 5).dtype, 'int') self.assertEqual(UniformDistribution(1.2, 5.8).dtype, 'float') with self.assertRaises(UnknownType): dist = UniformDistribution("bob", 2)
def test_uniform_float(self): """ Weak test of uniform float distributions. """ dist = UniformDistribution(1.0, 10.0) self.assertEqual(dist.dtype, 'float') for idx in xrange(100000): self.assertGreaterEqual(dist.next(), 1.0) self.assertLessEqual(dist.next(), 10.0)
def test_uniform_stddev(self): """ Test the standard deviation computation for a uniform distribution """ cases = ( ((1, 5), 1.1547), ((1.2, 5.8), 1.3279), ) for args, stddev in cases: dist = UniformDistribution(*args) self.assertAlmostEqual(dist.get_stddev(), stddev, places=4)
def test_uniform_variance(self): """ Test the variance computation for a uniform distribution """ cases = ( ((1, 5), 1.33333), ((1.2, 5.8), 1.76333), ) for args, variance in cases: dist = UniformDistribution(*args) self.assertAlmostEqual(dist.get_variance(), variance, places=4)
def test_uniform_mean(self): """ Test the mean computation for a uniform distribution """ cases = ( ((1, 5), 3.0), ((1.2, 5.8), 3.5), ) for args, mean in cases: dist = UniformDistribution(*args) self.assertAlmostEqual(dist.get_mean(), mean)
def test_uniform_stddev(self): """ Test the standard deviation computation for a uniform distribution """ cases = ( ((1, 5), 1.1547), ((1.2, 5.8), 1.3279), ) for args, stddev in cases: dist = UniformDistribution(*args) self.assertAlmostEqual(dist.get_stddev(), stddev, places=4)
def test_uniform_variance(self): """ Test the variance computation for a uniform distribution """ cases = ( ((1, 5), 1.33333), ((1.2, 5.8), 1.76333), ) for args, variance in cases: dist = UniformDistribution(*args) self.assertAlmostEqual(dist.get_variance(), variance, places=4)
def test_uniform_mean(self): """ Test the mean computation for a uniform distribution """ cases = ( ((1, 5), 3.0), ((1.2, 5.8), 3.5), ) for args, mean in cases: dist = UniformDistribution(*args) self.assertAlmostEqual(dist.get_mean(), mean)