Statistics 🔔 Random Variables & Distributions

Random Variables and Their Distributions

Turning random outcomes into numbers you can add up, average, and reason about.

Intro StatisticsAP Statistics level
💡
The big idea: A random variable is just a rule that pins a number onto every outcome of a random process — heads becomes 1, tails becomes 0, a die shows its face. Once outcomes are numbers, you can describe how the numbers are spread out (its probability distribution) and boil the whole thing down to a single balance point: the expected value. That move — outcome to number to distribution to a mean — is the engine behind almost everything that follows in statistics.
🎯 By the end, you'll be able to
  • Explain what a random variable is and how it turns outcomes into numbers
  • Tell the difference between discrete and continuous random variables
  • Read a probability mass function (PMF) and check that its probabilities sum to 1
  • Set up and compute the expected value E[X] as a probability-weighted average
📎 You should already know
  • Basic probability: outcomes and probabilities between 0 and 1
  • Mean of a list of numbers

From outcomes to numbers

Flip a coin. The outcome is heads or tails — words, not numbers. But statistics runs on arithmetic, so we need a way to turn those words into something we can add and average.

A random variable does exactly that: it is a rule that attaches a number to every possible outcome. Call heads 1 and tails 0, and now the flip has a numeric value. Roll a die and the random variable might just be the face shown, 1 through 6. Once outcomes are numbers, we can ask numeric questions: what value do we get on average? how spread out are the values?

By convention we name a random variable with a capital letter like X, and a specific value it can take with a lowercase letter, so \( P(X = x) \) reads as the probability that X comes out equal to x.

🔑 What a random variable is
A random variable is a rule that assigns a number to each outcome of a random process. It does not predict the outcome — the process is still random — it just relabels each possible outcome with a number so we can do arithmetic with it.

Two flavors: discrete and continuous

Random variables come in two kinds, and the difference is about what values they can land on.

  • A discrete random variable takes values you can list or count — often whole numbers. The number of heads in ten flips (0, 1, 2, ... , 10) or the face of a die (1 to 6) are discrete. There are gaps between the allowed values.
  • A continuous random variable can take any value in a range, with no gaps — like the exact height of a randomly chosen adult, or the time until a bus arrives. Between any two values there is always another possible value.

This lesson focuses on the discrete case, because there the whole distribution can be written as a simple table of values and their probabilities.

⚠️ Countable, not just 'a number'
The word that separates the two kinds is countable. A shoe size like 9.5 is still discrete — the possible sizes come in fixed steps. What makes something continuous is that it can slide to any value in between, so no list can capture every possibility.

The probability distribution of a discrete variable

For a discrete random variable, its probability distribution lists each value it can take alongside the probability of that value. This list is called a probability mass function, or PMF. You can write it as a table or draw it as a bar chart, one bar per value, where each bar's height is its probability.

Two rules make a PMF legitimate, and they are the same two rules any set of probabilities must obey:

  • Every probability is between 0 and 1.
  • The probabilities of all the possible values add up to exactly 1 — some outcome must happen.
\[ \sum_{i} P(X = x_i) = 1 \]
Total-probability rule: across all the values a discrete random variable can take, the probabilities sum to 1.

See it: build a distribution and find its balance point

The tool below is a weighted die whose six outcomes are the values 1 through 6. Drag the weight sliders to make some faces more likely than others; the bars are the probabilities, and they are automatically rescaled so they always sum to 1 — a live PMF you build by hand.

Watch the little triangle under the axis. It marks E[X], the mean of the distribution, and it sits exactly where the bars would balance if they were weights on a seesaw. Pile weight onto the high faces and the balance point slides right; make it symmetric and it settles in the middle at 3.5. The shaded band shows one standard deviation on either side of that balance point.

🎮 Interactive: a discrete distribution and its balance point LIVE
Set the relative weight of each outcome (1 to 6). The bars are the probabilities, always summing to 1. The triangle marks the mean E[X] — the point where the distribution balances — and the shaded band is one standard deviation around it.
✨ The mean is a balance point, not the most likely value
The expected value is where the distribution balances — a center of mass, not necessarily an outcome you will ever see. A fair die has E[X] = 3.5, yet you can never roll a 3.5. And the balance point need not be the tallest bar: pushing weight far out to one side drags the mean toward it even if a different value stays most likely. The mean listens to how far out the values sit, not just how probable they are.

Setting up the expected value

The expected value \( E[X] \) (also called the mean of the distribution, sometimes written \( \mu \)) is a probability-weighted average. You take each value the variable can be, multiply it by that value's probability, and add all those products up. Values that are more likely pull the average toward themselves because they carry more weight.

Notice this is just the ordinary average with the probabilities acting as the weights — if every value were equally likely, it would reduce to adding the values and dividing by how many there are.

\[ E[X] = \sum_{i} x_i \, P(X = x_i) \]
Expected value of a discrete random variable: each value times its probability, summed over all values.
📝 Worked example: A prize wheel pays out X dollars with this distribution: P(X = 0) = 0.6, P(X = 2) = 0.3, and P(X = 5) = 0.1. Is this a valid PMF, and what is the expected payout E[X]?
  1. Check the PMF: each probability is between 0 and 1, and 0.6 + 0.3 + 0.1 = 1. So it is a valid distribution.
  2. Set up E[X] as value times probability, summed: \( E[X] = 0(0.6) + 2(0.3) + 5(0.1) \).
  3. Work out each product: \( 0(0.6) = 0 \), \( 2(0.3) = 0.6 \), \( 5(0.1) = 0.5 \).
  4. Add them: \( 0 + 0.6 + 0.5 = 1.1 \).
✓ The distribution is valid and the expected payout is E[X] = 1.1 dollars — the long-run average per spin, even though no single spin ever pays exactly 1.1.

Check your understanding

1. Which of these is a DISCRETE random variable?
The number of heads can only be one of the countable whole numbers 0 through 10 — discrete. The others can slide to any value in a range, so they are continuous.
2. For a set of probabilities to form a valid PMF, they must…
Some outcome must happen, so the probabilities of all possible values sum to 1 (and each sits between 0 and 1).
3. A random variable has P(X = 1) = 0.2, P(X = 2) = 0.5, and P(X = 3) = 0.3. What is E[X]?
E[X] = 1(0.2) + 2(0.5) + 3(0.3) = 0.2 + 1.0 + 0.9 = 2.1.
4. In the simulation, the mean E[X] is drawn as a triangle under the axis. What does that picture represent?
The mean is the center of mass — the point where the bars would balance. It need not be the tallest bar or even a value the variable can actually take.
✅ Key takeaways
  • A random variable is a rule that assigns a number to each outcome of a random process, so outcomes can be added and averaged.
  • Discrete random variables take countable, listable values; continuous ones can take any value in a range.
  • A discrete variable's distribution is its PMF — each value with its probability — and those probabilities sum to 1.
  • The expected value E[X] = Σ x·P(X = x) is a probability-weighted average.
  • E[X] is the balance point of the distribution, not necessarily the most likely value or one you can actually observe.