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
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
def test_pid_broja4(): """ Test that xor cat is incomplete, but nonnegative and consistent. """ d = trivariates['xor cat'] pid = PID_BROJA(d) assert not pid.complete assert pid.nonnegative assert pid.consistent
def test_pid_broja1(): """ Test ibroja on a generic distribution. """ d = bivariates['diff'] pid = PID_BROJA(d, ((0, ), (1, )), (2, )) assert pid[((0, ), (1, ))] == pytest.approx(0.12255624891826589, abs=1e-4) assert pid[((0, ), )] == pytest.approx(0.18872187554086706, abs=1e-4) assert pid[((1, ), )] == pytest.approx(0.18872187554086706, abs=1e-4) assert pid[((0, 1), )] == pytest.approx(0.0, abs=1e-4)
def test_pid_broja2(): """ Test ibroja on another generic distribution. """ d = trivariates['anddup'] pid = PID_BROJA(d, [[0], [1], [2]], [3]) for atom in pid._lattice: if atom == ((0, ), (1, ), (2, )): assert pid[atom] == pytest.approx(0.31127812445913305, abs=1e-4) elif atom == ((0, 1), (1, 2)): assert pid[atom] == pytest.approx(0.5, abs=1e-4) else: assert pid[atom] == pytest.approx(0.0, abs=1e-4)
dist1 = Distribution(outcomes, pmf) print(" ") print("Probability distribution") print(" ") print(dist1) print(" ") # Compute five PIDs and print the output print("Partial Information Decompositions") 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])
output = np.zeros((16, 26)) for i in range(16): print(i) freq = mat[i, ] aa = freq / np.sum(freq) dat = np.reshape(aa, (4, 4, 3)) dist1 = Distribution.from_ndarray(dat) 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])