當前位置: 首頁>>代碼示例>>Python>>正文


Python ScalarDistribution.from_distribution方法代碼示例

本文整理匯總了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))
開發者ID:gto00002,項目名稱:dit,代碼行數:9,代碼來源:test_npscalardist.py

示例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))
開發者ID:gto00002,項目名稱:dit,代碼行數:9,代碼來源:test_npscalardist.py

示例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))
開發者ID:manolomartinez,項目名稱:dit,代碼行數:10,代碼來源:test_npscalardist.py

示例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
開發者ID:Autoplectic,項目名稱:dit,代碼行數:19,代碼來源:test_inequalities.py

示例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))
開發者ID:gto00002,項目名稱:dit,代碼行數:8,代碼來源:test_npscalardist.py


注:本文中的dit.ScalarDistribution.from_distribution方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。