Get startedGet started for free

Probability of losing money

In this exercise, we will use the DGP model to estimate probability.

As seen earlier, this company has the option of spending extra money, let's say $3000, to redesign the ad. This could potentially get them higher clickthrough and signup rates, but this is not guaranteed. We would like to know whether or not to spend this extra $3000 by calculating the probability of losing money. In other words, the probability that the revenue from the high-cost option minus the revenue from the low-cost option is lesser than the cost.

Once we have simulated revenue outcomes, we can ask a rich set of questions that might not have been accessible using traditional analytical methods.

This simple yet powerful framework forms the basis of Bayesian methods for getting probabilities.

This exercise is part of the course

Statistical Simulation in Python

View Course

Exercise instructions

  • Initialize cost_diff, the difference between the 'high' and 'low' cost options, to 3000.
  • Get the revenue for the high-cost option and assign it to rev_high.
  • Calculate the fraction of times when rev_high - rev_low is less than cost_diff. Call it frac and use it to print your results.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Initialize cost_diff
sims, cost_diff = 10000, ____

# Get revenue when the cost is 'low' and when the cost is 'high'
rev_low = get_revenue(get_signups('low', ct_rate, su_rate, sims))
rev_high = ____

# calculate fraction of times rev_high - rev_low is less than cost_diff
frac = ____
print("Probability of losing money = {}".format(____))
Edit and Run Code