What is a random variable?
A random variable is a variable whose value is a number that comes from a random process. Before the process happens, you do not know which value you will get. You only know which values are possible and how likely each one is.
Examples:
- X = the number of questions a contestant answers correctly out of 3.
- Y = the number of customers who arrive at a shop counter in one minute.
- W = the score shown on a weighted die after one roll.
We use capital letters (X, Y, W) for random variables and small letters (x, y, w) for particular values. “P(X = 2)” is read as “the probability that X equals 2”.
A random variable must give a number. “The colour of the next car” is a random outcome, but not a random variable. “The number of red cars among the next 10” is a random variable.
Discrete or continuous? A discrete random variable has values you can list, with gaps between them, such as 0, 1, 2, 3. A continuous random variable can take any value in an interval, such as a waiting time in seconds. This topic is about discrete random variables. You will meet a continuous one, the normal distribution, in Topic 2.11.
The probability distribution of a discrete random variable
The probability distribution of a discrete random variable lists every possible value with its probability. Two rules make a distribution valid:
- Every probability is between 0 and 1: 0 ≤ P(X = x) ≤ 1.
- The probabilities add to 1: ΣP(X = x) = 1.
If either rule fails, the table is not a probability distribution. Check both whenever you build or are given a distribution.
You can show a distribution in three ways:
- A table, with the values of X in one row and their probabilities in the next.
- A graph, usually a probability histogram: one bar per value, with height equal to the probability.
- A function, a formula such as P(X = x) = x ÷ 10 for x = 1, 2, 3, 4.
Where do the probabilities come from? There are two routes.
- Probability rules (Topics 2.4 to 2.7). List the outcomes of the process, find the probability of each, and add the probabilities of the outcomes that give the same value of X. This gives the exact distribution, as long as the assumptions behind the rules hold.
- Simulation (Topic 2.3). Imitate the process many times and record the value of X each time. The relative frequencies estimate the distribution. More trials give better estimates.
The cumulative distribution
The cumulative probability distribution gives, for each value x, the probability that X is less than or equal to x: P(X ≤ x). You get it by adding the probabilities from the smallest value up to x.
It can be shown as a table or a function. It has three features you can use as checks:
- It never decreases as x increases.
- Its last value is 1.
- You can get back to single probabilities by subtracting: P(X = x) = P(X ≤ x) − P(X ≤ previous value).
Read the inequality carefully. For a discrete variable, “less than 3” and “at most 3” are different events. With values 0, 1, 2, 3, P(X < 3) = P(X ≤ 2), but P(X ≤ 3) also includes P(X = 3). Words to translate:
| Words | Symbol |
|---|---|
| at most 2, no more than 2 | X ≤ 2 |
| fewer than 2, less than 2 | X < 2, which is X ≤ 1 here |
| at least 2, no fewer than 2 | X ≥ 2 |
| more than 2 | X > 2, which is X ≥ 3 here |
Worked example 1: building a distribution with probability rules
Question. On a fictional quiz show, Brainwave, a contestant answers three questions. From past shows, the probabilities that this contestant answers correctly are 0.9 for question 1, 0.6 for question 2 and 0.3 for question 3. Assume the results of the three questions are independent. Let X = the number of questions answered correctly.
(a) Construct the probability distribution of X and check that it is valid. (b) Construct the cumulative distribution. (c) Find the probability that the contestant answers at least 2 questions correctly.
(a) X can be 0, 1, 2 or 3. List all 2 × 2 × 2 = 8 outcomes (C = correct, W = wrong). Because the questions are independent, multiply along each outcome.
| Outcome | X | Probability |
|---|---|---|
| CCC | 3 | 0.9 × 0.6 × 0.3 = 0.162 |
| CCW | 2 | 0.9 × 0.6 × 0.7 = 0.378 |
| CWC | 2 | 0.9 × 0.4 × 0.3 = 0.108 |
| WCC | 2 | 0.1 × 0.6 × 0.3 = 0.018 |
| CWW | 1 | 0.9 × 0.4 × 0.7 = 0.252 |
| WCW | 1 | 0.1 × 0.6 × 0.7 = 0.042 |
| WWC | 1 | 0.1 × 0.4 × 0.3 = 0.012 |
| WWW | 0 | 0.1 × 0.4 × 0.7 = 0.028 |
The outcomes are mutually exclusive, so add the probabilities for each value of X:
- P(X = 0) = 0.028
- P(X = 1) = 0.252 + 0.042 + 0.012 = 0.306
- P(X = 2) = 0.378 + 0.108 + 0.018 = 0.504
- P(X = 3) = 0.162
| x | 0 | 1 | 2 | 3 |
|---|---|---|---|---|
| P(X = x) | 0.028 | 0.306 | 0.504 | 0.162 |
Check. Every probability is between 0 and 1, and 0.028 + 0.306 + 0.504 + 0.162 = 1.000. The distribution is valid.
(b) Add as you go:
| x | 0 | 1 | 2 | 3 |
|---|---|---|---|---|
| P(X ≤ x) | 0.028 | 0.334 | 0.838 | 1.000 |
(c) P(X ≥ 2) = P(X = 2) + P(X = 3) = 0.504 + 0.162 = 0.666. Or, with the cumulative table, P(X ≥ 2) = 1 − P(X ≤ 1) = 1 − 0.334 = 0.666.
Interpretation. In the long run, this contestant would answer at least 2 of the 3 questions correctly on about 66.6% of shows like this one.
Note. There are 8 outcomes but only 4 values of X. Do not give each outcome its own row in the distribution, and do not assume the outcomes are equally likely: here they are not.
Worked example 2: a distribution given as a function
Question. A fictional board game uses a weighted four-sided die. The score X on one roll has P(X = x) = kx for x = 1, 2, 3, 4, where k is a constant.
(a) Find k. (b) Write the distribution and the cumulative distribution as tables. (c) Find P(X ≤ 2), P(X > 2) and P(X = 3) from the cumulative table.
(a) The probabilities must add to 1:
k(1) + k(2) + k(3) + k(4) = 10k = 1, so k = 0.1.
(b)
| x | 1 | 2 | 3 | 4 |
|---|---|---|---|---|
| P(X = x) | 0.1 | 0.2 | 0.3 | 0.4 |
| P(X ≤ x) | 0.1 | 0.3 | 0.6 | 1.0 |
Check: all probabilities are between 0 and 1 and they add to 1, so this is valid. The cumulative row never decreases and ends at 1.
(c)
- P(X ≤ 2) = 0.3, read straight from the table.
- P(X > 2) = 1 − P(X ≤ 2) = 1 − 0.3 = 0.7.
- P(X = 3) = P(X ≤ 3) − P(X ≤ 2) = 0.6 − 0.3 = 0.3, which matches the distribution row.
Interpretation. On about 70% of rolls in the long run, this die shows a score of 3 or 4.
Worked example 3: estimating a distribution by simulation
Question. In a fictional phone game, each pack contains one of 3 characters, each equally likely, independently of other packs. A player opens 3 packs. Let X = the number of different characters the player gets. (a) Describe a simulation to estimate the distribution of X. (b) Use the results of one simulation to estimate the distribution. (c) Compare with the exact distribution.
(a) Label the characters 1, 2 and 3. For one trial, use a random number generator to produce three whole numbers from 1 to 3 (repeats allowed), one for each pack. Record X, the number of different labels. For example, 2, 1, 1 gives X = 2. Repeat for many trials, such as 300.
(b) One simulation of 300 trials gave these results:
| x | 1 | 2 | 3 | Total |
|---|---|---|---|---|
| Number of trials | 24 | 214 | 62 | 300 |
| Estimated P(X = x) | 0.0800 | 0.7133 | 0.2067 | 1 |
Each estimate is a relative frequency: for example, 214 ÷ 300 ≈ 0.7133.
(c) With rules: there are 3 × 3 × 3 = 27 equally likely outcomes. All three the same: 3 outcomes. All three different: 3 × 2 × 1 = 6 outcomes. Exactly two different: 27 − 3 − 6 = 18 outcomes.
| x | 1 | 2 | 3 |
|---|---|---|---|
| Exact P(X = x) | 3/27 ≈ 0.1111 | 18/27 ≈ 0.6667 | 6/27 ≈ 0.2222 |
The simulated estimates are close to the exact values but not equal. A simulation estimate changes from one run to the next. With more trials, the estimates tend to get closer to the exact probabilities.
Common misconceptions
- “The probabilities in a table add to 1, so it must be valid.” Also check that every probability is between 0 and 1. A negative value makes it invalid even if the sum is 1.
- Forgetting a value. Every possible value must appear, including 0 when it is possible. If the sum is less than 1, a value is probably missing.
- “Each value of X is equally likely.” Only if the process makes it so. In Worked example 1, the 4 values have very different probabilities.
- Listing outcomes instead of values. The distribution has one entry per value of X, not one per outcome.
- Mixing up < and ≤. For a discrete variable, P(X < 3) does not include P(X = 3). Translate the words first.
- “The cumulative probability for x is P(X = x).” It is P(X ≤ x), the running total.
- “A simulation gives the exact distribution.” It gives an estimate. It is close for many trials, but it is not exact.
- Treating X as an unknown to solve for. X is a random variable. You find probabilities of its values; you do not solve for X.
Where this leads
A distribution describes everything about a random variable, but you often want a single “typical value” and a measure of spread. In Topic 2.9 you will calculate the mean (expected value) and standard deviation of a random variable from its distribution. Read Parameters of Random Variables next. Later, the binomial distribution (Topic 2.10) gives a function for one important family of discrete distributions.
First, try the practice questions, then use the revision notes and the checklist. If the multiplication rule felt unfamiliar in Worked example 1, revisit Independent Events and Unions of Events.
Quick questions
What is the difference between X and x?
Capital X is the random variable: the rule that turns outcomes into numbers. Small x stands for one particular value it can take. So P(X = 2) means 'the probability that the random variable takes the value 2'.
Do I need to find the mean of the distribution in this topic?
No. Building and using the distribution is Topic 2.8. The mean (expected value) and standard deviation of a random variable come next, in Topic 2.9.