-
Notifications
You must be signed in to change notification settings - Fork 1
/
cli.py
50 lines (39 loc) · 1.74 KB
/
cli.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
""" Calculates Bayesian Probabilty that A - B > x
Usage:
ab_test.py <a_population> <a_success> <b_population> <b_success>
[--sample_size=<n>] [--absolute_effect_size=<x> | --relative_effect_size=<x>]
[--alpha=<a>] [--beta=<b>]
Options:
--sample_size=<n> Select a sample size [default: 10000]
--absolute_effect_size=<x> Select the absolute size of effect to be detected [default: 0.0]
--relative_effect_size=<x> Select the relative size of effect to be detected
--alpha=<a> Select an alpha [default: 1.0]
--beta=<b> Select a beta [default: 1.0]
"""
from __future__ import print_function
from docopt import docopt
from ab_test import probability_relative_effect, probability_absolute_effect
def main():
arguements = docopt(__doc__)
a_population = int(arguements['<a_population>'])
b_population = int(arguements['<b_population>'])
a_success = int(arguements['<a_success>'])
b_success = int(arguements['<b_success>'])
sample_size = int(arguements['--sample_size'])
absolute_effect_size = float(arguements['--absolute_effect_size'])
if arguements['--relative_effect_size']:
relative_effect_size = float(arguements['--relative_effect_size'])
else:
relative_effect_size = None
alpha = float(arguements['--alpha'])
beta = float(arguements['--beta'])
if relative_effect_size:
print(probability_relative_effect(
a_population, a_success, b_population, b_success,
alpha, beta, sample_size, relative_effect_size))
else:
print(probability_absolute_effect(
a_population, a_success, b_population, b_success,
alpha, beta, sample_size, absolute_effect_size))
if __name__ == "__main__":
main()