Skip to content
VidiMaster it, module by module
Module 7/Random Variables & Distributions

Random Variables & the Probability Mass Function

A random variable (Definition 12.1) is not a number but a function X:Ω→RX:\Omega\to\mathbb{R} that reads each outcome ω\omega of an experiment and reports a real value X(ω)X(\omega) — the sum of two dice, a gambler's change in wealth, a count. Writing {X∈B}={ω∈Ω:X(ω)∈B}\{X\in B\}=\{\omega\in\Omega:X(\omega)\in B\} turns a question about values into an event with a probability P{X∈B}\mathbb{P}\{X\in B\}, and the whole family of these probabilities is the probability distribution of XX (Definition 12.2). This lesson concentrates on discrete random variables (Definition 12.3), whose values form a finite or countably infinite list that carries all the probability. For them the distribution collapses to a single object, the probability mass function p(k)=P{X=k}p(k)=\mathbb{P}\{X=k\} (Definition 12.4): every probability becomes a sum of masses, P{X∈B}=∑k∈Bp(k)\mathbb{P}\{X\in B\}=\sum_{k\in B}p(k), and a function is a legitimate p.m.f. exactly when it is nonnegative and sums to 11. We build p.m.f.s and read probabilities off them for a pair of dice (Examples 12.1, 12.3), a wealth/payoff game (Examples 12.2, 12.4), and a biased spinner. (Continuous random variables and densities are left for a later lesson.)

Before you start — give these a try

Attempting first primes your brain for the lesson — even if you miss. Nothing is graded or saved; it's just a warm-up.

Which of the following functions is a valid probability mass function (nonnegative and summing to 11)?

Two fair dice are rolled and SS is their sum (3636 equally likely ordered outcomes). Find P{S=8}\mathbb{P}\{S=8\}. Give your answer as a decimal to 33 places.

What you’ll be able to do

  • State Definition 12.1: a random variable is a function X:Ω→RX:\Omega\to\mathbb{R}, taking the value X(ω)X(\omega) at each outcome ω∈Ω\omega\in\Omega, and learn to read an experiment (a pair of dice, a payoff game) through such functions.
  • Interpret the event {X∈B}={ω∈Ω:X(ω)∈B}\{X\in B\}=\{\omega\in\Omega:X(\omega)\in B\} for B⊆RB\subseteq\mathbb{R}, and describe the probability distribution of XX as the family of probabilities P{X∈B}\mathbb{P}\{X\in B\} (Definition 12.2).
  • Recognise a discrete random variable (Definition 12.3) by its finite or countably infinite range {k1,k2,… }⊆R\{k_1,k_2,\dots\}\subseteq\mathbb{R} with ∑iP{X=ki}=1\sum_i\mathbb{P}\{X=k_i\}=1, and identify its possible values.
  • Define and build the probability mass function p(k)=P{X=k}p(k)=\mathbb{P}\{X=k\} (Definition 12.4), and use P{X∈B}=∑k∈Bp(k)\mathbb{P}\{X\in B\}=\sum_{k\in B}p(k) to compute probabilities such as P{X=k}\mathbb{P}\{X=k\} and P{X≤k}\mathbb{P}\{X\le k\}.
  • Test whether a function is a valid p.m.f. by checking nonnegativity (p(k)≥0p(k)\ge 0) and total mass (∑kp(k)=1\sum_k p(k)=1), and solve for a missing mass — using the dice (Examples 12.1, 12.3) and the wealth game (Examples 12.2, 12.4).

In your course

