Random Variables

⚡ Key Takeaways

A random variable is a measurable function that assigns a real number to each outcome of a random experiment. Key result in words: it transports probability from an abstract sample space onto the real line, where it is described by a distribution function, mass function, or density. Where it applies: all of probability theory, statistics, statistical physics, finance, information theory, and machine learning. Who/when: crystallized through Chebyshev and Kolmogorov (1933), building on Gauss, Laplace, and the measure theory of Borel and Lebesgue.

💡 The Core Insight

A random variable is the bridge between the messy, problem-specific world of outcomes and the clean, universal world of real numbers. Once you have XX, probability becomes the study of how mass is distributed along R\mathbb{R}. Everything — expectation, variance, independence, convergence — is a statement about that distribution. The sample space becomes scaffolding you can discard.

Formal Statement

DefinitionProbability Space

A probability space is a triple (Ω,F,P)(\Omega, \mathcal{F}, P) where:

  • Ω\Omega is the sample space (set of all outcomes ω\omega),
  • F\mathcal{F} is a σ\sigma-algebra of subsets of Ω\Omega (the events), closed under complement and countable union,
  • P:F→[0,1]P:\mathcal{F}\to[0,1] is a probability measure with P(Ω)=1P(\Omega)=1 and countable additivity.

The axioms of countable additivity read:

1
P ⁣(⋃i=1∞Ai)=∑i=1∞P(Ai),Ai∩Aj=∅ (i≠j).\quad P\!\left(\bigcup_{i=1}^{\infty} A_i\right) = \sum_{i=1}^{\infty} P(A_i), \qquad A_i \cap A_j = \varnothing \ (i\ne j).

Derivation hint: this is Kolmogorov's third axiom; it is an assumption, not a theorem, chosen to make limits of probabilities behave.

DefinitionRandom Variable

A random variable is a function X:Ω→RX:\Omega \to \mathbb{R} that is F\mathcal{F}-measurable: for every x∈Rx\in\mathbb{R},

2
X−1((−∞,x])={ω∈Ω:X(ω)≤x}∈F.\quad X^{-1}\big((-\infty, x]\big) = \{\omega\in\Omega : X(\omega)\le x\} \in \mathcal{F}.

Derivation hint: we require the preimage of every half-line to be an event so that P(X≤x)P(X\le x) makes sense; preimages of all Borel sets then follow because {(−∞,x]}\{(-\infty,x]\} generates the Borel σ\sigma-algebra. Symbols: ω\omega = an outcome; X(ω)X(\omega) = its numerical value; X−1(B)={ω:X(ω)∈B}X^{-1}(B)=\{\omega:X(\omega)\in B\} = preimage; F\mathcal{F} = the events for which probability is defined.

DefinitionDistribution and CDF

The cumulative distribution function (CDF) of XX is

3
FX(x)=P(X≤x)=P({ω:X(ω)≤x}).\quad F_X(x) = P(X\le x) = P\big(\{\omega : X(\omega)\le x\}\big).

Derivation hint: apply PP to the measurable set guaranteed by equation [2]. FXF_X is non-decreasing, right-continuous, with lim⁡x→−∞FX(x)=0\lim_{x\to-\infty}F_X(x)=0 and lim⁡x→+∞FX(x)=1\lim_{x\to+\infty}F_X(x)=1. The law / distribution of XX is the pushforward measure PX(B)=P(X−1(B))P_X(B)=P(X^{-1}(B)) on the Borel sets.

DefinitionDiscrete vs Continuous

Discrete: XX takes values in a countable set; described by a probability mass function (PMF) pX(x)=P(X=x)p_X(x)=P(X=x) with ∑xpX(x)=1\sum_x p_X(x)=1.

(Absolutely) continuous: there exists a probability density function (PDF) fX≥0f_X\ge 0 with

4
FX(x)=∫−∞xfX(t) dt,∫−∞∞fX(t) dt=1.\quad F_X(x) = \int_{-\infty}^{x} f_X(t)\,dt, \qquad \int_{-\infty}^{\infty} f_X(t)\,dt = 1.

