本文整理匯總了Python中dit.ScalarDistribution.from_distribution方法的典型用法代碼示例。如果您正苦於以下問題:Python ScalarDistribution.from_distribution方法的具體用法?Python ScalarDistribution.from_distribution怎麽用?Python ScalarDistribution.from_distribution使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類dit.ScalarDistribution
的用法示例。
在下文中一共展示了ScalarDistribution.from_distribution方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_init11
# 需要導入模塊: from dit import ScalarDistribution [as 別名]
# 或者: from dit.ScalarDistribution import from_distribution [as 別名]
def test_init11():
outcomes = ["0", "1"]
pmf = [1 / 2, 1 / 2]
d = Distribution(outcomes, pmf)
sd = ScalarDistribution.from_distribution(d)
# Different sample space representations
assert_false(d.is_approx_equal(sd))
示例2: test_init9
# 需要導入模塊: from dit import ScalarDistribution [as 別名]
# 或者: from dit.ScalarDistribution import from_distribution [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))
示例3: test_init12
# 需要導入模塊: from dit import ScalarDistribution [as 別名]
# 或者: from dit.ScalarDistribution import from_distribution [as 別名]
def test_init12():
outcomes = ['0', '1']
pmf = [1/2, 1/2]
d = Distribution(outcomes, pmf)
sd = ScalarDistribution.from_distribution(d, base=10)
d.set_base(10)
# Different sample space representations
assert_false(d.is_approx_equal(sd))
示例4: test_fanos_inequality
# 需要導入模塊: from dit import ScalarDistribution [as 別名]
# 或者: from dit.ScalarDistribution import from_distribution [as 別名]
def test_fanos_inequality(dist):
"""
H(X|Y) <= hb(P_e) + P_e log(|X| - 1)
"""
dist1 = SD.from_distribution(dist.marginal([0]))
dist2 = SD.from_distribution(dist.marginal([1]))
ce = H(dist, [0], [1])
X = len(set().union(dist1.outcomes, dist2.outcomes))
eq_dist = dist1 == dist2
P_e = eq_dist[False] if False in eq_dist else 0
hb = H(SD([P_e, 1-P_e]))
assert ce <= hb + P_e * np.log2(X - 1) + epsilon
示例5: test_init8
# 需要導入模塊: from dit import ScalarDistribution [as 別名]
# 或者: from dit.ScalarDistribution import from_distribution [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))