Part 0 · 1 chapters · ~8 min

Distributions

Random variables, probability mass and density, the normal, log-normal, exponential, Poisson and binomial distributions, heavy tails and power laws, the law of large numbers and the central limit theorem (and when it fails), and simulating distributions in code.

1

Simulate to understand

code
// seeded generator so every number in this course is reproducible
let s = 42; const rnd = () => { s = (s * 1664525 + 1013904223) >>> 0; return (s + 0.5) / 4294967296; };
const normal = () => Math.sqrt(-2 * Math.log(rnd())) * Math.cos(2 * Math.PI * rnd());   // Box-Muller

// latency model used throughout: log-normal body (median 40 ms) + 1% slow tail (400-1000 ms: GC, retries)
const latency = () => rnd() < 0.01 ? 400 + rnd() * 600 : Math.exp(Math.log(40) + 0.35 * normal());
const poissonGap = (ratePerSec: number) => -Math.log(rnd()) / ratePerSec;               // exponential inter-arrival

Central limit theorem: averages of many independent samples become approximately normal, whatever the underlying distribution, which is why confidence intervals for means work. It converges slowly for heavy-tailed data, and not at all if the variance is infinite, so tail-heavy metrics need percentiles and the bootstrap (part 4).

DISTRIBUTIONS YOU MEET IN PRODUCTION
what generates the numbers you see
normalSums of many small effects;symmetric. Rare for latency.log-normalProducts of effects; right-skewed.Typical request latency body.exponentialTime between independent arrivals;memoryless.PoissonCount of independent events perinterval: requests per second.binomialSuccesses in n trials: conversionsout of visitors.heavy-tailed (Pareto)A few huge values dominate: filesizes, customer spend, tenantload.
swipe the figure sideways, or tap expand for full screen
1/4
normal is rare
The bell curve fits sums of many small independent effects (measurement error). Latency is bounded below and skewed right, so it is not normal.
sums of small effectslatency is not normal