Derivation hint: this is the Radon–Nikodym derivative of PXP_X with respect to Lebesgue measure, when it exists; fX=FX′f_X = F_X' wherever FXF_X is differentiable.

TheoremExpectation and Variance

For an integrable random variable, the expectation is

5
E[X]=∫ΩX(ω) dP(ω)=∫−∞∞x dFX(x),\quad \mathbb{E}[X] = \int_{\Omega} X(\omega)\,dP(\omega) = \int_{-\infty}^{\infty} x \, dF_X(x),

Derivation hint: the abstract Lebesgue integral over Ω\Omega equals the Lebesgue–Stieltjes integral over R\mathbb{R} by the change-of-variables (pushforward) theorem. reducing to ∑xx pX(x)\sum_x x\,p_X(x) (discrete) or ∫xfX(x) dx\int x f_X(x)\,dx (continuous). The variance is

6
Var⁡(X)=E[(X−E[X])2]=E[X2]−(E[X])2.\quad \operatorname{Var}(X) = \mathbb{E}\big[(X-\mathbb{E}[X])^2\big] = \mathbb{E}[X^2] - (\mathbb{E}[X])^2.

Derivation hint: expand (X−μ)2=X2−2μX+μ2(X-\mu)^2 = X^2 - 2\mu X + \mu^2 and use linearity of expectation with μ=E[X]\mu=\mathbb{E}[X].

TheoremLaw of the Unconscious Statistician

For a measurable function g:R→Rg:\mathbb{R}\to\mathbb{R},

7
E[g(X)]=∫−∞∞g(x) dFX(x),\quad \mathbb{E}[g(X)] = \int_{-\infty}^{\infty} g(x)\,dF_X(x),

Derivation hint: g(X)g(X) is itself a random variable; apply the pushforward of PP under XX, so no need to know the distribution of g(X)g(X) explicitly.

Why It Holds / Derivation

ProofExpectation as a Distribution Integral

We justify equation [5]: that the integral over the abstract space Ω\Omega equals an integral over R\mathbb{R} using only the law PXP_X. 1. Indicators. For X=1AX = \mathbf{1}_A with A∈FA\in\mathcal{F}, ∫Ω1A dP=P(A)\int_\Omega \mathbf{1}_A\,dP = P(A). As a real-valued variable this XX takes value 11 on AA and 00 elsewhere, and ∫x dFX=0⋅P(Ac)+1⋅P(A)=P(A)\int x\,dF_X = 0\cdot P(A^c) + 1\cdot P(A)=P(A). The identity holds. 2. Simple functions. Let X=∑k=1nak1AkX=\sum_{k=1}^n a_k \mathbf{1}_{A_k} with disjoint AkA_k. By linearity of the integral, ∫ΩX dP=∑kakP(Ak)\int_\Omega X\,dP = \sum_k a_k P(A_k), which equals ∑kak PX({ak})=∫x dFX\sum_k a_k\,P_X(\{a_k\}) = \int x\,dF_X. 3. Non-negative XX. Choose simple functions Xn↑XX_n \uparrow X pointwise. By the Monotone Convergence Theorem, ∫ΩXn dP→∫ΩX dP\int_\Omega X_n\,dP \to \int_\Omega X\,dP, and correspondingly on R\mathbb{R}, giving the identity for non-negative XX. 4. General XX. Write X=X+−X−X = X^+ - X^- with X±≥0X^\pm \ge 0. If at least one of E[X+],E[X−]\mathbb{E}[X^+], \mathbb{E}[X^-] is finite, subtract to obtain equation [5]. ■\blacksquare

∎
mathematician · Andrey Kolmogorov | 1903–1987

Kolmogorov's 1933 monograph Grundbegriffe der Wahrscheinlichkeitsrechnung placed probability on the rigorous footing of measure theory. His decisive move was to define a random variable as a measurable function on an abstract probability space, severing probability from any particular interpretation (frequency, betting, physical) and making it a branch of analysis. This let him prove the strong law of large numbers and the zero–one law with full rigor, and it remains the framework every undergraduate course silently assumes.

Building Intuition

🧠 Intuition

