Exemplo n.º 1
0
def test(alpha=0.382, beta=0.77):
    """Test of entropy rate function for two-state Markov chain."""
    d = {(0,0): 1.-alpha, (0,1): alpha, (1,0):beta, (1,1):1.-beta}
    s = [beta / (alpha + beta), alpha / (alpha + beta)]
    e = approximate_entropy_rate(d, s)
    print d
    print s
    print e
    print ( beta * binary_entropy(alpha) + alpha * binary_entropy(beta) ) / (alpha + beta)
Exemplo n.º 2
0
def test(alpha=0.382, beta=0.77):
    """Test of entropy rate function for two-state Markov chain."""
    d = {(0, 0): 1. - alpha, (0, 1): alpha, (1, 0): beta, (1, 1): 1. - beta}
    s = [beta / (alpha + beta), alpha / (alpha + beta)]
    e = approximate_entropy_rate(d, s)
    print d
    print s
    print e
    print(beta * binary_entropy(alpha) +
          alpha * binary_entropy(beta)) / (alpha + beta)
Exemplo n.º 3
0
def static_plot(Ns, m, incentive_func=None, eta=None, w=None, mutation_func=None, mu_ab=0.001, mu_ba=0.001, test_func=None):
    """Plot entropy rate over a range of population sizes."""
    params = [Ns]
    for p in [m, incentive_func, eta, w, mutation_func, mu_ab, mu_ba, test_func]:
        params.append(constant_generator(p))
    es = run_batches(params)
    #k = 0.5 + 0.5* math.log(math.pi / 2)    
    #print mu_ab, (es[-1][-1] - k) / (0.5 * math.log(Ns[-1]))
    #pyplot.plot(Ns, [(es[i][-1] -k)/(0.5 * math.log(Ns[i])) for i in range(len(es))])
    #print mu_ab, (es[-1][-1] - k) / (0.5 * math.log(Ns[-1]))
    print mu_ab, es[-1][-1] - binary_entropy(mu_ab)
    pyplot.plot(Ns, [es[i][-1] - binary_entropy(mu_ab) for i in range(len(es))])
    return es
Exemplo n.º 4
0
def static_plot(Ns,
                m,
                incentive_func=None,
                eta=None,
                w=None,
                mutation_func=None,
                mu_ab=0.001,
                mu_ba=0.001,
                test_func=None):
    """Plot entropy rate over a range of population sizes."""
    params = [Ns]
    for p in [
            m, incentive_func, eta, w, mutation_func, mu_ab, mu_ba, test_func
    ]:
        params.append(constant_generator(p))
    es = run_batches(params)
    #k = 0.5 + 0.5* math.log(math.pi / 2)
    #print mu_ab, (es[-1][-1] - k) / (0.5 * math.log(Ns[-1]))
    #pyplot.plot(Ns, [(es[i][-1] -k)/(0.5 * math.log(Ns[i])) for i in range(len(es))])
    #print mu_ab, (es[-1][-1] - k) / (0.5 * math.log(Ns[-1]))
    print mu_ab, es[-1][-1] - binary_entropy(mu_ab)
    pyplot.plot(Ns,
                [es[i][-1] - binary_entropy(mu_ab) for i in range(len(es))])
    return es