Mathematics.

foundations of probability

Random Variables

Probability30 minDifficulty4 out of 10

You should know: sample space, functions

Overview

A random variable is a mathematical formalization of a quantity or object which depends on random events. The term 'random variable' in its mathematical definition refers to neither randomness nor variability but instead is a function whose domain is the set of possible outcomes in a sample space and whose range is typically a subset of the real numbers. A random variable lets us attach a number to every outcome of an experiment, so we can apply arithmetic, calculus, and statistics to what would otherwise just be abstract outcomes.

Intuition

A sample space can contain outcomes that aren't numbers at all — {Heads, Tails}, or a deck of cards. A random variable is the bridge that converts those outcomes into numbers so we can do math with them: 'let X be the number of heads in 3 coin flips' assigns the number 0, 1, 2, or 3 to every possible sequence of flips. Once outcomes become numbers, you can ask for averages, spreads, and probabilities of numeric ranges — questions that don't even make sense on raw outcomes like 'Heads'.

Interactive Graph

The distribution of a random variable

Loading visualization…

Formal Definition

Definition

A random variable X is a measurable function from a sample space Ω to a measurable space E (usually the real numbers ℝ). For a set S of possible values, the probability that X falls in S is defined via the underlying probability measure on Ω:

X ⁣:ΩEX \colon \Omega \to E

X maps each outcome ω in the sample space to a value in E

Random variable
E=R,X ⁣:ΩRE = \mathbb{R}, \quad X \colon \Omega \to \mathbb{R}

Most commonly, E is the set of real numbers

P(XS)=P({ωΩX(ω)S})P(X \in S) = P(\{\omega \in \Omega \mid X(\omega) \in S\})

The probability that X takes a value in S is the probability of the set of outcomes mapping into S

Induced probability
P(X=2)=P({ω:X(ω)=2})P(X = 2) = P(\{\omega : X(\omega) = 2\})

A common shorthand: the probability that X equals a specific value

Notation

NotationMeaning
XXA random variable (capital letters denote random variables, lowercase their realized values)
xxA specific value that X can take
P(X=x)P(X = x)The probability mass function value for a discrete random variable
fX(x)f_X(x)The probability density function of a continuous random variable X
FX(x)=P(Xx)F_X(x) = P(X \le x)The cumulative distribution function (CDF) of X

Properties

Discrete vs. continuous

X is discrete if it takes countably many values (described by a PMF); continuous if described by a PDF over an interval\text{X is discrete if it takes countably many values (described by a PMF); continuous if described by a PDF over an interval}

CDF is non-decreasing

x1<x2    FX(x1)FX(x2)x_1 < x_2 \implies F_X(x_1) \le F_X(x_2)

PMF normalization

xP(X=x)=1\sum_x P(X=x) = 1

Condition: for discrete X

PDF normalization

fX(x)dx=1\int_{-\infty}^{\infty} f_X(x)\,dx = 1

Condition: for continuous X

Applications

Signal processing models noise and signal amplitudes as random variables to design filters and estimate error rates.

Worked Examples

  1. Sample space: Ω = {HH, HT, TH, TT}, each with probability 1/4.

    X(HH)=2, X(HT)=1, X(TH)=1, X(TT)=0X(HH)=2,\ X(HT)=1,\ X(TH)=1,\ X(TT)=0
  2. Group outcomes by the value of X.

    P(X=0)=14,P(X=1)=24=12,P(X=2)=14P(X=0)=\tfrac14,\quad P(X=1)=\tfrac24=\tfrac12,\quad P(X=2)=\tfrac14

Answer: PMF: P(X=0)=1/4, P(X=1)=1/2, P(X=2)=1/4.

Practice Problems

Difficulty 3/10

A fair six-sided die is rolled; let X be the value shown. What is P(X ≤ 4)?

Difficulty 4/10

Which best describes the difference between a discrete and a continuous random variable?

Difficulty 5/10

Classify each as a discrete or continuous random variable: (a) number of cars passing a toll in an hour, (b) the exact wait time until the next car, (c) daily rainfall in mm.

Common Mistakes

Common Mistake

Thinking P(X=x) is meaningful and nonzero for a continuous random variable at any specific x.

For continuous random variables, P(X=x) = 0 for any single point x; only probabilities over intervals, like P(a ≤ X ≤ b), are meaningful (computed by integrating the PDF).

Common Mistake

Confusing the random variable X (a function) with its realized numeric value x (an outcome).

X is the mapping from outcomes to numbers; x is a particular number X might equal. This is why we write P(X=x), not P(x=x).

Quiz

A DISCRETE random variable is described by its:
Which is a CONTINUOUS random variable?

Summary

  • A random variable X is a function from the sample space Ω to the real numbers.
  • Discrete random variables are described by a probability mass function (PMF); continuous ones by a probability density function (PDF).
  • The cumulative distribution function F_X(x) = P(X ≤ x) is non-decreasing and works for both discrete and continuous variables.
  • For continuous random variables, individual points have probability zero — only intervals carry positive probability.
  • Random variables let us apply algebra, calculus, and statistics to the outcomes of random experiments.

References