← Back to roadmapProbability · 11 of 40

Lesson 11 · Probability

Distributions and simulation

Choose a distribution from the mechanism that generates the data, then use a reproducible simulation to check a probability, quantile, or operational decision.

Learning objective

Given a probabilistic story, define the random variable, unit of exposure, support, and target quantity; choose and parameterize a defensible distribution; compute a probability or tail; and simulate the full process while stating what the simulation does—and does not—validate.

Prediction before reveal

What is the number of clicks?

A notification reaches 20 eligible users. Each user clicks with probability 0.10. Choose the most defensible starting model before the plot appears.

Model check0 / 1
Which random variable and mechanism fit the story?

Choose a model to record your prediction.

The interview-ready answer: “I am modeling this random variable, which is discrete or continuous and has this support. The mechanism suggests this family with parameters in these units. I would check its independence, rate, tail, or segment assumptions; use a CDF or survival probability for the decision; and simulate with a recorded seed if the calculation is cumbersome. More draws reduce Monte Carlo noise, not model error.”

1. Start with the variable, not the distribution name

A distribution is a compact model of how a random variable behaves. Before saying “Poisson” or “normal,” write down what one observation represents. For example:

  • X = successful clicks among 20 eligible users. This is a discrete count with support {0, 1, …, 20}.
  • X = support tickets arriving during one hour. This is a discrete count with support {0, 1, 2, …}; the exposure is one hour.
  • T = time until the next ticket. This is continuous, nonnegative, and measured in hours.
  • Y = order value. It is physically positive and often right-skewed; a lognormal model may be more defensible than a symmetric normal model when multiplicative effects dominate.

Support is a fast interview diagnostic. A normal distribution can assign probability to negative order values. That may be a harmless approximation for a measurement far from zero, or it may be a warning that a positive, skewed quantity needs a different model or a transformation. A count model should not quietly produce fractional events. Impossible values tell you to revisit the mechanism, truncation, or approximation.

For a discrete variable, the probability mass function (PMF) gives P(X=x). For a continuous variable, the probability density function (PDF) is a height: the probability of an interval is area under the density, while P(X=x)=0 for an ordinary continuous model. The common interface is the cumulative distribution function:

F(x) = P(X ≤ x)

Its complement is the survival function S(x)=P(X>x)=1-F(x). For a count, “at least 3” means P(X≥3)=1−P(X≤2), not 1−P(X≤3). Quantiles reverse the CDF: a 95th percentile is a threshold with approximately 95% of modeled outcomes below it. It is useful for capacity planning, but it is not a guarantee.

2. Match a mechanism to a canonical family

Canonical distributions are useful because their parameters have interpretable mechanisms. The table is a recognition aid, not permission to fit a named curve without checking the story.

Interview-relevant distribution families
FamilyGenerating storyKey factsWatch for
BernoulliOne binary trial with success probability pX∈{0,1}; mean p; variance p(1−p)It describes one opportunity, not a campaign total.
BinomialSuccesses in exactly n approximately independent trials with common pP(X=k)=C(n,k)pᵏ(1−p)ⁿ⁻ᵏ; mean np; variance np(1−p)Random opportunities, unequal probabilities, or dependence break the simple story.
PoissonEvents in a fixed exposure window with a stable expected count λP(X=k)=e⁻λ λᵏ/k!; mean = variance = λChanging rates, bursts, segments, and retries often create overdispersion.
ExponentialWaiting time to the next event from a constant-rate processF(t)=1−e⁻λᵗ; mean 1/λ; memorylessQueueing, priority, aging, or staffing can make the hazard change over time.
NormalSymmetric additive noise or an aggregate measurementN(μ,σ²); standardize with z=(x−μ)/σCheck support, skew, outliers, and dependence; a bell-shaped histogram is not enough.
LognormalA positive quantity whose logarithm has a normal distributionMedian eᵘ; mean eᵘ⁺σ²ᐟ²; right-skewedThe mean can be much larger than a typical observation.

