Skip to content
DeepForgeby svx
All problems
MediumInformation Theoryinfo-077

Interaction Information Sign

Problem

From a 3D joint distribution joint[x][y][z], return the sign of the interaction information using the entropy expansion

II = H(X) + H(Y) + H(Z) - H(X,Y) - H(X,Z) - H(Y,Z) + H(X,Y,Z)

Return 1 if II > 1e-9, -1 if II < -1e-9, and 0 otherwise. All entropies are in bits.

Hint

The XOR distribution is the classic case of negative interaction information.

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.25,0],[0,0.25]],[[0,0.25],[0.25,0]]]]
expected: -1
case 3
in: [[[[0.5,0],[0,0]],[[0,0],[0,0.5]]]]
expected: 1
case 4
in: [[[[0.25,0.25],[0,0]],[[0,0],[0.25,0.25]]]]
expected: 0
Starter codePython
import math
def interaction_information_sign(joint):
    # Your code here
    pass

4 test cases · run your code against them in the editor