Esempio n. 1
0
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
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)
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
Esempio n. 4
0
def test_markov_chains3(dist):
    """
    Test the markov_chains strategy.
    """
    assert coinformation(dist, [[0], [2]], [1]) == pytest.approx(0.0, abs=1e-7)
Esempio n. 5
0
def predicate(d):
    return coinformation(d) <= -1 / 2
Esempio n. 6
0
def test_gk_pos_i_neg2():
    """
    Test against known values.
    """
    i = coinformation(gk_pos_i_neg)
    assert i == pytest.approx(-0.33143555680040304)
Esempio n. 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)
Esempio n. 8
0
def test_stacked2():
    """
    Test against known values.
    """
    i = coinformation(stacked, [[0], [1]], [2])
    assert i == pytest.approx(2/3)
Esempio n. 9
0
def test_stacked1():
    """
    Test against known values.
    """
    i = coinformation(stacked)
    assert i == pytest.approx(1.5849625007211565)
Esempio n. 10
0
def test_mixed1():
    """
    Test against known values.
    """
    i = coinformation(mixed)
    assert i == pytest.approx(0.0)
Esempio n. 11
0
def test_stacked2():
    """
    Test against known values.
    """
    i = coinformation(stacked, [[0], [1]], [2])
    assert i == pytest.approx(2 / 3)
Esempio n. 12
0
def test_stacked1():
    """
    Test against known values.
    """
    i = coinformation(stacked)
    assert i == pytest.approx(1.5849625007211565)
Esempio n. 13
0
def test_mixed1():
    """
    Test against known values.
    """
    i = coinformation(mixed)
    assert i == pytest.approx(0.0)
Esempio n. 14
0
def test_gk_pos_i_neg2():
    """
    Test against known values.
    """
    i = coinformation(gk_pos_i_neg)
    assert i == pytest.approx(-0.33143555680040304)
Esempio n. 15
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)
Esempio n. 16
0
def predicate(d):
    return coinformation(d) <= -1/2