Two units are easy to confuse. A rate of 2 tickets per hour is not itself a count distribution; for a 30-minute window, the expected count is λ=2×0.5=1. Likewise, “click probability 0.10” describes one opportunity; the expected number across 20 opportunities is np=2. State the exposure every time a parameter changes units.

3. Why binomial and Poisson look related

Let Bᵢ be the 0/1 indicator for success on trial i. If each Bᵢ is Bernoulli with success probability p, then the total successes are:

X = Σᵢ Bᵢ

To get exactly k successes, choose which k positions succeed, then multiply the probability of that sequence:

P(X=k) = C(n,k)pᵏ(1−p)ⁿ⁻ᵏ

Linearity of expectation gives E[X]=ΣE[Bᵢ]=np. Under independence, variances add, so Var(X)=np(1−p). Those formulas expose the assumptions: fixed n, binary outcomes, a common probability, and enough independence for variance addition.

Poisson is a useful approximation when opportunities are numerous, individual probabilities are small, and λ=np stays fixed. Setting p=λ/n and letting n grow turns the binomial expression toward:

P(X=k) → e⁻λ λᵏ/k!

The approximation is a consequence of a mechanism, not a universal rule based on seeing a small percentage. If the number of opportunities is known, binomial preserves the finite upper bound. If the natural story is an event rate per exposure, Poisson may be the cleaner starting point. If the count variance is much larger than its mean, investigate changing rates, clustering, or mixtures before simulating more single-rate Poisson draws.

4. Worked calculation: 20 independent opportunities

Question. A notification is sent to n=20 eligible users. Assume each user clicks independently with common probability p=0.10. What is the probability of at least three clicks, and what are the mean and standard deviation?

Step 1 — name the variable. Let X be the number of clicks in one send. It is a fixed-opportunity count, so X∼Binomial(20,0.10). If users can click repeatedly, users influence one another, or audience segments have very different rates, this is only an approximation.

Step 2 — translate the event. “At least three” includes 3, 4, and every larger count. The shorter complement is:

P(X≥3) = 1 − [P(X=0)+P(X=1)+P(X=2)]

Step 3 — calculate each term. With q=1−p=0.90:

P(X=0)C(20,0)(0.10)⁰(0.90)²⁰ = 0.1215767

P(X=1)C(20,1)(0.10)¹(0.90)¹⁹ = 0.2701703

P(X=2)C(20,2)(0.10)²(0.90)¹⁸ = 0.2851798

TailP(X≥3) = 1 − 0.6769268 = 0.3230732

Step 4 — calculate location and spread. The expected count is E[X]=np=20(0.10)=2. The variance is 20(0.10)(0.90)=1.8, so the standard deviation is √1.8≈1.342 clicks.

Interpretation. Under this model, about 32.3% of comparable sends have at least three clicks. The expected count of 2 describes a long-run average; it does not mean every send produces two clicks. A 10,000-draw simulation should estimate the tail near 0.323 with simulation standard error approximately √[0.323(1−0.323)/10,000]≈0.0047. An estimate of 0.329 is plausible noise, not evidence that the formula failed.

5. Simulation is a transparent estimator, not a truth machine

Simulation is useful when the target is hard to calculate exactly or when several random inputs interact. Define the generative process first. Then draw independent or appropriately dependent replicas, transform each replica into the decision statistic, and summarize the resulting distribution.

If the target is θ=E[g(X)], draw X₁,…,Xₘ and compute:

θ̂ = (1/M) Σᵢ g(Xᵢ)

For a capacity event, g(Xᵢ) is 1 when simulated demand exceeds capacity and 0 otherwise. The average of those indicators is the simulated exceedance probability. Under suitable independence, the law of large numbers makes the estimate stabilize as M grows. For an indicator with estimated probability θ̂, a useful Monte Carlo standard-error approximation is:

SE(θ̂) ≈ √[θ̂(1−θ̂)/M]

Use a local generator and record the seed, model parameters, draw count, and code version. Compare a simulation to an analytic case when one exists; repeat with several seeds or batches; and inspect how the estimate changes as M increases. A seed makes a pseudo-random run reproducible for debugging. It does not make the real world deterministic and it is not a substitute for secure randomness.

