Ejemplo 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)
Ejemplo n.º 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
Ejemplo 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)
Ejemplo n.º 5
0
def predicate(d):
    return coinformation(d) <= -1 / 2
Ejemplo 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)
Ejemplo 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)
Ejemplo n.º 8
0
def test_stacked2():
    """
    Test against known values.
    """
    i = coinformation(stacked, [[0], [1]], [2])
    assert i == pytest.approx(2/3)
Ejemplo n.º 9
0
def test_stacked1():
    """
    Test against known values.
    """
    i = coinformation(stacked)
    assert i == pytest.approx(1.5849625007211565)
Ejemplo n.º 10
0
def test_mixed1():
    """
    Test against known values.
    """
    i = coinformation(mixed)
    assert i == pytest.approx(0.0)
Ejemplo n.º 11
0
def test_stacked2():
    """
    Test against known values.
    """
    i = coinformation(stacked, [[0], [1]], [2])
    assert i == pytest.approx(2 / 3)
Ejemplo n.º 12
0
def test_stacked1():
    """
    Test against known values.
    """
    i = coinformation(stacked)
    assert i == pytest.approx(1.5849625007211565)
Ejemplo n.º 13
0
def test_mixed1():
    """
    Test against known values.
    """
    i = coinformation(mixed)
    assert i == pytest.approx(0.0)
Ejemplo 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)
Ejemplo 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)
Ejemplo n.º 16
0
def predicate(d):
    return coinformation(d) <= -1/2