Пример #1
0
 def test_shannon(self):
     """shannon should match hand-calculated values"""
     c = array([5])
     self.assertFloatEqual(shannon(c), 0)
     c = array([5,5])
     self.assertFloatEqual(shannon(c), 1)
     c = array([1,1,1,1,0])
     self.assertEqual(shannon(c), 2)
Пример #2
0
 def test_shannon(self):
     """shannon should match hand-calculated values"""
     c = array([5])
     self.assertFloatEqual(shannon(c), 0)
     c = array([5,5])
     self.assertFloatEqual(shannon(c), 1)
     c = array([1,1,1,1,0])
     self.assertEqual(shannon(c), 2)
Пример #3
0
 def test_heip_e(self):
     """heip e should match hand-calculated value"""
     c = array([1,2,3,1])
     h = shannon(c, base=e)
     expected = exp(h-1)/3
     self.assertEqual(heip_e(c), expected)
Пример #4
0
 def test_heip_e(self):
     """heip e should match hand-calculated value"""
     c = array([1,2,3,1])
     h = shannon(c, base=e)
     expected = exp(h-1)/3
     self.assertEqual(heip_e(c), expected)