The most important boundary is model error. If the rate is wrong, users are dependent, the population is a mixture, or an outage regime is omitted, one million draws can produce a very precise answer to the wrong question. Simulation validates arithmetic conditional on the model; domain checks and out-of-time backtests are what challenge the model.

6. Worked product scenario: staffing payment-failure support

Question. A checkout team expects 5,000 attempts per day. Returning users have payment-failure probability 0.01 and new users 0.05. The planned mix is 3,500 returning and 1,500 new users. The team can resolve 120 failure tickets daily. What is the chance demand exceeds capacity?

Step 1 — define the decision. Let Y be payment failures in one day. The relevant event is Y>120, not only the average failure rate. With fixed segment counts and independent conditional outcomes:

Y = Yᵣ + Yₙ, Yᵣ∼Binomial(3500,0.01), Yₙ∼Binomial(1500,0.05)

Step 2 — baseline moments. The expected daily demand is E[Y]=3500(0.01)+1500(0.05)=35+75=110. Because the segment outcomes are independent, the variances add:

Var(Y)=34.65+71.25=105.90

So the baseline standard deviation is √105.90≈10.29 tickets. Exact convolution gives P(Y≥120)≈0.1773. A simulation can reproduce this by drawing one returning-user count and one new-user count per replicate day, adding them, and recording whether the sum reaches 120. With M=100,000, the Monte Carlo standard error is about √[0.177(1−0.177)/100,000]≈0.0012.

Step 3 — inspect the tempting shortcut. The exposure-weighted failure probability is:

p̄ = [3500(0.01)+1500(0.05)]/5000 = 0.022

A one-rate shortcut, Binomial(5000,0.022), has the same mean 110 and gives a similar tail here, about 0.1791. That similarity is conditional, not proof that the models are interchangeable. If the segment mix varies day to day, failures cluster during an outage, or rates move together, averaging p hides uncertainty. A stress simulation can draw a regime or segment mix first, then draw conditional failures. The mean may remain near 110 while variance and P(Y>120) rise.

Decision. I would not staff to the mean. I would backtest the segmented generator on comparable historical days, stress the new-user mix and outage rate, and choose a capacity percentile tied to the support-service target. On launch day I would monitor failure rate by user segment, queue volume, retries, exposure mix, and logging completeness. If observed variance is several times the Poisson mean, investigate changing rate, dependence, data grain, and unmodeled subgroups before reaching for a negative-binomial or mixture model.

7. Continuous distributions: waiting, measuring, and skew

If events arrive at a constant rate λ, the time T until the next event is exponential. The survival function is:

P(T>t)=e⁻λᵗ

That gives the memoryless property:

P(T>s+t | T>s)=P(T>t)

Memoryless does not mean “all waits are exponential.” Support response time can depend on priority, queue backlog, staffing shifts, and how long a ticket has already waited. Inspect conditional residual waits or an empirical survival curve; a Weibull, gamma, queueing, or empirical model may be a better next step, especially when unresolved tickets are censored.

A positive right-skewed measure such as order value or session duration may be generated by multiplicative effects. If log(Y)∼N(μ,σ²), then median(Y)=eᵘ and E[Y]=eᵘ⁺σ²ᐟ². The mean exceeds the median when σ>0. This matters when an interviewer asks for “typical” behavior versus expected revenue or a high-percentile service target.

Nearest alternatives and failure modes

The nearest plausible alternative is often a different data-generating story, not a more sophisticated algorithm:

Decision boundaries for related choices
If the story is…Start with…Switch or stress-test when…
Fixed binary opportunitiesBinomial; preserve known n and finite support.Opportunities are random, probabilities vary by segment, or outcomes interact.
Events per exposure windowPoisson; make λ a count for the stated window.Mean and variance disagree, rates change, events cluster, or retries inflate counts.
Waiting for the next eventExponential only with constant hazard.Age, queue position, priority, or staffing changes the hazard.
Positive multiplicative outcomeLognormal as a candidate; inspect log scale and quantiles.Zeros, censoring, multiple segments, or a different tail mechanism dominate.
Observed data with no credible generatorEmpirical distribution or resampling, with explicit dependence assumptions.Do not pretend a fitted name establishes mechanism; later lessons cover bootstrap and permutation.

