Consider three discrete binary random variables -- A, B, C.
I have calculated
I(A;C), but I want to calculate
I'm having trouble implementing this.
From reading this paper I have an idea, but can't get it to work out in python.
I have these functions (python 3)
def entropy(X, Y):
probs = 
for c1 in set(X):
for c2 in set(Y):
probs.append(np.mean(np.logical_and(X == c1, Y == c2)))
return np.sum(-p * np.log2(p) for p in probs if p > 0)
def calc_MI(x, y, bins):
c_xy = np.histogram2d(x, y, bins)
mi = mutual_info_score(None, None, contingency=c_xy)
But I'm not sure how to move forward, thanks in advance.