Exemplo n.º 1
0
def compute_entropy(probs, quantizer):
    dist = 0.0
    modeled_sum = sum([math.exp(quantizer.representer(math.log(prob))) for prob in probs])
    for prob in probs:
        prob_q = math.exp(quantizer.representer(math.log(prob)))
        if prob_q == 0.0:
            prob_q = Automaton.eps
        prob_q /= modeled_sum
        dist += Automaton.kullback(prob, prob_q)
        #print prob, prob_q, Automaton.kullback(prob, prob_q)
    return dist