import math


def ent(x):
    """ Entropy [bits] given a vector of log probabilities """
    x     = [ math.exp(-val) for val in x ]
    logs  = [ math.log(val, 2) for val in x ]
    prods = [ a * b for a,b in zip(x, logs) ]
    return - sum(prods)