Exemplo n.º 1
0
def simulate_day(pvec, priors):
    
    priors = priors.copy()
    n = pvec.size
    datasize = 100
    
    for k in xrange(0, 2):
        data = bs.sim_data(priors, datasize)
        prob = bs.prob_opt(data)
        weights = bs.get_weights(prob, 50)
        for i in xrange(0, n):
            for j in xrange(0, int(weights[i])):
                result = pull(pvec[i])
                if result == 0:
                    priors[i,1] += 1
                else:
                    priors[i,0] += 1
                    
    return priors,weights
Exemplo n.º 2
0
def simulate_convergence(pvec):
    n = pvec.size
    priors = sp.ones((n,2))
    datasize = 100
    
    delta = 0
    p_tol = .95
    champ_cvr = 0
    pvr = 1
    days = 0
    
    weights = []
    while ((delta < p_tol) and (champ_cvr/100. < pvr)) or days < 14:
        days += 1
        priors, weights1 = simulate_day(pvec, priors)
        weights.append(weights1)
        data = bs.sim_data(priors, datasize)
        prob = bs.prob_opt(data)
        delta = prob.max()
        valrem_dist, pvr = val_remaining(data, prob)
        champ_ind = sp.argmax(prob)
        champ_cvr = priors[champ_ind,0]/float(priors[champ_ind,0] + priors[champ_ind,1])            

    return priors,weights,champ_ind,days