本文整理汇总了Python中dit.ScalarDistribution.is_approx_equal方法的典型用法代码示例。如果您正苦于以下问题:Python ScalarDistribution.is_approx_equal方法的具体用法?Python ScalarDistribution.is_approx_equal怎么用?Python ScalarDistribution.is_approx_equal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dit.ScalarDistribution
的用法示例。
在下文中一共展示了ScalarDistribution.is_approx_equal方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_init9
# 需要导入模块: from dit import ScalarDistribution [as 别名]
# 或者: from dit.ScalarDistribution import is_approx_equal [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_mss
# 需要导入模块: from dit import ScalarDistribution [as 别名]
# 或者: from dit.ScalarDistribution import is_approx_equal [as 别名]
def test_mss():
"""
Test the construction of minimal sufficient statistics.
"""
d = get_gm()
d1 = mss(d, [0, 1], [2, 3])
d2 = mss(d, [2, 3], [0, 1])
dist = ScalarDistribution([0, 1], [1 / 3, 2 / 3])
assert_true(dist.is_approx_equal(d1))
assert_true(dist.is_approx_equal(d2))
assert_true(d1.is_approx_equal(d2))
示例3: test_add_mul
# 需要导入模块: from dit import ScalarDistribution [as 别名]
# 或者: from dit.ScalarDistribution import is_approx_equal [as 别名]
def test_add_mul():
d1 = ScalarDistribution([1 / 3, 2 / 3])
d2 = ScalarDistribution([2 / 3, 1 / 3])
d3 = ScalarDistribution([1 / 2, 1 / 2])
d4 = 0.5 * (d1 + d2)
assert_true(d3.is_approx_equal(d4))
示例4: test_init8
# 需要导入模块: from dit import ScalarDistribution [as 别名]
# 或者: from dit.ScalarDistribution import is_approx_equal [as 别名]
def test_init8():
outcomes = [0, 1, 2]
pmf = [1 / 3] * 3
d1 = ScalarDistribution(outcomes, pmf)
d2 = ScalarDistribution.from_distribution(d1)
assert_true(d1.is_approx_equal(d2))
示例5: test_is_approx_equal3
# 需要导入模块: from dit import ScalarDistribution [as 别名]
# 或者: from dit.ScalarDistribution import is_approx_equal [as 别名]
def test_is_approx_equal3():
d1 = ScalarDistribution([1 / 2, 1 / 2], sample_space=(0, 1, 2))
d2 = ScalarDistribution([1 / 2, 1 / 2])
assert_false(d1.is_approx_equal(d2))
示例6: test_is_approx_equal2
# 需要导入模块: from dit import ScalarDistribution [as 别名]
# 或者: from dit.ScalarDistribution import is_approx_equal [as 别名]
def test_is_approx_equal2():
d1 = ScalarDistribution([1 / 2, 1 / 2, 0])
d1.make_dense()
d2 = ScalarDistribution([1 / 2, 0, 1 / 2])
d2.make_dense()
assert_false(d1.is_approx_equal(d2))