A random variable is a quantity whose value is uncertain — the outcome of a die roll, the velocity of a single molecule, the spike count of an auditory-nerve fibre over a fixed interval. Its distribution specifies the probabilities of each possible value. This lesson develops the vocabulary — random variable, distribution, expected value, variance — and the five or six named distributions (uniform, Bernoulli, binomial, Gaussian, exponential, Poisson) that recur throughout the chapter.
What is a random variable?
A random variable is a quantity whose value is not known with certainty until you measure it. Examples:
The number of times a tossed coin lands heads in 10 trials.
The arrival time of the next photon from a faint star.
The voltage measured across a noisy resistor at a particular instant.
The displacement of a Brownian particle after one second.
A random variable is not the same as a single random outcome. It is the entire family of possible outcomes plus the probabilities of each. Two random variables are equal in distribution if they have the same probabilities of producing the same outcomes — they need not produce the same value in any particular trial.
Random variables come in two flavours:
Discrete — takes values from a countable set: {0,1,2,3,…} or {H,T} or the integers. Examples: coin tosses, spike counts, photon counts.
Continuous — takes values from an uncountable interval, typically R or [0,1] or some subset. Examples: position of a Brownian particle, voltage, arrival time.
Describing a distribution
For a discrete random variable X, the probability mass function (PMF) gives the probability of each possible value:
p(k)≡Pr(X=k),k∑p(k)=1.
For a continuous random variable, individual points have probability zero (a continuous variable could be exactlyπ or exactly2, but the probability of landing on any single value with infinite precision is zero). Instead we describe the distribution by a probability density function (PDF):
f(x),Pr(a≤X≤b)=∫abf(x)dx,∫−∞∞f(x)dx=1.
The density f(x) has units of “probability per unit x.” For voltage it would have units of 1/V; for time, units of 1/s.
Both kinds of distribution can be described equivalently by their cumulative distribution function (CDF):
F(x)≡Pr(X≤x).
The CDF goes from 0 at −∞ to 1 at +∞, monotonically. For continuous X, f(x)=F′(x).
Expectation and variance
The expected value (or mean) of a random variable is the probability-weighted average of its possible values:
E[X]=k∑kp(k)orE[X]=∫xf(x)dx.
The expected value is a deterministic number — a property of the distribution, not of any particular realisation. It is the long-run average if you repeated the experiment many times.
The variance measures how spread out the distribution is around the mean:
Var[X]≡E[(X−μ)2]=E[X2]−μ2,
where μ=E[X]. The variance has units of [X]2; the square root, called the standard deviationσ=Var[X], has the same units as X and is the more natural “typical spread” measure.
▶The shortcut formula Var = E[X²] − μ²Derivation
Expand the definition:
Var[X]=E[(X−μ)2]=E[X2−2μX+μ2].
Linearity of expectation (which holds because the integral or sum is linear in the integrand):
Var[X]=E[X2]−2μE[X]+μ2=E[X2]−2μ⋅μ+μ2=E[X2]−μ2.
The variance is therefore “the mean of the square minus the square of the mean.” Useful: it avoids computing the centred quantity X−μ and then squaring, which can be slower than computing X2 directly and subtracting.
Higher-order moments — E[X3], E[X4] — measure further aspects of the distribution. The third moment around the mean (normalised by σ3) is skewness, measuring asymmetry. The fourth moment around the mean (normalised by σ4, minus 3) is kurtosis, measuring tail heaviness. For most distributions in the bookshelf, mean and variance suffice.
Six distributions to know
Six named distributions appear repeatedly across the bookshelf. They are worth knowing by name, mean, variance, and shape.
1. Uniform on [a,b]
Continuous, PDF is constant on [a,b] and zero outside:
f(x)=b−a1for x∈[a,b].
Mean (a+b)/2, variance (b−a)2/12. The “default” distribution when you have no information beyond bounds.
2. Bernoulli(p)
Discrete, two outcomes: 1 with probability p, 0 with probability 1−p. A single coin toss. Mean p, variance p(1−p). The building block of the binomial and Poisson.
3. Binomial(n,p)
Discrete, the number of successes in n independent Bernoulli(p) trials:
Pr(X=k)=(kn)pk(1−p)n−k,k=0,1,…,n.
Mean np, variance np(1−p). As n→∞ with p fixed, approaches a Gaussian (Central Limit Theorem). As n→∞ with np fixed (i.e. p→0), approaches a Poisson — see lesson 11.4.
4. Gaussian (normal), N(μ,σ2)
Continuous, the bell curve:
f(x)=σ2π1exp(−2σ2(x−μ)2).
Mean μ, variance σ2. The asymptotic shape of any sum of many independent identically-distributed (i.i.d.) random variables with finite variance — the Central Limit Theorem. Develop it in 11.2.
5. Exponential(λ)
Continuous, supported on [0,∞):
f(t)=λe−λt,t≥0.
Mean 1/λ, variance 1/λ2. The waiting-time distribution for a memoryless process — the inter-arrival times of a Poisson process. Develop it in 11.4.
6. Poisson(λ)
Discrete, supported on the non-negative integers:
Pr(X=k)=k!λke−λ,k=0,1,2,…
Mean λ, variance λ (variance equals mean — a Poisson-process signature). The number of events in a fixed time interval for a Poisson process. Develop it in 11.4.
▶Mean and variance of a Poisson spike countWorked Example
An auditory-nerve fibre fires at a mean rate λ=80spikes/s. In a T=50ms window, the spike count N is Poisson with parameter μ=λT=80×0.05=4.
Mean:E[N]=μ=4 spikes.
Variance:Var[N]=μ=4 (variance equals mean for Poisson).
Standard deviation:σ=4=2 spikes.
The coefficient of variation is σ/μ=2/4=0.5. Doubling the window to 100 ms gives μ=8, σ=22≈2.83, and CV drops to ≈0.35 — longer counting windows yield more reliable rate estimates.
Joint, marginal, and conditional
When two random variables X and Y appear together we need new tools.
The joint distributionp(x,y) or f(x,y) gives the probability or density of (X,Y) taking the pair (x,y). The marginal distribution of X alone is recovered by summing or integrating out Y:
p(x)=y∑p(x,y),f(x)=∫f(x,y)dy.
The conditional distribution of X given Y=y is
p(x∣y)=p(y)p(x,y),f(x∣y)=f(y)f(x,y).
Two random variables are independent if p(x,y)=p(x)p(y) — i.e. learning the value of one tells you nothing about the other.
These three concepts — joint, marginal, conditional — are the algebraic infrastructure of Bayesian inference. Bayes’ rule rearranges them.
Two more facts that will come up
Linearity of expectation holds with or without independence: E[aX+bY]=aE[X]+bE[Y] for any constants a,b.
Variance is not linear in general — but for independent random variables it adds: Var[X+Y]=Var[X]+Var[Y]. The same identity rescaled: standard deviations do not add for independent sums, but their squares do. This is the algebraic content of “errors add in quadrature.”
⏳The history— Kolmogorov's axioms for probability
For two centuries after Pascal and Fermat’s 1654 correspondence on games of chance, probability was treated as a collection of computational recipes — useful, intuitive, and logically unmoored. The frequentist interpretation (“probability is long-run frequency”) and the Laplacian interpretation (“probability is equally likely cases”) each worked in specific settings but failed in others, and there was no agreed answer to what “probability” meant.
Andrey Kolmogorov’s 1933 monograph Grundbegriffe der Wahrscheinlichkeitsrechnung (Foundations of the Theory of Probability) gave the axiomatic definition that is now standard: a probability is a non-negative, countably-additive measure on a sigma-algebra of events, normalised so that the certain event has measure 1. Random variables are measurable functions on this space; expectations are Lebesgue integrals.
The axiomatisation did three things at once. It unified frequentist and subjective probabilities into a single mathematical object (only the interpretation differs). It connected probability to measure theory and so to the rest of 20th-century analysis. And it provided the formal ground for the convergence theorems (law of large numbers, central limit theorem, martingale convergence) that underwrite all of modern statistical inference.
What we use this for
The vocabulary of this lesson is the prerequisite for everything else in the chapter: