What do you think?
How many coin flips does it take, on average, to get two Heads in a row?

From events to numbers

So far, we've worked with events: "roll a 6," "draw a red card," "test positive." But often we care about numbers that emerge from random experiments.

Questions like:

  • How many flips until Heads?
  • How many defective items in a batch?
  • How long until the next earthquake?

These questions give numbers, not yes/no answers. This is where random variables enter the picture.

What is a random variable?

Random Variable

A random variable XX is a function that assigns a numerical value to each outcome in a sample space. We write P(X=k)P(X = k) for the probability that XX takes value kk.

Think of a random variable as a "measuring device" for random experiments. Instead of asking "did event A happen?", we ask "what number did we get?"

What do you think?
Which of these is best described by a number rather than a yes/no event?
Let X = number of heads in 3 coin flips. What are the possible values of X? (comma-separated values, e.g. 1, 3, 5)

The probability mass function (PMF)

The PMF tells us the complete probability story of a discrete random variable: the probability of each possible value.

Probability Mass Function

For a discrete random variable XX, the PMF is: pX(k)=P(X=k)p_X(k) = P(X = k)

It satisfies: pX(k)0p_X(k) \geq 0 for all kk, and kpX(k)=1\sum_k p_X(k) = 1.

Think of it as a bar chart of probabilities. Each bar's height represents how likely that value is.

PMF as a Bar Chart

Each bar's height is the probability of that value. All bars sum to 1.

Scenario
X = number of Heads in 3 fair coin flips
0.125
0
0.375
1
0.375
2
0.125
3
P(X = k) = C(3,k) · (½)³
Max P(X=k)
0.375
Values
4
∑ P(X=k)
1.000

Example: flips until first heads

Let XX = number of flips until the first Heads.

What do you think?
What is P(X = 2)? (i.e., first Heads on the second flip)
Enter a decimal, e.g. 0.42

The pattern continues:

  • P(X=1)=1/2P(X = 1) = 1/2 (Heads immediately)
  • P(X=2)=1/4P(X = 2) = 1/4 (Tails, then Heads)
  • P(X=3)=1/8P(X = 3) = 1/8 (Tails, Tails, Heads)
  • P(X=k)=(1/2)kP(X = k) = (1/2)^k

Each probability is half the previous one. This is the geometric distribution.

Explore how the geometric PMF shape changes with different success probabilities, or simulate trials to watch the empirical distribution converge:

Geometric Distribution Explorer
Mode
0.050.95
P(X = k) = (1 − p)k−1 · p
1
2
3
4
5
6
7
8
9
10
11
12
13
14
k (trials until first success)
E[X] = 1/p
3.33
Var(X)
7.78
SD(X)
2.79
P(X > 5)
0.1681
What's P(X = 4) for flips until first Heads? (decimal, e.g. 0.42)
The PMF values must sum to what number? (whole number)

Why this matters

Understanding PMFs lets us:

  • Calculate probabilities of specific outcomes
  • Find expected values (averages)
  • Compare different random quantities

In the next lesson, we'll learn about the Cumulative Distribution Function (CDF), which answers questions like "What's the probability of getting at most 5?"

When you see a probability question about a random variable, the PMF gives you all the individual probabilities. It's the complete specification of the random variable's behavior.