· MATH2015 · Linear Algebra & Probability
§12.1 Random Variables
  • Definition 12.1Random variable
    A random variable is a function X:Ω→RX:\Omega\to\mathbb{R} on a sample space Ω\Omega; its value at ω\omega is X(ω)X(\omega).
  • Definition 12.2Probability distribution
    The collection of probabilities P{X∈B}\mathbb{P}\{X\in B\} for subsets B⊆RB\subseteq\mathbb{R}, where {X∈B}={ω∈Ω:X(ω)∈B}\{X\in B\}=\{\omega\in\Omega:X(\omega)\in B\}.
  • Definition 12.3Discrete random variable
    XX is discrete if its range is finite or countably infinite, {k1,k2,… }⊆R\{k_1,k_2,\dots\}\subseteq\mathbb{R}, with ∑iP{X=ki}=1\sum_i\mathbb{P}\{X=k_i\}=1.
  • Definition 12.4Probability mass function
    p(k)=P{X=k}p(k)=\mathbb{P}\{X=k\} on the possible values of XX; then P{X∈B}=∑k∈Bp(k)\mathbb{P}\{X\in B\}=\sum_{k\in B}p(k). Valid p.m.f.: p(k)≥0p(k)\ge 0 and ∑kp(k)=1\sum_k p(k)=1.
  • Example 12.1A pair of dice: X1,X2,SX_1,X_2,S
    X1(i,j)=iX_1(i,j)=i, X2(i,j)=jX_2(i,j)=j, S=X1+X2S=X_1+X_2; the event {S=8}\{S=8\} has P{S=8}=536\mathbb{P}\{S=8\}=\tfrac{5}{36}.
  • Example 12.2The wealth game
    W=−1W=-1 on {1,2,3}\{1,2,3\}, W=1W=1 on {4}\{4\}, W=3W=3 on {5,6}\{5,6\}; possible values {−1,1,3}\{-1,1,3\}.
  • Example 12.3p.m.f.s of X1X_1 and SS
    pX1(k)=16p_{X_1}(k)=\tfrac16 for k=1,…,6k=1,\dots,6; pSp_S runs 136→636→136\tfrac{1}{36}\to\tfrac{6}{36}\to\tfrac{1}{36}; and P{S<6}=1036\mathbb{P}\{S<6\}=\tfrac{10}{36}.
  • Example 12.4p.m.f. of the wealth game
    pW(−1)=12, pW(1)=16, pW(3)=13p_W(-1)=\tfrac12,\ p_W(1)=\tfrac16,\ p_W(3)=\tfrac13.
Continuous random variables and probability density functions (Definition 12.5 onward in §12.1) are treated in a separate lesson; this lesson covers only the discrete case.
1

Random variables: functions on the sample space

A random variable (Definition 12.1) is neither a varying number nor random on its own — it is a function X:Ω→RX:\Omega\to\mathbb{R} that attaches a real number X(ω)X(\omega) to every outcome ω\omega of an experiment. The randomness lives entirely in which outcome ω∈Ω\omega\in\Omega the experiment produces; once ω\omega is fixed, the value X(ω)X(\omega) is completely determined. By convention random variables wear uppercase letters X,Y,ZX,Y,Z, while X(ω)X(\omega) denotes the value at a sample point. For a pair of dice, Ω={(i,j):i,j∈{1,…,6}}\Omega=\{(i,j):i,j\in\{1,\dots,6\}\}, and we may define X1(i,j)=iX_1(i,j)=i (first die), X2(i,j)=jX_2(i,j)=j (second die), and S(i,j)=X1(i,j)+X2(i,j)=i+jS(i,j)=X_1(i,j)+X_2(i,j)=i+j (the sum); for the outcome (5,1)(5,1) these give X1=5X_1=5, X2=1X_2=1, S=6S=6. A random variable thus repackages raw outcomes into the number we actually care about — a total, a payoff, a count — converting an experiment about dice faces into one about sums.

2

Events $\{X\in B\}$ and the probability distribution

Because XX is a function, we can ask how likely it is to land in a target set. For a subset B⊆RB\subseteq\mathbb{R}, the shorthand {X∈B}\{X\in B\} (read 'XX lies in BB') names the event consisting of every outcome whose XX-value falls in BB: {X∈B}={ω∈Ω:X(ω)∈B}.\{X\in B\}=\{\omega\in\Omega:X(\omega)\in B\}. Since this is a genuine subset of Ω\Omega, it is an event in F\mathcal{F} and carries a probability P{X∈B}\mathbb{P}\{X\in B\} inherited from the underlying probability space. Useful special cases are {X=k}\{X=k\} (take B={k}B=\{k\}) and {X≤k}\{X\le k\} (take B=(−∞,k]B=(-\infty,k]). The probability distribution of XX (Definition 12.2) is the entire collection of these numbers P{X∈B}\mathbb{P}\{X\in B\} as BB ranges over subsets of R\mathbb{R} — a complete description of how XX spreads its probability along the real line. For the dice sum, {S=8}\{S=8\} collects (2,6),(3,5),(4,4),(5,3),(6,2)(2,6),(3,5),(4,4),(5,3),(6,2), so P{S=8}=536\mathbb{P}\{S=8\}=\tfrac{5}{36}.

3

Discrete random variables

