-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathab_test.py
22 lines (16 loc) · 962 Bytes
/
ab_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from numpy.random import beta as beta_dist
import numpy
def get_samples(success, population, alpha, beta, sample_size):
return beta_dist(success+alpha, population-success+beta, sample_size)
def probability_relative_effect(
a_population, a_success, b_population, b_success,
alpha, beta, sample_size, relative_effect_size):
a_samples = get_samples(a_success, a_population, alpha, beta, sample_size)
b_samples = get_samples(b_success, b_population, alpha, beta, sample_size)
return numpy.mean((a_samples - b_samples)/b_samples > relative_effect_size)
def probability_absolute_effect(
a_population, a_success, b_population, b_success,
alpha, beta, sample_size, absolute_effect_size):
a_samples = get_samples(a_success, a_population, alpha, beta, sample_size)
b_samples = get_samples(b_success, b_population, alpha, beta, sample_size)
return numpy.mean((a_samples - b_samples) > absolute_effect_size)