Esempio n. 1
0
def test_pid_dep3():
    """
    Test that idep and ibroja differ on reduced or.
    """
    d = bivariates['reduced or']
    pid1 = PID_BROJA(d)
    pid2 = PID_dep(d)
    assert pid1 != pid2
Esempio n. 2
0
def test_pid_dep4():
    """
    Test that anddup is complete.
    """
    d = trivariates['anddup']
    pid = PID_dep(d)
    assert pid.complete
    assert pid.nonnegative
    assert pid.consistent
Esempio n. 3
0
def test_pid_dep1():
    """
    Test idep on a generic distribution.
    """
    d = bivariates['reduced or']
    pid = PID_dep(d, ((0, ), (1, )), (2, ))
    assert pid[((0, ), (1, ))] == pytest.approx(0.073761301440421256, abs=1e-4)
    assert pid[((0, ), )] == pytest.approx(0.23751682301871169, abs=1e-4)
    assert pid[((1, ), )] == pytest.approx(0.23751682301871169, abs=1e-4)
    assert pid[((0, 1), )] == pytest.approx(0.45120505252215537, abs=1e-4)
Esempio n. 4
0
def test_pid_dep2():
    """
    Test idep on another generic distribution.
    """
    d = trivariates['anddup']
    pid = PID_dep(d, [[0], [1], [2]], [3])
    for atom in pid._lattice:
        if atom == ((0, ), (1, ), (2, )):
            assert pid[atom] == pytest.approx(0.081704409646414788, abs=1e-4)
        elif atom == ((0, 1), (1, 2)):
            assert pid[atom] == pytest.approx(0.27042624480113808, abs=1e-4)
        elif atom in [((0, ), (2, )), ((1, ), )]:
            assert pid[atom] == pytest.approx(0.22957374150893717, abs=1e-4)
        else:
            assert pid[atom] == pytest.approx(0.0, abs=1e-4)
Esempio n. 5
0
print("  ")
print("{0}{1} is Shd, {0} is UnqB, {1} is UnqA, {0:1} is Syn")
print("  ")

rcyBROJA = PID_BROJA(dist1, [[0], [1]], [2])

print("  ")
print(" The I_broja PID is plotted in Fig. 6 ")
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)
Esempio n. 6
0
    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])

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

    # 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]])