A random variable is discrete (Definition 12.3) when its range — the set of values it can take — is finite or countably infinite, say {k1,k2,… }⊆R\{k_1,k_2,\dots\}\subseteq\mathbb{R}, and these values carry all the probability: ∑iP{X=ki}=1.\sum_i \mathbb{P}\{X=k_i\}=1. The values kk with P{X=k}>0\mathbb{P}\{X=k\}>0 are the possible values of XX. Discreteness is exactly what makes exact, by-hand computation possible: a discrete XX places all of its probability on a list of isolated points, so any probability about XX is a sum over those points, never an integral. The sum of two dice (S∈{2,…,12}S\in\{2,\dots,12\}) and the wealth change (W∈{−1,1,3}W\in\{-1,1,3\}) are discrete with finite range; a quantity that can in principle grow without bound (such as the number of tosses until the first head) is discrete with countably infinite range. Continuous random variables — whose probability is smeared over intervals and found by integration — are the subject of a later lesson.

4

The probability mass function (p.m.f.)

For a discrete XX the whole distribution is captured by one function. The probability mass function (p.m.f., Definition 12.4) is p(k)=P{X=k},p(k)=\mathbb{P}\{X=k\}, defined on the possible values of XX: it records how much probability 'mass' sits at each point. Knowing the p.m.f. is knowing everything, because for any set B⊆RB\subseteq\mathbb{R} P{X∈B}=∑k∈Bp(k),\mathbb{P}\{X\in B\}=\sum_{k\in B}p(k), so every probability about XX is read off by summing masses (for instance P{X≤k}=∑j≤kp(j)\mathbb{P}\{X\le k\}=\sum_{j\le k}p(j)). A function pp is a valid p.m.f. precisely when it meets two conditions mirroring the probability axioms: it is nonnegative, p(k)≥0p(k)\ge 0 for every kk (a probability is never negative), and it has total mass one, ∑kp(k)=1\sum_k p(k)=1 (all the probability is accounted for). Any pp meeting both defines a legitimate discrete random variable; fail either and it is not a p.m.f. For example the first die has pX1(k)=16p_{X_1}(k)=\tfrac16 for k=1,…,6k=1,\dots,6 (six masses of 16\tfrac16 summing to 11), and the wealth game has pW(−1)=12, pW(1)=16, pW(3)=13p_W(-1)=\tfrac12,\ p_W(1)=\tfrac16,\ p_W(3)=\tfrac13.

Definition 12.1 — Random variable

Let Ω\Omega be a sample space. A random variable is a function X:Ω→RX:\Omega\to\mathbb{R}. Its value at a sample point ω∈Ω\omega\in\Omega is written X(ω)X(\omega), and random variables are denoted by uppercase letters such as XX, YY, ZZ.

Intuition. A random variable is a fixed rule that reads each outcome and reports a number; nothing about the function is random. The uncertainty is inherited from the outcome ω\omega that the experiment selects. This is what lets us replace an unwieldy outcome (a pair of dice faces) by the quantity we care about (their sum).
Definition 12.2 — Probability distribution

For a random variable XX and a subset B⊆RB\subseteq\mathbb{R}, the set {X∈B}={ω∈Ω:X(ω)∈B}\{X\in B\}=\{\omega\in\Omega:X(\omega)\in B\} is an event with probability P{X∈B}\mathbb{P}\{X\in B\}. The probability distribution of XX is the collection of all these probabilities P{X∈B}\mathbb{P}\{X\in B\}, taken over subsets B⊆RB\subseteq\mathbb{R}.

Intuition. The distribution answers every question of the form 'how likely is XX to fall in here?' at once. It transfers the probability measure from the original sample space onto the real line, describing where XX places its weight irrespective of the mechanism that produced the outcome.
Definition 12.3 — Discrete random variable

A random variable XX is discrete if its range is a finite or countably infinite set {k1,k2,… }⊆R\{k_1,k_2,\dots\}\subseteq\mathbb{R} and ∑iP{X=ki}=1\sum_i\mathbb{P}\{X=k_i\}=1. The values kk for which P{X=k}>0\mathbb{P}\{X=k\}>0 are the possible values of XX.

Intuition. Discrete means the probability sits on a countable list of separated points, and the point masses together account for all of the probability. This is exactly the setting in which probabilities are computed by adding finitely or countably many numbers rather than by calculus.
Definition 12.4 — Probability mass function

