Random Variables and Their Distributions
Turning random outcomes into numbers you can add up, average, and reason about.
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.
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.
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.
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.
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.
- Check the PMF: each probability is between 0 and 1, and 0.6 + 0.3 + 0.1 = 1. So it is a valid distribution.
- Set up E[X] as value times probability, summed: \( E[X] = 0(0.6) + 2(0.3) + 5(0.1) \).
- Work out each product: \( 0(0.6) = 0 \), \( 2(0.3) = 0.6 \), \( 5(0.1) = 0.5 \).
- Add them: \( 0 + 0.6 + 0.5 = 1.1 \).
Check your understanding
- 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.