import math


def compute_entropy(values):
    """
    Given values for a random variable, calculate its entropy.
    :param values: RV
    :return: entropy of random variable with values outcome
    """
    counts = {}
    for val in values:
        try:
            counts[val] += 1
        except KeyError:
            counts[val] = 1
    entropy = 0
    for key, value in counts.items():
        prob = counts[key] / len(values)
        entropy += -1 * prob * math.log(prob, 2)
    return entropy