def entropy_term(x): """Helper function for entropy_single: calculates one term in the sum.""" if x==0: return 0.0 else: return -x*math.log2(x)