Skip to content

Instantly share code, notes, and snippets.

@vlavorini
Last active December 22, 2019 14:03
Show Gist options
  • Save vlavorini/4825d263544b86bf9d695af001e0838e to your computer and use it in GitHub Desktop.
Save vlavorini/4825d263544b86bf9d695af001e0838e to your computer and use it in GitHub Desktop.
from scipy.stats import beta
import numpy as np
from calc_prob import calc_prob_between
#This is the known data: imporessions and conversions for the Control and Test set
imps_ctrl,convs_ctrl=16500, 30
imps_test, convs_test=17000, 50
#here we create the Beta functions for the two sets
a_C, b_C = convs_ctrl+1, imps_ctrl-convs_ctrl+1
beta_C = beta(a_C, b_C)
a_T, b_T = convs_test+1, imps_test-convs_test+1
beta_T = beta(a_T, b_T)
#calculating the lift
lift=(beta_T.mean()-beta_C.mean())/beta_C.mean()
#calculating the probability for Test to be better than Control
prob=calc_prob_between(beta_T, beta_C)
print (f"Test option lift Conversion Rates by {lift*100:2.2f}% with {prob*100:2.1f}% probability.")
#output: Test option lift Conversion Rates by 59.68% with 98.2% probability.
@vlavorini
Copy link
Author

yes: null is Java, in Python you can use None

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment