Probability Distributions
The distribution of a random variable describes how probability is spread over its possible values. Two random variables with the same distribution behave identically from a probabilistic point of view, even if they come from different experiments. A crit indicator on a d20 and a biased coin that lands heads 5% of the time have the same distribution.
Most distributions used in practice belong to a few families, each indexed by a small number of parameters. We write to say that follows the normal distribution with parameters and .
This chapter covers
- probability mass functions for discrete random variables and probability density functions for continuous ones,
- the discrete families Bernoulli, binomial, categorical and Poisson,
- the continuous families uniform, normal, beta and Student's t,
- the multivariate normal distribution, and
- a summary table of where each family appears in the ML and RL notes.
Probability Mass Functions
A discrete random variable is described by its probability mass function (PMF), . A function is a valid PMF exactly when its values are non-negative and add up to one over all possible values,
The probability of any event is the sum of the PMF over the values in it, , and the CDF from chapter 1 is the running sum .
Probability Density Functions
A continuous random variable is described by a probability density function (PDF) , whose area over an interval gives the probability that falls in it,
A function is a valid PDF exactly when it is non-negative and its total area is one,
The density is the derivative of the CDF, , and for a small width the probability of landing near is approximately . A density is therefore not a probability, and it can be larger than one. The uniform distribution on has density everywhere on that interval, and its total area is still .
Discrete Distributions
Bernoulli
The Bernoulli distribution describes a single trial with two outcomes, success () with probability and failure () with probability . Its PMF is
The crit indicator from chapter 1 is . In machine learning, logistic regression models a binary label as a Bernoulli random variable whose depends on the input.
Binomial
The binomial distribution counts the successes in independent Bernoulli trials with the same success probability . Independent means that the result of one trial doesn't change the probabilities of the others. There are ways to place successes among trials, each with probability , so
The number of critical hits in 20 attack rolls is . The probability of at least one crit is , so a full evening of combat without a single crit isn't that unusual.
Categorical
The categorical distribution generalizes the Bernoulli to outcomes. The random variable takes a value in , and a vector of probabilities gives
A fair d20 is categorical with for every face. Softmax regression outputs a categorical distribution over classes, and in RL a stochastic policy over a finite set of actions is a categorical distribution for each state (see Markov Decision Processes). Counting how often each outcome occurs in categorical trials gives the multinomial distribution, which relates to the categorical the way the binomial relates to the Bernoulli.
Poisson
The Poisson distribution counts events in a fixed interval of time or space, when events occur independently of each other at a constant average rate . Its PMF is
The number of random encounters during a day of travel, or of emails you receive in an hour, are classic examples. The Poisson is also the limit of the binomial for rare events. If is large and is small, is close to . Poisson regression uses it to model counts.
Continuous Distributions
Uniform
The uniform distribution on spreads probability evenly over the interval,
Random number generators produce values, and samplers for every other distribution, including the ones in these interactives, start from them. Shrink the interval below a width of one to see the density rise above one.
Normal
The normal (or Gaussian) distribution is the bell curve,
where sets the center and sets the spread. About 68% of the probability lies within one of , 95% within two and 99.7% within three. The standard normal has and , and any normal random variable can be standardized to it with .
The normal shows up so often because averages of many independent quantities are approximately normal, which is the central limit theorem. The ML notes use it to model the noise in linear regression, and the RL notes use it for policies over continuous actions in policy gradient methods.
Beta
The beta distribution lives on , which makes it a natural way to describe uncertainty about an unknown probability. With shape parameters ,
where makes the area equal to one. With it is the uniform distribution. The mean is , and the larger is, the more concentrated the distribution becomes.
If you suspect that a d20 is loaded but don't know by how much, a beta distribution can describe your belief about its crit chance. A later chapter on Bayesian inference updates that belief with each roll, and the same idea drives Thompson sampling for bandits.
Student's t
The Student's t distribution with degrees of freedom has density
It is bell-shaped and centered at zero like the standard normal, but with heavier tails, and it approaches the standard normal as grows. It appears when a sample mean is standardized with the sample's own standard deviation instead of the true one, which is the basis of confidence intervals and t-tests in the planned inference chapters.