Purchase Flow
After signups, let's model the revenue generation process. Once the customer has signed up, they decide whether or not to purchase - a natural candidate for a binomial RV. Let's assume that 10% of signups result in a purchase.
Although customers can make many purchases, let's assume one purchase. The purchase value could be modeled by any continuous RV, but one nice candidate is the exponential RV. Suppose we know that purchase value per customer has averaged around $1000. We use this information to create the purchase_values RV. The revenue, then, is simply the sum of all purchase values.
The variables ct_rate, su_rate and the function get_signups() from the last exercise are pre-loaded for you.
This exercise is part of the course
Statistical Simulation in Python
Exercise instructions
- Model
purchasesas a binomial RV withp=0.1. - Model
purchase_valuesas an exponential RVscale=1000and the appropriatesize. - Append
revwith the sum ofpurchase_values.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
def get_revenue(signups):
rev = []
np.random.seed(123)
for s in signups:
# Model purchases as binomial, purchase_values as exponential
purchases = ____(s, p=____)
purchase_values = ____
# Append to revenue the sum of all purchase values.
rev.append(____)
return rev
print("Simulated Revenue = ${}".format(get_revenue(get_signups('low', ct_rate, su_rate, 1))[0]))