The probability mass function (p.m.f.) of a discrete random variable XX is p(k)=P{X=k}p(k)=\mathbb{P}\{X=k\}, defined on the possible values of XX. For any subset B⊆RB\subseteq\mathbb{R}, P{X∈B}=∑k∈Bp(k)\mathbb{P}\{X\in B\}=\sum_{k\in B}p(k). A function is a valid p.m.f. iff p(k)≥0p(k)\ge 0 for all kk and ∑kp(k)=1\sum_k p(k)=1.

Intuition. The p.m.f. lists the probability mass at each possible value, and every probability about XX is obtained by summing the relevant masses. Its two defining properties — nonnegative, and total mass one — are precisely the fingerprints of a probability measure restricted to the values of XX.

Worked examples

Example 1

Examples 12.2 & 12.4 (the wealth game). A fair die is rolled. The player's wealth changes by −1-1 if the outcome is 11, 22, or 33; by +1+1 if it is 44; and by +3+3 if it is 55 or 66. Let WW be the change in wealth. Describe WW as a random variable, find its probability mass function, check that it is valid, and compute P{W>0}\mathbb{P}\{W>0\}.

  1. 1

    WW as a function on Ω\Omega. The sample space is Ω={1,2,3,4,5,6}\Omega=\{1,2,3,4,5,6\}, and the payoff rule defines W(1)=W(2)=W(3)=−1W(1)=W(2)=W(3)=-1, W(4)=1W(4)=1, W(5)=W(6)=3W(5)=W(6)=3 — a function W:Ω→RW:\Omega\to\mathbb{R}, hence a random variable.

  2. 2

    Possible values. WW takes the values {−1,1,3}\{-1,1,3\}, so it is discrete with finite range.

  3. 3

    Collect outcomes for each value. {W=−1}={1,2,3}\{W=-1\}=\{1,2,3\}, {W=1}={4}\{W=1\}=\{4\}, {W=3}={5,6}\{W=3\}=\{5,6\}. The die is fair, so each face has probability 16\tfrac16 and P{W=k}=16×(number of faces giving k)\mathbb{P}\{W=k\}=\tfrac16\times(\text{number of faces giving }k).

  4. 4

    The p.m.f. pW(−1)=36=12p_W(-1)=\tfrac{3}{6}=\tfrac12,   pW(1)=16\;p_W(1)=\tfrac16,   pW(3)=26=13\;p_W(3)=\tfrac{2}{6}=\tfrac13.

  5. 5

    Validity check. All three masses are ≥0\ge 0, and 12+16+13=3+1+26=66=1\tfrac12+\tfrac16+\tfrac13=\tfrac{3+1+2}{6}=\tfrac66=1, so pWp_W is a valid p.m.f.

  6. 6

    P{W>0}\mathbb{P}\{W>0\}. Take B=(0,∞)B=(0,\infty), which catches the values 11 and 33: P{W>0}=pW(1)+pW(3)=16+13=1+26=12\mathbb{P}\{W>0\}=p_W(1)+p_W(3)=\tfrac16+\tfrac13=\tfrac{1+2}{6}=\tfrac12.

Answer. pW(−1)=12, pW(1)=16, pW(3)=13p_W(-1)=\tfrac12,\ p_W(1)=\tfrac16,\ p_W(3)=\tfrac13 (nonnegative and summing to 11), and P{W>0}=16+13=12=0.5\mathbb{P}\{W>0\}=\tfrac16+\tfrac13=\tfrac12=0.5.
Example 2

Examples 12.1 & 12.3 (a pair of dice). Two fair dice are rolled, with Ω={(i,j):i,j∈{1,…,6}}\Omega=\{(i,j):i,j\in\{1,\dots,6\}\} (3636 equally likely outcomes). Let S(i,j)=i+jS(i,j)=i+j be the sum. Find the probability mass function of SS, and use it to compute P{S=8}\mathbb{P}\{S=8\} and P{S<6}\mathbb{P}\{S<6\}.

Example 3

A biased spinner. A spinner shows one of the numbers 1,2,3,41,2,3,4. It lands on 11 with probability 18\tfrac18, on 22 with probability 14\tfrac14, on 33 with probability 18\tfrac18, and on 44 with the remaining probability. Let XX be the number shown. Find pX(4)p_X(4), confirm pXp_X is a valid p.m.f., and compute P{X≥3}\mathbb{P}\{X\ge 3\}.