import math


def entropy(data):
    """
    Compute the Shannon entropy, a measure of uncertainty.
    """

    if len(data) == 0:
        return None

    n = sum(data)

    _op = lambda f: f * math.log(f)
    return - sum(_op(float(i) / n) for i in data)