import math


def entropy(class_probabilities):
    """given a list of probabilities, compute the entropy"""
    return sum(-p * math.log(p, 2)
               for p in class_probabilities
               if p)