Ejemplo n.º 1
0
def dda_expected_entropy(qs):
    """return d/da[E[H|a*qs]], a function of alpha"""
    # Agrees with test_diff!
    sum_qs = float(sum(qs))
    h_inf = h(normalize(qs), units='nats')
    h_0 = 0  #expected_entropy_from_alphas([0 for q in qs])
    Z = h_inf  #*log(2) # in nats
    return lambda alpha: ((sum_qs * polygamma(1, alpha * sum_qs + 1) - sum(
        qj**2 / sum_qs * polygamma(1, alpha * qj + 1) for qj in qs)) / (Z))
Ejemplo n.º 2
0
def dda_expected_entropy(qs):
    """return d/da[E[H|a*qs]], a function of alpha"""
    # Agrees with test_diff!
    sum_qs = float(sum(qs))
    h_inf = h(normalize(qs),units='nats')
    h_0 = 0 #expected_entropy_from_alphas([0 for q in qs])
    Z = h_inf#*log(2) # in nats
    return lambda alpha: ((sum_qs*polygamma(1,alpha*sum_qs+1) -
                           sum(qj**2/sum_qs*polygamma(1,alpha*qj+1) for qj in qs))/
                          (Z))
Ejemplo n.º 3
0
def h_mle(xs,units='bits'):
    """Compute MLE estimator of entropy"""
    p_hats = frequencies(xs)
    return h(p_hats,units=units)