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.
Este ejercicio forma parte del curso
Statistical Simulation in Python
Instrucciones del ejercicio
- Model
purchases
as a binomial RV withp=0.1
. - Model
purchase_values
as an exponential RVscale=1000
and the appropriatesize
. - Append
rev
with the sum ofpurchase_values
.
Ejercicio interactivo práctico
Prueba este ejercicio completando el código de muestra.
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]))