コード例 #1
0
ファイル: test_testing.py プロジェクト: Autoplectic/dit
def test_distribution_structures6():
    """
    A test for the distribution_structures strategy.
    """
    dists = distribution_structures(size=3, alphabet=2, uniform=True)
    example = find(dists, predicate)
    assert coinformation(example) <= -1/2
コード例 #2
0
def test_ii2(i):
    """ Test II = -1^n * I for giant bit distributions """
    outcomes = ['0'*i, '1'*i]
    pmf = [1/2, 1/2]
    d = D(outcomes, pmf)
    ci = coinformation(d)
    ii = interaction_information(d)
    assert ii == pytest.approx((-1)**i * ci)
コード例 #3
0
def test_ii2():
    """ Test II = -1^n * I for giant bit distributions """
    for i in range(2, 6):
        outcomes = ['0'*i, '1'*i]
        pmf = [1/2, 1/2]
        d = D(outcomes, pmf)
        ci = coinformation(d)
        ii = interaction_information(d)
        yield assert_almost_equal, ii, (-1)**i * ci
コード例 #4
0
ファイル: test_testing.py プロジェクト: vreuter/dit
def test_markov_chains3(dist):
    """
    Test the markov_chains strategy.
    """
    assert coinformation(dist, [[0], [2]], [1]) == pytest.approx(0.0, abs=1e-7)
コード例 #5
0
ファイル: test_testing.py プロジェクト: vreuter/dit
def predicate(d):
    return coinformation(d) <= -1 / 2
コード例 #6
0
ファイル: test_miscellaneous.py プロジェクト: psychon7/dit
def test_gk_pos_i_neg2():
    """
    Test against known values.
    """
    i = coinformation(gk_pos_i_neg)
    assert i == pytest.approx(-0.33143555680040304)
コード例 #7
0
def test_markov_chains1():
    """
    Test the markov_chains strategy.
    """
    dist = markov_chains(alphabets=3).example()
    assert coinformation(dist, [[0], [2]], [1]) == pytest.approx(0.0, abs=1e-7)
コード例 #8
0
ファイル: test_dependencies.py プロジェクト: Autoplectic/dit
def test_stacked2():
    """
    Test against known values.
    """
    i = coinformation(stacked, [[0], [1]], [2])
    assert i == pytest.approx(2/3)
コード例 #9
0
ファイル: test_dependencies.py プロジェクト: Autoplectic/dit
def test_stacked1():
    """
    Test against known values.
    """
    i = coinformation(stacked)
    assert i == pytest.approx(1.5849625007211565)
コード例 #10
0
ファイル: test_dependencies.py プロジェクト: Autoplectic/dit
def test_mixed1():
    """
    Test against known values.
    """
    i = coinformation(mixed)
    assert i == pytest.approx(0.0)
コード例 #11
0
ファイル: test_dependencies.py プロジェクト: psychon7/dit
def test_stacked2():
    """
    Test against known values.
    """
    i = coinformation(stacked, [[0], [1]], [2])
    assert i == pytest.approx(2 / 3)
コード例 #12
0
ファイル: test_dependencies.py プロジェクト: psychon7/dit
def test_stacked1():
    """
    Test against known values.
    """
    i = coinformation(stacked)
    assert i == pytest.approx(1.5849625007211565)
コード例 #13
0
ファイル: test_dependencies.py プロジェクト: psychon7/dit
def test_mixed1():
    """
    Test against known values.
    """
    i = coinformation(mixed)
    assert i == pytest.approx(0.0)
コード例 #14
0
ファイル: test_miscellaneous.py プロジェクト: Autoplectic/dit
def test_gk_pos_i_neg2():
    """
    Test against known values.
    """
    i = coinformation(gk_pos_i_neg)
    assert i == pytest.approx(-0.33143555680040304)
コード例 #15
0
ファイル: test_testing.py プロジェクト: Autoplectic/dit
def test_markov_chains1():
    """
    Test the markov_chains strategy.
    """
    dist = markov_chains(alphabets=3).example()
    assert coinformation(dist, [[0], [2]], [1]) == pytest.approx(0.0, abs=1e-7)
コード例 #16
0
ファイル: test_testing.py プロジェクト: Autoplectic/dit
def predicate(d):
    return coinformation(d) <= -1/2