Exemplo n.º 1
0
def hit_conf(conf,p, lift, interval, consecutives = 1, max_run = float('inf')):

    A = Banner(p+(p*lift), BernouliEstimator(alpha = 1, beta = 1))
    B = Banner(p, BernouliEstimator(alpha = 1, beta = 1))
    time = 0
    hit_better = 0
    hit_worse = 0
    

    while(hit_better < consecutives and hit_worse < consecutives):
        time+=interval
        A.run(interval)
        B.run(interval)

        dist_a = A.estimator.get_distribution()
        dist_b = B.estimator.get_distribution()
        lift_dist = (dist_a - dist_b)/dist_b

        if np.mean(lift_dist > 0) > conf:
            hit_better += 1
        else:
            hit_better = 0

        if np.mean(lift_dist < 0) > conf:
            hit_worse += 1
        else:
            hit_worse = 0

        if max_run < time:
            break

    if hit_better < consecutives:
        return 0.0, time
    else:
        return 1.0, time
Exemplo n.º 2
0
def estimate_baseline(p, conf, min_effect,  alpha = 1, beta = 1):
    interval = round((1/p) * 10)
    time = interval
    A = Banner(p, BernouliEstimator(alpha = 1, beta =1))
    A.run(interval)
    dist = A.estimator.get_distribution()
    m = np.mean(dist)
    l = np.percentile(dist, 100*min_effect)

    while(m-l > min_effect*l):
        time += interval
        A.run(interval)
        dist = A.estimator.get_distribution()
        m = np.mean(dist)
        l = np.percentile(dist, 100*min_effect)

    return time, m, l