Overview
Curated: · Written: · Reviewed:
Probability Distributions
In one line
Choose the distribution from the process that generates the data, then check the tail, because alerts and capacity are set in the tail. Binomial counts successes in fixed trials, Poisson counts events at a constant rate, exponential measures the wait between them, normal fits sums of small effects, and log-normal fits products of effects. Use negative binomial when counts are over-dispersed.
Key definitions
- Generating mechanism: the process that produces the observations. It justifies a family; the histogram shape does not.
- Density: a continuous curve whose value can exceed 1. Probability is its integral over an interval, and any exact value has probability zero.
- Over-dispersion: variance above the mean. It breaks the Poisson assumption.
- Memoryless: P(T > s + t | T > s) = P(T > t). Only the exponential has this property.
- Censored observation: a value known only to exceed a limit, such as a timeout.
- Tail index: the power-law exponent α. Below 2 the variance is infinite.
Formulas and complexity
No event in a window of length t for a Poisson process. The exponential survival function has the same form.
Negative binomial with shape r. It reduces to Poisson as r grows.
Log-normal, where μ and σ are the mean and standard deviation of log X.
Sum of n independent stages. For 100 calls with mean 8 ms and SD 6 ms: mean 800 ms, SD 60 ms.
For ±10% relative precision at 95%, n = z²(1−p)/(0.01p). This gives about 1,540 at p = 0.2 and about 18,800 at p = 0.02.
Little's law: mean requests in flight equal arrival rate times mean latency.
How it works
- Name the mechanism: fixed trials, events at a constant rate, waiting, or additive or multiplicative effects.
- Map it to the family and name the one property to test: equal mean and variance for Poisson, memorylessness for exponential, constant p and independence for binomial.
- Estimate parameters, then confirm the library convention. SciPy's
expontakesscale = 1/rate. - Check the tail with a Q-Q plot or the empirical CDF. A goodness-of-fit test on large samples rejects every model, so it measures detectability, not adequacy.
- Decide from the quantile you need, using the fitted model's quantile or the empirical one with an interval. Never use mean + k·SD for a skewed or heavy-tailed quantity.
When to use and when not to
| Distribution | Use when | Fails when | Check |
|---|---|---|---|
| Binomial | fixed n, independent trials, constant p | p varies or trials correlate | variance n·p·(1−p) |
| Poisson | constant-rate counts | arrivals cluster | variance ≈ mean |
| Negative binomial | over-dispersed counts | underlying rate is truly constant | variance = μ + μ²/r |
| Exponential | waits with constant hazard | hazard changes with age, long service tails | mean = scale |
| Normal | sums of many small effects | skew or heavy tails, as in latency | Q-Q tail check |
| Log-normal | positive multiplicative effects | the data mixes populations | report the median |
| Heavy tail (α < 2) | extreme values dominate | never for a CLT-based interval | tail index first |
Traps interviewers probe
- Poisson for clustered counts. A variance of 3× the mean means arrivals cluster, and Poisson intervals come out too narrow. Fix: compare variance with mean and switch to negative binomial.
- Reading a density as a probability. For rate 10, f(0.2) = 1.35 is a density, not a probability. P(gap > 0.2 s) = e^{-2} ≈ 0.135, and P(gap = 0 s) = 0. Fix: integrate over an interval.
- mean + 2.33·SD for heavy tails. At α = 1.5 the variance is infinite, so the sample SD does not settle as n grows and one extreme point can dominate. Fix: check the tail index first, then use an empirical quantile with a bootstrap bound or a tail model.
- Timeouts recorded as measurements. Storing 30 of 1,000 requests as 5,000 ms makes p99 = 5,000 ms, which is only a floor. Fix: record censoring and use survival methods.
- One seeded RNG shared by workers. Identical seeds produce identical streams, so pooling duplicates the draws and understates the standard error. Fix: spawn child generators with
rng.spawnand record the seeds.
Interview tips
Open with the mechanism and the family in one sentence, then name the test you would run on it.
Follow-ups to expect:
- Does variance equal the mean? If not, what model replaces Poisson?
- Does memorylessness hold for this service? A disk that has run 3,000 hours still has a 37% chance (e^{-1}) of surviving the next 1,000 under an exponential model, so an exponential model gives no reason to replace it early.
- Is the variance finite? If not, the CLT interval is invalid.
- With 100 independent backends at 1% slow each, 1 − 0.99^100 ≈ 63% of requests exceed 100 ms end to end, so the end-to-end p99 is not the stage p99.
30-second answer: "These are per-window counts at a roughly constant rate, so Poisson is my first model, and I check mean against variance. If variance is well above the mean, arrivals cluster, so I use a negative binomial. For the threshold I take the p99 from the fitted quantile, check it against the empirical p99, and report the interval. I don't use mean plus 2.33 standard deviations. Before running anything I confirm the library's parameter convention."
Feedback on this overview
Log in free to save your progress and keep bookmarks and notes for a quick revision before your interview.