Example #1
0
def test_pid_broja3():
    """
    Test that iproj and ibroja are the same on reduced or.
    """
    d = bivariates['reduced or']
    pid1 = PID_BROJA(d)
    pid2 = PID_Proj(d)
    assert pid1 == pid2
Example #2
0
def test_pid_proj1():
    """
    Test iproj on a generic distribution.
    """
    d = bivariates['diff']
    pid = PID_Proj(d, ((0,), (1,)), (2,))
    assert pid[((0,), (1,))] == pytest.approx(0.16503749927884365)
    assert pid[((0,),)] == pytest.approx(0.1462406251802893)
    assert pid[((1,),)] == pytest.approx(0.1462406251802893)
    assert pid[((0, 1),)] == pytest.approx(0.04248125036057776)
Example #3
0
def test_pid_proj3():
    """
    Test iproj on another generic distribution.
    """
    d = trivariates['xor shared']
    pid = PID_Proj(d)
    for atom in pid._lattice:
        if atom == ((0,), (1, 2)):
            assert pid[atom] == pytest.approx(1.0)
        else:
            assert pid[atom] == pytest.approx(0.0)
Example #4
0
def test_pid_proj2():
    """
    Test iproj on another generic distribution.
    """
    d = trivariates['anddup']
    pid = PID_Proj(d, [[0], [1], [2]], [3])
    assert pid[((0, 1), (1, 2))] == pytest.approx(0.5)
    assert pid[((0,), (1,), (2,))] == pytest.approx(0.31127812445913305)
    for atom in pid._lattice:
        if atom not in [((0, 1), (1, 2)), ((0,), (1,), (2,))]:
            assert pid[atom] == pytest.approx(0.0)
Example #5
0
print(rcyBROJA)
print("  ")

rcyCCS = PID_CCS(dist1, [[0], [1]], [2])

print(rcyCCS)

rcyDEP = PID_dep(dist1, [[0], [1]], [2])

print(rcyDEP)

rcyWB = PID_WB(dist1, [[0], [1]], [2])

print(rcyWB)

rcyPROJ = PID_Proj(dist1, [[0], [1]], [2])

print(rcyPROJ)
print("  ")

# Computation of the entropies

H_OBA = entropy(dist1)
H_B = entropy(dist1, [0])
H_A = entropy(dist1, [1])
H_O = entropy(dist1, [2])

H_OB = entropy(dist1, [[0], [2]])
H_OA = entropy(dist1, [[1], [2]])
H_BA = entropy(dist1, [[0], [1]])
Example #6
0
    p = PID_BROJA(dist1, [[0], [1]], [2])

    output[i, 0:4] = [
        p.get_partial(n)
        for n in sorted(p._lattice, key=dit.pid.lattice.sort_key(p._lattice))
    ]

    p = PID_WB(dist1, [[0], [1]], [2])

    output[i, 4:8] = [
        p.get_partial(n)
        for n in sorted(p._lattice, key=dit.pid.lattice.sort_key(p._lattice))
    ]

    p = PID_Proj(dist1, [[0], [1]], [2])

    output[i, 8:12] = [
        p.get_partial(n)
        for n in sorted(p._lattice, key=dit.pid.lattice.sort_key(p._lattice))
    ]

    p = PID_CCS(dist1, [[0], [1]], [2])

    output[i, 12:16] = [
        p.get_partial(n)
        for n in sorted(p._lattice, key=dit.pid.lattice.sort_key(p._lattice))
    ]

    p = PID_dep(dist1, [[0], [1]], [2])