Premium problem131. Mutual Information

Medium Locked

joint[i][j] is P(X=i,Y=j)P(X=i, Y=j). Return the mutual information between X and Y, in bits.

I(X;Y)=∑i,jpijlog⁡2pijpi pjI(X;Y) = \sum_{i,j} p_{ij}\log_2\frac{p_{ij}}{p_i\,p_j}

Recover the marginals by summing the rows and columns. The result is 0 exactly when X and Y are independent, and it measures how much knowing one tells you about the other.

Input

[[0.25, 0.25], [0.25, 0.25]]

Output

np.float64(0.0)

Premium problem

This one's part of Premium. Unlock the full Probability track plus every other premium problem on the site.

Implement solve(...)