Skip to content

Random Variables

Attempt these from memory before reading.

  • What does it mean for X:Ω→RX : \Omega \to \mathbb{R} to be a random variable? Which part is the “random” part?
  • State three properties of a cumulative distribution function.
  • What is the difference between a discrete and a continuous random variable?
  • Name a distribution that is neither.
  • What is a moment generating function, and what is it for?

Check your answers against the text. The first prompt is the one most people answer wrongly — the randomness is in Ω\Omega and PP, not in XX.

Motivation: a random variable is not random

Section titled “Motivation: a random variable is not random”

The name is a historical accident, and it causes real confusion. A random variable is a deterministic function from the sample space to the real numbers. Nothing about it is random.

The randomness lives in the outcome: roll a die and you get a number, and the number is whatever the physics gave you. The function XX is the bookkeeping that turns the outcome into a quantity you care about. If the outcome is ω=\omega = “rolled a four”, then X(ω)=4X(\omega) = 4 is certain once ω\omega is known — it is ω\omega that was uncertain.

Why measurability is the definition. Writing P(X≤x)P(X \le x) is shorthand for P({ω:X(ω)≤x})P(\{\omega : X(\omega) \le x\}), and that set has to be in F\mathcal{F} or the probability is undefined. So XX must be measurable: preimages of Borel sets must be events. That single requirement is the whole definition, and it is not technicality for its own sake — it is what stops you asking probability questions about sets that cannot be measured (recall the Vitali set from Probability Spaces).

Why this matters for what follows. Everything on this page — distribution functions, densities, moments — is a statement about the pushforward of PP by XX. A random variable transports probability from the sample space onto the real line, and the CDF records where it landed.

Definition. A random variable is a measurable function X:Ω→RX : \Omega \to \mathbb{R}. The cumulative distribution function (CDF) of XX is

FX(x)=P(X≤x)F_X(x) = P(X \leq x)

Proposition 2.1 (Properties of the CDF).

  1. FF is non-decreasing: if a≤ba \leq b Then F(a)≤F(b)F(a) \leq F(b).
  2. lim⁡x→−∞F(x)=0\lim_{x \to -\infty} F(x) = 0 and lim⁡x→+∞F(x)=1\lim_{x \to +\infty} F(x) = 1.
  3. FF is right-continuous: lim⁡x→a+F(x)=F(a)\lim_{x \to a^+} F(x) = F(a).

Proof. (1) If a≤ba \leq b Then {X≤a}⊆{X≤b}\{X \leq a\} \subseteq \{X \leq b\} So F(a)=P(X≤a)≤P(X≤b)=F(b)F(a) = P(X \leq a) \leq P(X \leq b) = F(b) by Proposition 1.1(3).

(2) As x→−∞x \to -\infty The events {X≤x}\{X \leq x\} decrease to ∅\emptyset So by continuity from above of probability measures, F(x)→0F(x) \to 0. As x→+∞x \to +\infty The events increase to Ω\Omega So F(x)→1F(x) \to 1.

(3) As x→a+x \to a^+ The events {X≤x}\{X \leq x\} decrease to {X≤a}\{X \leq a\} Giving right-continuity. ■\blacksquare

A random variable is discrete if its range is countable. The probability mass function (PMF) is pX(x)=P(X=x)p_X(x) = P(X = x).

Definition (Expected Value). For a discrete random variable:

E[X]=∑xx pX(x)E[X] = \sum_{x} x\, p_X(x)

Provided the sum converges absolutely.

Definition (Variance). Var(X)=E[(X−μ)2]=E[X2]−(E[X])2\mathrm{Var}(X) = E[(X - \mu)^2] = E[X^2] - (E[X])^2 where μ=E[X]\mu = E[X].

Proposition 2.2 (Linearity of Expectation). E[aX+bY]=aE[X]+bE[Y]E[aX + bY] = aE[X] + bE[Y] for any random variables XX, YY and constants aa, bb.

Proof. Direct computation from the definition of expected value. For the discrete case:

E[aX+bY]=∑x,y(ax+by) pX,Y(x,y)=a∑xx pX(x)+b∑yy pY(y)=aE[X]+bE[Y]E[aX + bY] = \sum_{x,y} (ax + by)\, p_{X,Y}(x,y) = a\sum_x x\, p_X(x) + b\sum_y y\, p_Y(y) = aE[X] + bE[Y]

■\blacksquare

A random variable is continuous if its CDF is absolutely continuous, i.e., there exists a probability density function (PDF) fXf_X such that

FX(x)=∫−∞xfX(t) dtF_X(x) = \int_{-\infty}^{x} f_X(t)\, dt

Key properties:

  1. fX(x)≥0f_X(x) \geq 0 for all xx.
  2. ∫−∞∞fX(x) dx=1\int_{-\infty}^{\infty} f_X(x)\, dx = 1.
  3. P(a≤X≤b)=∫abfX(x) dxP(a \leq X \leq b) = \int_a^b f_X(x)\, dx.
  4. P(X=a)=0P(X = a) = 0 for any single point aa.

Discrete distributions:

