Most interview questions use one of five shapes. Guess two of their facts before the table gives them away.
Predict
Orders arrive independently at 3 a minute on average. What's the variance of the count in one minute?
Predict
At 3 orders a minute, the gap between orders averages 20 seconds. What's its standard deviation?
Distribution
At the shop
Mean, variance
Bernoulli(p)
is an order returned
p, p(1 − p)
Binomial(n, p)
returns among n orders
np, np(1 − p)
Poisson(λ)
orders in a minute
λ, λ
Exponential, rate λ
minutes between orders
1/λ, 1/λ²
Normal(μ, σ²)
the average of many
μ, σ²
OpenStax gives the binomial's mean as np and its variance as npq, with q = 1 − p, and calls the single-trial case a Bernoulli trial. A Poisson count fits events that happen at a known average rate, each independently of the time since the last one, like orders arriving. The gaps between such events are exponential, and OpenStax notes that an exponential's standard deviation equals its mean.
import numpy as nprng = np.random.default_rng(6)draws = { "returned or not, Bernoulli(0.1)": (rng.random(100_000) < 0.1, 0.1, 0.09), "returns in 20 orders, binomial(20, 0.1)": (rng.binomial(20, 0.1, 100_000), 2.0, 1.8), "orders a minute, Poisson(3)": (rng.poisson(3, 100_000), 3.0, 3.0), "minutes between orders, exponential": (rng.exponential(1 / 3, 100_000), 1 / 3, 1 / 9),}for name, (x, m, v) in draws.items(): print(f"{name:40} mean {x.mean():.3f} ({m:.3f}), variance {x.var():.3f} ({v:.3f})")
returned or not, Bernoulli(0.1) mean 0.100 (0.100), variance 0.090 (0.090)returns in 20 orders, binomial(20, 0.1) mean 2.001 (2.000), variance 1.808 (1.800)orders a minute, Poisson(3) mean 3.000 (3.000), variance 2.999 (3.000)minutes between orders, exponential mean 0.334 (0.333), variance 0.111 (0.111)