All problems
Dual Total Correlation
Problem
Compute the dual total correlation in bits of a 3D joint distribution joint[x][y][z]:
DTC = H(X,Y) + H(X,Z) + H(Y,Z) - 2 * H(X,Y,Z)
Equivalently, H(X,Y,Z) minus the sum of H(X|YZ) + H(Y|XZ) + H(Z|XY).
Hint
Dual total correlation equals total correlation for three variables only in special cases.
Test cases
case 1
in: [[[[0.125,0.125],[0.125,0.125]],[[0.125,0.125],[0.125,0.125]]]]
expected: 0
case 2
in: [[[[0.5,0],[0,0]],[[0,0],[0,0.5]]]]
expected: 1
case 3
in: [[[[0.25,0.25],[0,0]],[[0,0],[0.25,0.25]]]]
expected: 1
case 4
in: [[[[0.2,0.1],[0.05,0.05]],[[0.05,0.05],[0.1,0.2]]]]
expected: 0.43365938015714
Starter codePython
import math
def dual_total_correlation(joint):
# Your code here
pass4 test cases · run your code against them in the editor