import math def entropy(A, B): return - (A * math.log2(A) + B * math.log2(B))