本文整理汇总了Python中dit.ScalarDistribution.set_base方法的典型用法代码示例。如果您正苦于以下问题:Python ScalarDistribution.set_base方法的具体用法?Python ScalarDistribution.set_base怎么用?Python ScalarDistribution.set_base使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dit.ScalarDistribution
的用法示例。
在下文中一共展示了ScalarDistribution.set_base方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_init9
# 需要导入模块: from dit import ScalarDistribution [as 别名]
# 或者: from dit.ScalarDistribution import set_base [as 别名]
def test_init9():
outcomes = [0, 1, 2]
pmf = [1 / 3] * 3
d1 = ScalarDistribution(outcomes, pmf)
d2 = ScalarDistribution.from_distribution(d1, base=10)
d1.set_base(10)
assert_true(d1.is_approx_equal(d2))
示例2: test_J8
# 需要导入模块: from dit import ScalarDistribution [as 别名]
# 或者: from dit.ScalarDistribution import set_base [as 别名]
def test_J8():
for i in range(3, 10):
d = SD([1/i]*i)
d.set_base(i)
assert(J(d) < H(d))
示例3: test_p2
# 需要导入模块: from dit import ScalarDistribution [as 别名]
# 或者: from dit.ScalarDistribution import set_base [as 别名]
def test_p2():
for i in range(2, 10):
d = SD([1/i]*i)
d.set_base(i)
assert_almost_equal(P(d), i)
示例4: test_J6
# 需要导入模块: from dit import ScalarDistribution [as 别名]
# 或者: from dit.ScalarDistribution import set_base [as 别名]
def test_J6():
for i in range(2, 10):
d = SD([1/i]*i)
d.set_base(10)
assert_almost_equal(J(d), (i-1)*(np.log10(i)-np.log10(i-1)))
示例5: test_J8
# 需要导入模块: from dit import ScalarDistribution [as 别名]
# 或者: from dit.ScalarDistribution import set_base [as 别名]
def test_J8(i):
""" Test a property of J from result 1 of the paper using log bases """
d = SD([1/i]*i)
d.set_base(i)
assert J(d) < H(d)
示例6: test_p2
# 需要导入模块: from dit import ScalarDistribution [as 别名]
# 或者: from dit.ScalarDistribution import set_base [as 别名]
def test_p2():
""" Test some simple base cases using SD with varying bases """
for i in range(2, 10):
d = SD([1 / i] * i)
d.set_base(i)
yield assert_almost_equal, P(d), i
示例7: test_J5
# 需要导入模块: from dit import ScalarDistribution [as 别名]
# 或者: from dit.ScalarDistribution import set_base [as 别名]
def test_J5(i):
""" Test a property of J from result 2 of the paper with a log base """
d = SD([1/i]*i)
d.set_base('e')
assert J(d) == pytest.approx((i-1)*(np.log(i)-np.log(i-1)))
示例8: test_J6
# 需要导入模块: from dit import ScalarDistribution [as 别名]
# 或者: from dit.ScalarDistribution import set_base [as 别名]
def test_J6(i):
""" Test a property of J from result 2 of the paper with base 10 """
d = SD([1/i]*i)
d.set_base(10)
assert J(d) == pytest.approx((i-1)*(np.log10(i)-np.log10(i-1)))
示例9: test_p2
# 需要导入模块: from dit import ScalarDistribution [as 别名]
# 或者: from dit.ScalarDistribution import set_base [as 别名]
def test_p2(i):
""" Test some simple base cases using SD with varying bases """
d = SD([1/i]*i)
d.set_base(i)
assert P(d) == pytest.approx(i)
示例10: test_J8
# 需要导入模块: from dit import ScalarDistribution [as 别名]
# 或者: from dit.ScalarDistribution import set_base [as 别名]
def test_J8():
""" Test a property of J from result 1 of the paper using log bases """
for i in range(3, 10):
d = SD([1/i]*i)
d.set_base(i)
yield assert_true, J(d) < H(d)
示例11: test_J6
# 需要导入模块: from dit import ScalarDistribution [as 别名]
# 或者: from dit.ScalarDistribution import set_base [as 别名]
def test_J6():
""" Test a property of J from result 2 of the paper with base 10 """
for i in range(2, 10):
d = SD([1/i]*i)
d.set_base(10)
yield assert_almost_equal, J(d), (i-1)*(np.log10(i)-np.log10(i-1))
示例12: test_H4
# 需要导入模块: from dit import ScalarDistribution [as 别名]
# 或者: from dit.ScalarDistribution import set_base [as 别名]
def test_H4():
d = SD([1/10]*10)
d.set_base(10)
assert_almost_equal(H(d), 1.0)
示例13: test_H4
# 需要导入模块: from dit import ScalarDistribution [as 别名]
# 或者: from dit.ScalarDistribution import set_base [as 别名]
def test_H4():
""" Test entropy in base 10 """
d = SD([1/10]*10)
d.set_base(10)
assert_almost_equal(H(d), 1.0)