Think of Ω\Omega as a bag of tickets, one per outcome ω\omega, each printed with a number X(ω)X(\omega). Drawing a ticket at random (weighted by PP) and reading its number is the random variable. The measurability condition just says: for any threshold xx, the collection of tickets reading "≤x\le x" is one you're allowed to bet on (it lies in F\mathcal{F}). Now imagine collapsing all tickets with the same number into one pile. The piles, with their total weights, are the distribution. Two utterly different bags (rolling a die vs. spinning a 6-sector wheel) can produce the same piles — hence the same random variable in distribution. This is why we routinely "forget Ω\Omega": all probabilistic questions about XX alone are answered by the pile weights, i.e., by FXF_X.

Figure
CDF and PDF of a continuous random variable: the CDF is the running area under the density.

```svg

Density f(x) and CDF F(x) x f(x) x₀ area = F(x₀) F(x) → 1 F(x₀) F(x): CDF (top) f(x): density (bottom)

```

Worked Examples

ExampleA Fair Die — Discrete

Given: Roll a fair six-sided die. Ω={1,2,3,4,5,6}\Omega=\{1,2,3,4,5,6\}, each outcome probability 1/61/6. Define X(ω)=ωX(\omega)=\omega (the face value).

Steps: 1. PMF: pX(k)=1/6p_X(k)=1/6 for k=1,…,6k=1,\dots,6. 2. Expectation, eqn [5]: E[X]=∑k=16k⋅16=16(1+2+3+4+5+6)=216=3.5\mathbb{E}[X]=\sum_{k=1}^6 k\cdot\tfrac16 = \tfrac{1}{6}(1+2+3+4+5+6)=\tfrac{21}{6}=3.5. 3. E[X2]=16(1+4+9+16+25+36)=916≈15.1667\mathbb{E}[X^2]=\tfrac16(1+4+9+16+25+36)=\tfrac{91}{6}\approx 15.1667. 4. Variance, eqn [6]: Var⁡(X)=916−(3.5)2=15.1667−12.25=2.9167\operatorname{Var}(X)=\tfrac{91}{6}-(3.5)^2 = 15.1667 - 12.25 = 2.9167.

Answer:

E[X]=3.5 (pips),Var⁡(X)=3512≈2.917 (pips2)\boxed{\mathbb{E}[X]=3.5 \text{ (pips)}, \quad \operatorname{Var}(X)=\tfrac{35}{12}\approx 2.917 \text{ (pips}^2)}

:::example[Uniform on [0,2] — Continuous] Given: XX uniform on [0,2][0,2], so fX(x)=12f_X(x)=\tfrac12 for 0≤x≤20\le x\le 2, else 00.

Steps: 1. Check normalization, eqn [4]: ∫0212 dx=1\int_0^2 \tfrac12\,dx = 1. ✓ 2. CDF, eqn [3]: FX(x)=∫0x12 dt=x/2F_X(x)=\int_0^x \tfrac12\,dt = x/2 for 0≤x≤20\le x\le 2. 3. Expectation, eqn [5]: E[X]=∫02x⋅12 dx=12⋅x22∣02=12⋅2=1\mathbb{E}[X]=\int_0^2 x\cdot\tfrac12\,dx = \tfrac12\cdot\tfrac{x^2}{2}\Big|_0^2 = \tfrac12\cdot 2 = 1. 4. E[X2]=∫02x2⋅12 dx=12⋅x33∣02=12⋅83=43\mathbb{E}[X^2]=\int_0^2 x^2\cdot\tfrac12\,dx = \tfrac12\cdot\tfrac{x^3}{3}\Big|_0^2 = \tfrac12\cdot\tfrac{8}{3}=\tfrac{4}{3}. 5. Variance, eqn [6]: Var⁡(X)=43−12=13\operatorname{Var}(X)=\tfrac43 - 1^2 = \tfrac13.

Answer:

E[X]=1 (units),Var⁡(X)=13≈0.333 (units2)\boxed{\mathbb{E}[X]=1 \text{ (units)}, \quad \operatorname{Var}(X)=\tfrac13\approx 0.333 \text{ (units}^2)}

Common Misconceptions

⚠️ Common mistake