DistributionPMFE[X]E[X]Var(X)\mathrm{Var}(X)
Bernoulli(p)(p)px(1−p)1−xp^x(1-p)^{1-x}, x∈{0,1}x \in \{0,1\}ppp(1−p)p(1-p)
Binomial(n,p)(n,p)(nx)px(1−p)n−x\binom{n}{x}p^x(1-p)^{n-x}npnpnp(1−p)np(1-p)
Poisson(λ)(\lambda)e−λλx/x!e^{-\lambda}\lambda^x / x!λ\lambdaλ\lambda
Geometric(p)(p)(1−p)x−1p(1-p)^{x-1}p, x≥1x \geq 11/p1/p(1−p)/p2(1-p)/p^2

Continuous distributions:

DistributionPDFE[X]E[X]Var(X)\mathrm{Var}(X)
Uniform(a,b)(a,b)1/(b−a)1/(b-a) on [a,b][a,b](a+b)/2(a+b)/2(b−a)2/12(b-a)^2/12
Exponential(λ)(\lambda)λe−λx\lambda e^{-\lambda x}, x≥0x \geq 01/λ1/\lambda1/λ21/\lambda^2
N(μ,σ2)N(\mu, \sigma^2)1σ2πe−(x−μ)2/(2σ2)\frac{1}{\sigma\sqrt{2\pi}}e^{-(x-\mu)^2/(2\sigma^2)}μ\muσ2\sigma^2

Definition. X∼N(μ,σ2)X \sim N(\mu, \sigma^2) if XX has PDF f(x)=1σ2πexp⁡(−(x−μ)22σ2)f(x) = \frac{1}{\sigma\sqrt{2\pi}}\exp\left(-\frac{(x-\mu)^2}{2\sigma^2}\right).

Theorem 2.3 (Standardisation). If X∼N(μ,σ2)X \sim N(\mu, \sigma^2) Then Z=(X−μ)/σ∼N(0,1)Z = (X - \mu)/\sigma \sim N(0, 1).

Proof. The CDF of ZZ: P(Z≤z)=P(X≤μ+σz)=∫−∞μ+σz1σ2πe−t2/2 dtP(Z \leq z) = P(X \leq \mu + \sigma z) = \int_{-\infty}^{\mu + \sigma z} \frac{1}{\sigma\sqrt{2\pi}} e^{-t^2/2}\, dt. Substituting u=(t−μ)/σu = (t - \mu)/\sigma: =∫−∞z12πe−u2/2 du= \int_{-\infty}^{z} \frac{1}{\sqrt{2\pi}} e^{-u^2/2}\, du Which is the CDF of N(0,1)N(0, 1). ■\blacksquare

Theorem 2.4 (Moment Generating Function). If X∼N(μ,σ2)X \sim N(\mu, \sigma^2) Then

MX(t)=E[etX]=exp⁡(μt+σ2t22)M_X(t) = E[e^{tX}] = \exp\left(\mu t + \frac{\sigma^2 t^2}{2}\right)

Proof. MX(t)=∫−∞∞etx1σ2πe−(x−μ)2/(2σ2) dxM_X(t) = \int_{-\infty}^{\infty} e^{tx} \frac{1}{\sigma\sqrt{2\pi}} e^{-(x-\mu)^2/(2\sigma^2)}\, dx. Completing the square in the exponent and evaluating the Gaussian integral gives the result. ■\blacksquare

Definition. The moment generating function (MGF) of XX is MX(t)=E[etX]M_X(t) = E[e^{tX}] (when it exists in a neighbourhood of t=0t = 0).

Theorem 2.5. If the MGF exists in a neighbourhood of 0, it uniquely determines the distribution. Furthermore, E[Xn]=MX(n)(0)E[X^n] = M_X^{(n)}(0).

A random variable is a function that converts uncertain outcomes into numbers, making it possible to compute averages, variances, and probabilities of numerical events. The cumulative distribution function FX(x)=P(X≤x)F_X(x) = P(X \leq x) tells you the probability that XX falls at or below a given value, and it completely determines the distribution of XX. For discrete random variables, the probability mass function gives the probability at each point. For continuous random variables, the probability density function gives the “rate” at which probability accumulates, and probabilities are computed by integrating.

Expected value is the long-run average: if you repeated an experiment infinitely many times and averaged the results, the expected value is what you would converge to. Variance measures spread around the mean. The normal distribution is special because the central limit theorem shows that sums of many independent random variables, regardless of their original distribution, tend toward a normal distribution. Moment generating functions encode all moments of a distribution into a single function, and they convert the hard operation of convolution (adding independent random variables) into the easy operation of multiplication.

Problem. Let X∼Poisson(3)X \sim \mathrm{Poisson}(3) and Y∼Poisson(5)Y \sim \mathrm{Poisson}(5) be independent. Find the distribution of X+YX + Y.

Solution

The MGF of X∼Poisson(λ)X \sim \mathrm{Poisson}(\lambda) is MX(t)=eλ(et−1)M_X(t) = e^{\lambda(e^t - 1)}.

MX+Y(t)=MX(t)⋅MY(t)=e3(et−1)⋅e5(et−1)=e8(et−1)M_{X+Y}(t) = M_X(t) \cdot M_Y(t) = e^{3(e^t - 1)} \cdot e^{5(e^t - 1)} = e^{8(e^t - 1)}.

This is the MGF of Poisson(8)\mathrm{Poisson}(8). Since the MGF uniquely determines the distribution, X+Y∼Poisson(8)X + Y \sim \mathrm{Poisson}(8).

■\blacksquare

Worked Example: Minimum of Exponential Random Variables

Solution. Let X1,…,XnX_1, \ldots, X_n be independent with Xi∼Exp(λi)X_i \sim \mathrm{Exp}(\lambda_i). Find the distribution of M=min⁡(X1,…,Xn)M = \min(X_1, \ldots, X_n).

P(M>t)=P(X1>t,…,Xn>t)=∏i=1nP(Xi>t)=∏i=1ne−λit=e−(λ1+⋯+λn)tP(M > t) = P(X_1 > t, \ldots, X_n > t) = \prod_{i=1}^{n} P(X_i > t) = \prod_{i=1}^{n} e^{-\lambda_i t} = e^{-(\lambda_1 + \cdots + \lambda_n)t}

So P(M≤t)=1−e−λtP(M \leq t) = 1 - e^{-\lambda t} where λ=∑i=1nλi\lambda = \sum_{i=1}^{n} \lambda_i. This means M∼Exp(λ)M \sim \mathrm{Exp}(\lambda). ■\blacksquare

DistributionCDFDensity?MGF near 0?The point
Bernoullistepno (atoms)yesthe discrete case
Normalsmoothyes, e−x2/2e^{-x^2/2}yesthe continuous case everyone knows
Cantorcontinuousnodivergesneither discrete nor continuous
Cauchysmoothyes, 1π(1+x2)\frac{1}{\pi(1+x^2)}noa density with no moments
δ0\delta_0 (point mass)step at 0noyesdegenerate but legal

The Cantor distribution is the one to remember. Take XX uniform on the Cantor set: its CDF is the Cantor function, which is continuous everywhere and constant on the complement of the Cantor set. So XX is not discrete — it takes uncountably many values — and not continuous — there is no density with respect to Lebesgue measure. It is singular, and it is the reason the discrete/continuous dichotomy is a simplification rather than a theorem.

The Cauchy is the one that bites in practice. It has a perfectly good density, so it is a legitimate continuous random variable, and its moment generating function does not exist in any neighbourhood of zero because the moments themselves are infinite. Any argument that starts “take the MGF of…” silently assumes the moments exist. That assumption fails for the most famous heavy-tailed distribution in statistics.

Mistake 1: Confusing P(A∣B)P(A|B) with P(B∣A)P(B|A). The conditional probability P(A∣B)=P(A∩B)/P(B)P(A|B) = P(A \cap B)/P(B) is not the same as P(B∣A)=P(A∩B)/P(A)P(B|A) = P(A \cap B)/P(A). These are equal only when P(A)=P(B)P(A) = P(B). A common error is to assume that if P(A∣B)P(A|B) is high, then P(B∣A)P(B|A) is also high. This is the basis of the prosecutor’s fallacy.

Mistake 2: Assuming that independence implies uncorrelatedness. If two random variables XX and YY are independent, then they are uncorrelated (their covariance is zero). However, the converse is not true: uncorrelated variables can be dependent. For example, let XX be uniform on {−1,0,1}\{-1, 0, 1\} and Y=X2Y = X^2. Then XX and YY are uncorrelated but not independent.

Mistake 3: Forgetting Bayes’ theorem. Bayes’ theorem states that P(A∣B)=P(B∣A)P(A)/P(B)P(A|B) = P(B|A)P(A)/P(B). A common mistake is to ignore the prior P(A)P(A) and the evidence P(B)P(B), leading to incorrect updates of probabilities. Always use the full form of Bayes’ theorem when updating beliefs based on new evidence.

Mistake 4: Confusing the expectation of a product with the product of expectations. E[XY]=E[X]E[Y]E[XY] = E[X]E[Y] holds only when XX and YY are independent (or uncorrelated). as a rule, E[XY]≠E[X]E[Y]E[XY] \neq E[X]E[Y]. Do not assume that the expectation of a product factors without checking independence.

Mistake 5: Forgetting that variance is not linear. Var(aX+b)=a2Var(X)\mathrm{Var}(aX + b) = a^2 \mathrm{Var}(X), not aVar(X)+ba \mathrm{Var}(X) + b. The variance of a sum is Var(X+Y)=Var(X)+Var(Y)+2Cov(X,Y)\mathrm{Var}(X + Y) = \mathrm{Var}(X) + \mathrm{Var}(Y) + 2\mathrm{Cov}(X, Y). If XX and YY are independent, then Var(X+Y)=Var(X)+Var(Y)\mathrm{Var}(X + Y) = \mathrm{Var}(X) + \mathrm{Var}(Y), but this does not hold as a rule.