Common failure signals include zero inflation, overdispersion, serial dependence, changing exposure, censoring, a hidden mixture, and support violations. A mixture of two binomials is not generally a binomial with the average probability. A mixture of two normals is not generally normal. Compare conditional distributions within homogeneous segments, plot rates over time, inspect the data grain, and test the tail relevant to the decision.

Common interview trap

Weak answer: “I would use a Poisson distribution and run 10,000 simulations.”

Why it fails: it never defines the random variable or exposure, explains why events are approximately independent, states the unit of λ, names the target probability, or reports simulation uncertainty. It also implies that a larger simulation can rescue a changing rate or a mixture of segments.

Corrected answer: “I would define the count and window first. If this is a stable event rate with approximately independent increments, I would start with Poisson and scale λ to the window. I would estimate the exceedance probability with a seeded generator, report M and Monte Carlo SE, compare with an analytic case, and check time clustering, segment mix, retries, and overdispersion. If those checks fail, I would simulate the richer process or use an alternative model rather than adding draws to the wrong one.”

Interview practice bank

  1. How do you choose a probability distribution for a new problem?

    Strong answer: Define the random variable and one observation; state support and units; identify the mechanism; choose the smallest defensible family; specify parameters; name assumptions and diagnostics; then use a CDF, tail, quantile, or simulation for the decision.

    Follow-up: What if the count variance is twice its mean? Signal: structured probabilistic thinking instead of distribution-name recall.

  2. Twenty users click independently with probability 0.1. Compute P(X ≥ 3), the mean, and variance.

    Strong answer: X∼Binomial(20,0.1); use 1−[P(0)+P(1)+P(2)]≈0.3231; mean 2; variance 1.8; SD about 1.342. State fixed n, common p, and independence.

    Follow-up: When is Poisson with λ=2 reasonable? Signal: accurate event translation, arithmetic, and assumptions.

  3. What is the difference between a PDF and a probability?

    Strong answer: A discrete PMF height is point probability; a continuous PDF height is density, not point probability and may exceed 1. Interval probability is area under the density. The CDF gives P(X≤x) for either type.

    Follow-up: How would you compute P(a<X<b)? Signal: avoids a foundational category error.

  4. Why does a Poisson distribution have variance equal to its mean?

    Strong answer: It is a consequence of the sparse independent-event mechanism, or of the binomial limit with p=λ/n: mean np=λ, variance np(1−p)→λ. Equality is a model implication and a diagnostic, not a law of all counts.

    Follow-up: What does overdispersion suggest? Signal: connects formula to mechanism.

  5. A Poisson model predicts mean and variance 50, but observed daily variance is 180. What do you investigate?

    Strong answer: Verify grain and exposure; inspect serial dependence, segment mix, changing rates, outages, retries, zero inflation, and measurement changes. Compare conditional variance within homogeneous strata, then consider a mixture, time-varying rate, or negative binomial as a candidate—not as an automatic answer.

    Follow-up: Would a negative binomial prove the mechanism? Signal: diagnoses before selecting a replacement.

  6. When would you use binomial instead of Poisson?

    Strong answer: Binomial when fixed opportunities and binary outcomes with common p are central; Poisson when event count per exposure and a stable rate are central. Poisson can approximate binomial for large n, small p, λ=np, but exact binomial preserves the known upper bound.

    Follow-up: What if page views are random rather than fixed? Signal: chooses from the story, not just the percentage.

  7. Why might exponential waiting time be wrong for support response time?

    Strong answer: Exponential implies constant hazard and memorylessness. Priority tiers, queue buildup, staffing shifts, and aging violate that story; inspect conditional waits, censoring, and segments, then consider an empirical survival, Weibull/gamma, or queueing model.

    Follow-up: What does memoryless mean numerically? Signal: connects a distribution to process assumptions.

  8. How would you estimate the probability that a policy exceeds capacity?

    Strong answer: Define the full generative process and policy; sample uncertain inputs with dependencies; run many seeded replicates; use an exceedance indicator; report estimate, M, seed, and Monte Carlo SE; validate against an analytic case and stress uncertain rates or mixes.

    Follow-up: How large should M be? Signal: designs a decision-oriented simulation rather than a decorative histogram.

  9. A launch team can process 120 payment-failure tickets per day. How would you plan staffing?

    Strong answer: Define daily failures and capacity; segment returning and new users; compute a mean/variance baseline; simulate segmented counts and P(Y>120); choose a service-level percentile; backtest and monitor rates, mix, retries, and outages. Explain the averaged-rate shortcut and its limits.

    Follow-up: What if failures correlate during an outage? Signal: turns distribution choice into a bounded operational decision.

