コード例 #1
0
 def test_fractions(self):
     # Test sample variance with Fraction data.
     data = [Fraction(1, 4), Fraction(1, 4), Fraction(3, 4), Fraction(7, 4)]
     expected = 0.7071067811865476
     assert statistics.stdev(data) == expected
     assert Math.std(data) == expected
     assert statistics.stdev(data) == Math.std(data)
コード例 #2
0
 def test_ints(self):
     # Test sample variance with int data.
     data = [4, 7, 13, 16]
     exact = math.sqrt(30)
     assert statistics.stdev(data) == exact
     assert Math.std(data) == exact
     assert statistics.stdev(data) == Math.std(data)
コード例 #3
0
 def test_decimals(self):
     # Test sample variance with Decimal data.
     data = [Decimal(2), Decimal(2), Decimal(7), Decimal(9)]
     exact = (4 * Decimal('9.5') / Decimal(3)).sqrt()
     assert statistics.stdev(data) == exact
     assert Math.std(data) == exact
     assert statistics.stdev(data) == Math.std(data)
     assert isinstance(statistics.stdev(data), Decimal)