Skip to content

Instantly share code, notes, and snippets.

@Pitchlab
Last active November 5, 2021 01:42
Show Gist options
  • Save Pitchlab/29f637be0552b74c0197ded2fbb8488e to your computer and use it in GitHub Desktop.
Save Pitchlab/29f637be0552b74c0197ded2fbb8488e to your computer and use it in GitHub Desktop.
import math
# TMI Startup Calculator
# (c)2019 Erik van der Pluijm, TMI
#
# all times in months
# some variables to work with - change these for outcomes
#
start_users = 100
price_month = 10.0
churn_year = 0.25
churn_month = churn_year/12
growth_year = 0.5
growth_month = growth_year/12
# assuming the following funnel: Ad impressions > Ad clicks > Landing Page > Signup > Pay
# Conversion rates between stages (change these for effect):
c_adimpr_adclicks = 0.02
c_adclicks_lp = 0.05
c_lp_signup = 0.05
c_signup_pay = 0.9
# advertising cost per click
cpc = 0.5
# calculate the number of users churned at time = t
def n_churn(start_users, churn, t):
return start_users * math.exp(math.log(churn) * t)
# calculate the number of users at time = t
def n_users(start_users, growth, churn, t):
return start_users * math.exp(math.log(1+growth-churn) * t)
# calculate the number of 'new' users that were added to counter churn and realise growth at time = t
def n_new(start_users, growth, churn, t):
users = n_users(start_users, growth, churn, t)
oldusers = n_users(start_users, growth, churn, t-1)
return users - oldusers + n_churn(oldusers, churn, 1)
# calculate how many people to reach for a certain number of users
def audience_size(users):
return users / c_adimpr_adclicks / c_adclicks_lp / c_lp_signup / c_signup_pay
# the average number of months customers stay
t_halflife = math.log(2) / churn_month
# customer lifetime value
cltv = t_halflife * price_month
cac = 1 / (c_adclicks_lp * c_lp_signup * c_signup_pay) * cpc
print("Starting Users", start_users)
print("Yearly churn", churn_year * 100, "% Yearly growth", growth_year * 100,"%")
print("The average user is member for", t_halflife, "months")
print("CAC",cac, "CLTV", cltv, "CLTV/CAC", cltv/cac)
# run for 2 years (24 months)
#
for i in range(1,25):
users = n_users(start_users, growth_month, churn_month, i)
churn = n_churn(users, churn_month, 1)
new = n_new(start_users, growth_month, churn_month, i)
audience = audience_size(new)
cost = audience * cpc * c_adimpr_adclicks # only pay for part of audience that clicks!
print()
print("Month", i)
print("Users",users)
print("New",new)
print("Churning customers",churn)
print("Audience required",audience)
print("Cost of getting new customers",cost)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment