Module 8 · Probability: Reasoning About Uncertainty · Lesson 28 of 51

Distributions, expected value and simulation

Random variables, expected value for business decisions, the binomial, Poisson and normal distributions with SciPy, and Monte Carlo simulation.

In this lesson · about 45 minutes

  • Compute an expected value to compare options
  • Use the binomial, Poisson and normal distributions with scipy.stats
  • Answer a 'what could happen?' question by simulation

Expected value

E[X] = Σ value × probability. A promo email costs $0.05 to send; 4% of people redeem it, each bringing $6 of profit. EV per email = 0.04 × 6 − 0.05 = $0.19: worth sending. Variance tells you how bumpy the ride is around that average.

Three distributions you'll meet constantly

DistributionCounts or measuresCafé exampleSciPy
Binomial(n, p)Successes in n yes/no trialsHow many of 50 app visitors buystats.binom.pmf(k, n, p), .cdf
Poisson(λ)Events in a fixed time when they arrive at randomCustomers arriving in 10 minutes (average 6)stats.poisson.pmf(k, mu)
Normal(μ, σ)A measurement that clusters around an averageDaily sales, sample meansstats.norm.cdf(x, loc, scale)

pmf = probability of exactly k; cdf = probability of k or fewer; sf = probability of more than k (1 − cdf); ppf = the inverse (which value has 95% below it?).

Monte Carlo simulation

Write down how one random day works, run it 10,000 times with NumPy, and summarise the results. It handles questions with no tidy formula: "If we bake 60 croissants, how often do we sell out, and how many do we waste on average?"

Binomial, Poisson and normal in SciPy

How many croissants to bake?

Demand averages 52 a day (Poisson). Each sold earns $2.10 profit; each left over costs $0.90. Simulate 10,000 days for several batch sizes.

Exercise

Is the loyalty offer worth it?

A "free pastry after 5 coffees" offer: each member has a 0.3 chance of using it in a month. Users bring an extra $9 profit and cost $1.20 for the pastry; non-users bring nothing. Running the offer costs $0.50 per member per month. Set ev to the expected profit per member per month (rounded to 2) and worth_it to whether it's positive.

Exercise

Staffing for a rush

Customers arrive at Campus at an average of 9 per 10 minutes (Poisson). One barista handles up to 12 in that time. Set p_overload to the probability that more than 12 arrive, and p_quiet to the probability of 5 or fewer, both from scipy.stats.poisson, rounded to 4.

Flashcards

Module 8 flashcards

0 of 10 known

Say the answer out loud, flip the card, then be honest: cards you miss come back at the end.

10 left in the deck

Practice exam

Module 8 checkpoint

8 questions, 10 minutes.

  • 8 questions · 10 minutes
  • No feedback until you submit. Flag questions to come back to them.
  • Aim for 85% or better before you move on. The real exam's 750 out of 900 is roughly 80–83%.

Exercises solved: 0 of 2

Tip: solve each exercise first. Press Check to test your code.

Written by Noviq Academy in its own words. Kettle & Crumb and all its data are made up for teaching; any resemblance to a real business is a coincidence. Python runs in your browser with Pyodide, so results can differ slightly from your own computer. Power BI, Tableau and other product names belong to their owners. Read-aloud uses your device's built-in voices.