"A random variable is a number" — false. It is a function X:Ω→RX:\Omega\to\mathbb{R}. The number appears only after an outcome is drawn. Conflating the function with one of its values causes endless confusion when manipulating expressions like E[X]\mathbb{E}[X] (a fixed number) versus XX (a function).

"Continuous means P(X=x)>0P(X=x)>0 for some xx" — false. For a continuous random variable P(X=a)=0P(X=a)=0 for every single point aa; probability lives in intervals, not points. Density fX(a)f_X(a) is not a probability — it can exceed 11.

"E[g(X)]=g(E[X])\mathbb{E}[g(X)]=g(\mathbb{E}[X])" — generally false (that is Jensen's inequality territory). Equality holds only for affine gg.

CounterexampleA Function That Is Not a Random Variable

Let Ω=[0,1]\Omega=[0,1] but take a coarse σ\sigma-algebra F={∅,[0,12),[12,1],Ω}\mathcal{F}=\{\varnothing, [0,\tfrac12), [\tfrac12,1], \Omega\}. Define X(ω)=ωX(\omega)=\omega. Then {X≤14}=[0,14]\{X\le \tfrac14\}=[0,\tfrac14], which is not in F\mathcal{F}. So XX fails the measurability condition [2] and is not a random variable with respect to this F\mathcal{F} — even though it is a perfectly ordinary function. Measurability is relative to the chosen σ\sigma-algebra, not an intrinsic property of the formula.

Connections

connection

Random variables sit at the hub of probability. The notion of independence is defined via factorization of joint distributions of several random variables, leading to Joint Distributions. Sequences of them and their limiting behavior produce the Law of Large Numbers and Central Limit Theorem. The expectation operator is a special case of the Lebesgue Integration machinery, and the existence of densities invokes the Radon–Nikodym Theorem. The CDF connects to Measure Theory through Lebesgue–Stieltjes measures, and transformations g(X)g(X) link to the Change of Variables formula. Conditioning generalizes to Conditional Expectation as a projection onto a sub-σ\sigma-algebra.

Real-World Applications

🔬 Where this appears

Historical Development

⏳ History
- 1654 — Pascal and Fermat correspond on the "problem of points," computing expected stakes without naming random variables.
- 1713 — Jacob Bernoulli's Ars Conjectandi proves the first law of large numbers for binomial counts.
- 1733/1812 — De Moivre and Laplace develop the normal approximation; Laplace's Théorie analytique systematizes expectations and generating functions.
- 1867 — Chebyshev introduces the inequality bearing his name, treating moments of "variables" rigorously and proving a general LLN.
- 1901–1909 — Lyapunov and Markov sharpen the Central Limit Theorem using characteristic functions of sums of random variables.
- 1902–1904 — Lebesgue's integration theory provides the analytic engine for defining expectation as an integral.
- 1909–1933 — Borel and Fréchet develop measure on abstract spaces, paving the way for measurable functions.
- 1933 — Kolmogorov's Grundbegriffe gives the modern axiomatic definition: a random variable is a measurable function on a probability space.
- 1930s–40s — Doob and Kolmogorov extend the concept to stochastic processes (families of random variables indexed by time).

Subtleties & Limits

open-problem

Beyond the discrete/continuous dichotomy. Many distributions are neither purely discrete nor absolutely continuous. By the Lebesgue decomposition, every distribution splits into a discrete part, an absolutely continuous part, and a singular continuous part (e.g., the Cantor distribution), which has a continuous CDF but no density and assigns probability to a set of Lebesgue measure zero. Undergraduate courses usually ignore the singular part, yet it appears in dynamical systems and fractal models. Open practical questions: how to estimate and simulate from singular distributions efficiently, and how to define meaningful "densities" via Hausdorff measures. More foundationally, in infinite-dimensional settings (e.g., random functions, Gaussian processes) there is no Lebesgue measure, so the Radon–Nikodym viewpoint of equation [4] must be replaced by abstract measure theory — a frontier where measurability, the seemingly pedantic condition [2], becomes genuinely delicate.

See Also

Probability Distributions · Expectation · Variance and Standard Deviation · Cumulative Distribution Function · Law of Large Numbers · Central Limit Theorem · Measure Theory