1.13 Random variables and distributions

Standard probability and statistics for ML — written August 2026

What this is and why it exists

Choosing a distribution IS a modelling assumption — "errors are Gaussian", "clicks are Bernoulli", "arrivals are Poisson" are claims about the world wearing mathematical clothes. This topic builds the wardrobe: the standard distributions as answers to "what process generated this?", and the machinery (PMF, PDF, CDF, quantiles) for wearing any of them fluently.

The vocabulary

  • Random variable — a number attached to a random outcome; the object everything else describes.
  • PMF / PDF — the probability of each value (discrete) or the density whose AREA gives probability (continuous); a density is not a probability and can exceed 1.
  • CDF — probability of landing at or below x; the universal, always-defined description.
  • Quantile — the CDF read backwards: the value below which a given fraction falls (the median is the 0.5 quantile).
  • Bernoulli / binomial / categorical — one yes-no trial; the count of yeses in n trials; one roll of a k-sided (possibly loaded) die.
  • Poisson — the count of independent rare events in a window, given only their average rate.
  • Uniform / exponential / normal / beta / gamma — the continuous regulars: ignorance-within-limits; memoryless waiting time; summed noise; a probability's own distribution; waiting for several events.

The mental model

Match the STORY, not the shape. Each named distribution is the fingerprint of a generating process, and picking one is asserting that the process happened. One outcome, two ways: Bernoulli — a click, a defect, a conversion. Count of successes in a fixed number of tries: binomial — bit errors per packet. One of k categories: categorical — the output layer of every classifier. Counts of independent events at a known average rate with no fixed n: Poisson — support tickets per hour, typos per page. Time until the next such event: exponential, whose famous memorylessness (the wait so far tells you nothing about the wait remaining) is a strong assumption you should notice yourself making. Anything that is a SUM of many small independent effects: normal — measurement noise, and (pr5) the CLT's universal endpoint. A quantity that is itself a probability: beta, the natural prior for a rate (st6 will use it). Waiting for several exponential events: gamma.

The machinery is one picture. Discrete variables have a PMF — bars whose heights are probabilities and sum to one. Continuous ones have a PDF — a curve whose AREAS are probabilities; the height at a point is a density, can exceed 1, and P(X equals any exact value) is zero. The CDF works for both — accumulate from the left — and quantiles read it backwards, which is how "95th percentile latency" and every confidence interval are actually computed. Transformations are the working skill: pushing a variable through a function reshapes its distribution (squash a uniform through the inverse CDF and you SAMPLE from any distribution — how random number libraries work), and the log-transform that turns multiplicative effects additive is the data-handling module's favourite move.

What you should now be able to explain or do

Name the distribution from a described process, and the assumption it smuggles. Read probabilities from a PDF as areas and from a CDF directly. Extract quantiles. Say what a density's height means, and one honest sentence about what transforming a variable does.

Check yourself

Poisson(7) for the count; exponential for the wait — the paired fingerprints of independent events at a constant average rate.

No — it is a density. Probabilities are areas under the curve; heights can exceed 1 as long as the total area is 1. P(X exactly 0.3) is zero.

Memorylessness: having waited ten minutes already changes nothing about the remaining wait's distribution — true for genuinely independent arrivals, false for wear-out and queues with structure.

Beta — a distribution ON the interval from 0 to 1, the natural prior for a rate (a conversion rate, a click-through rate); it drives the Bayesian A/B analysis of st6.

The CDF inverted: the value below which a fraction q of probability lies. Medians, percentile latencies and the endpoints of confidence intervals are all quantiles.

Go deeper

Back to Random variables and distributions: work through the checklist