Timed synthesis

You have eight minutes. A marketplace expects 10,000 daily orders. Historical data suggest 1.5% need manual review, but review rates are higher for new sellers and seller mix will change during a promotion. Operations can process 180 reviews per day. Choose a model, estimate the capacity risk, describe a simulation, and state what you would monitor after launch.

Incomplete: names a distribution without defining the variable or exposure, averages away seller mix, says “run simulations” without a statistic or uncertainty, and gives no failure diagnostic.

Competent: defines daily review count and capacity threshold; starts with fixed-order binomial or segmented binomials; computes a mean/variance baseline; simulates P(Y>180) with M, seed, and Monte Carlo SE; and names mix drift and dependence as risks.

Strong: preserves seller dependencies, distinguishes a fixed-opportunity story from a Poisson exposure story, backtests on promotion-like periods, stress-tests rate and mix, selects a service-level percentile with a contingency, and says plainly that more draws cannot cure misspecification.

Three quick checks

  1. You observe refunds among a fixed 2,000 orders. What must you ask before choosing binomial or Poisson?

    Ask whether 2,000 is fixed and each order has one binary outcome with a common probability and approximate independence. If the natural story is event count per exposure, or rates vary by segment, state that and model the structure explicitly.

  2. A simulation estimates P(Y>120)=0.177 from 100,000 replicates. What else belongs in your answer?

    Name the model, parameters, target definition, generator/seed, simulation size, Monte Carlo SE (about 0.0012 here), and a check that the launch process—including mix and dependence—matches the generator.

  3. The simulated mean matches the observed mean, but observed variance is four times the Poisson variance. Is the model validated?

    No. Matching the mean is weak evidence. Investigate changing rate, dependence, segment mix, retries, zero inflation, and data grain; compare conditional distributions and decision tails. A larger simulation would only make the wrong model more precise.

Keep this in mind

  • Define the random variable, support, unit, and target before naming a distribution.
  • Binomial counts fixed binary opportunities; Poisson counts events per exposure; exponential models constant-hazard waiting time.
  • A PDF is density, not point probability. Use a CDF, survival function, or quantile for communication and decisions.
  • Means do not describe tails, and averaged segment rates do not automatically preserve the distribution.
  • Record the seed, generator, parameters, draw count, and Monte Carlo standard error.
  • More draws reduce simulation noise. They do not repair a wrong support, rate, dependence structure, or mixture assumption.

Sources and scope

The distribution definitions, support, mass/density distinction, and CDF framing follow the NIST/SEMATECH probability-distribution reference and its related-distributions reference. The binomial, exponential, normal, and Poisson claims are cross-checked against NIST’s binomial distribution, exponential distribution, normal distribution, and Poisson approximation notes. The PMF/PDF/CDF and sampling vocabulary is also consistent with the SciPy probability-distributions guide; seeded generator behavior follows the NumPy random-sampling reference. The current CZI 2025 interview guide calibrates the emphasis on role-specific reasoning and communication, not a universal interview loop. Scope excludes full distribution fitting, formal goodness-of-fit tests, the CLT, likelihood, bootstrap, permutation, censoring estimators, and advanced stochastic processes; those belong in later lessons or specialist depth.