Skip to content

Instantly share code, notes, and snippets.

Created October 6, 2012 21:47
Show Gist options
  • Save anonymous/3846278 to your computer and use it in GitHub Desktop.
Save anonymous/3846278 to your computer and use it in GitHub Desktop.
import random
BASELINE_CONVERSION_RATE = 0.05
NUM_EMAILS = 4
NUM_PEOPLE_PER_EMAIL = 125
def did_convert():
return random.random() < BASELINE_CONVERSION_RATE
def avg(vals):
return sum(vals) / float(len(vals))
max_by_min_conversion_increases = []
max_conversions = []
min_conversions = []
for i in range(10000):
vals = []
for j in range(NUM_EMAILS):
vals.append(avg([did_convert() for _ in range(NUM_PEOPLE_PER_EMAIL)]))
max_conversions.append(max(vals))
min_conversions.append(min(vals))
if min(vals):
# If the min is 0 we would have an infinite increase, so while removing
# these slightly skews the data, we have no choice!
max_by_min_conversion_increases.append(max(vals) / min(vals))
print 'Avg increase from min --> max:', avg(max_by_min_conversion_increases)
print 'Avg max conversion: ', avg(max_conversions)
print 'Avg min conversion: ', avg(min_conversions)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment