In [3]:
import pandas as pd
import scipy as sp
import daft

import matplotlib.pyplot as plt
import numpy as np

from abtools import ABtest, BernoulliModel

%matplotlib inline

In [4]:
p = .05
size = 200000
delta_true = .025

a = sp.stats.bernoulli.rvs(p=p, size=size, random_state=8228)
b = sp.stats.bernoulli.rvs(p=p*(1+delta_true), size=size, random_state=8228)

print('A - Mean: %.4f, std: %.2f' % (a.mean(), a.std()))
print('B - Mean: %.4f, std: %.2f' % (b.mean(), b.std()))
print('B better A on %.4f = %.4f%%' % (b.mean()- a.mean(), (b.mean()/a.mean()-1)*100))


A - Mean: 0.0502, std: 0.22
B - Mean: 0.0513, std: 0.22
B better A on 0.0011 = 2.2917%

In [5]:
test = ABtest([a, b], BernoulliModel, 5000)

test.test_all()


ABtest for 2 groups
Out[5]:
<abtools.core.abtest.ABtest at 0x7fd5aa8cec50>

In [6]:
test.probabilities_df


Out[6]:
group1 group2 mean
group1 - 0.9482 0.0501806423946
group2 0.0518 - 0.0513310018794
mean 0.0501806423946 0.0513310018794 -

In [7]:
test.plot()



In [ ]: