Sub topic 1
What a Random Variable Is
This chapter defines a random variable, the object that every later idea in this tutorial describes. You will see how it differs from an ordinary variable, how to write events in terms of it, and how to avoid the confusions that cost points on GRE Quantitative Reasoning.
Prerequisites
This chapter assumes you can already do the following:
- Work with fractions, decimals, and percents.
- Find the mean, median, and range of a small data set.
- Compute the probability of a simple event, such as drawing a red marble from a bag.
- Read a simple graph or a number line.
If any of these feels shaky, review it first. Each one is used below without re-teaching.
The core idea
A random variable is a rule that assigns a number to each possible outcome of a random process. The process might be rolling a die, selecting a person from a survey, or measuring the height of a randomly chosen plant. The random variable turns the raw outcome into a number you can calculate with.
Two parts of that definition matter.
- It is a rule, not a single number. Before the process runs, the random variable has no fixed value. It has a set of possible values, each with some chance of occurring.
- The value is numerical. "Heads" is an outcome. "The number of heads in three flips" is a random variable, because it assigns the number 0, 1, 2, or 3 to each result.
By convention, a random variable is written as a capital letter such as X. A specific value it might take is written in lowercase, such as x. The expression X = 2 is a statement about an event: "the random variable takes the value 2."
From outcomes to numbers
Consider flipping a fair coin three times. The sample space, which is the list of all possible outcomes, has eight entries.
Let X be the number of heads. The table shows how X maps each outcome to a number.
| Outcome | X (number of heads) |
|---|---|
| TTT | 0 |
| HTT, THT, TTH | 1 |
| HHT, HTH, THH | 2 |
| HHH | 3 |
Several different outcomes can give the same value of X. That is allowed. The rule goes from outcomes to numbers, and it does not need to be one-to-one.
Because the eight outcomes are equally likely, you can find the probability of each value of X by counting.
- P(X = 0) = 1/8
- P(X = 1) = 3/8
- P(X = 2) = 3/8
- P(X = 3) = 1/8
These four probabilities add to 1, as they must, because X has to take one of these values.
Events written in terms of X
Once you have a random variable, you can describe events with inequalities. This is how GRE questions usually phrase things.
Using the same X (number of heads in three flips):
- "At least two heads" is the event X ≥ 2. Its probability is P(X = 2) + P(X = 3) = 3/8 + 1/8 = 1/2.
- "Fewer than one head" is X < 1, which means X = 0. Its probability is 1/8.
- "At most one head" is X ≤ 1. Its probability is 1/8 + 3/8 = 1/2.
The words "at least," "at most," "more than," and "fewer than" map to ≥, ≤, >, and <. Misreading one of these is a common source of wrong answers, so translate the wording to a symbol before you compute.
A random variable is not the same as its values
Beginners often treat X as if it were an ordinary algebra variable that you solve for. It is not. You do not "solve" for X in the sense of finding one number. You describe how X behaves across all the ways the process could turn out.
Compare two statements.
- In algebra, "x + 3 = 7" has one answer, x = 4.
- For a random variable, "X is the number of heads in three flips" has four possible values, each with its own probability.
A useful habit is to separate three questions.
- What values can X take?
- How likely is each value?
- What single numbers summarize X, such as its center and its spread?
The first question is the topic of this chapter. The second is the topic of the chapter on probability distributions, and the third is covered by expected value and standard deviation. The remaining chapters build on that outline.
A second example: choosing from a population
Random variables are not limited to games of chance. Suppose a school has 200 students, and you pick one student at random. Let H be that student's height in centimeters.
Before you pick, H is unknown. After you pick, H has one definite value, say 168. The randomness is in the selection. The same idea applies to any quantity measured on a randomly chosen item: a test score, a package weight, a commute time.
This matters for the GRE because many problems say "a value is chosen at random from a normally distributed population." The quantity chosen is a random variable, and the question asks about its probability of landing in some range.
Computing with a random variable
You can compute with a random variable the same way you would with its possible values, as long as you keep track of probabilities. The code below builds the distribution of X (number of heads in three flips) by enumerating the eight outcomes, then answers the "at least two heads" question.
from itertools import product
from fractions import Fraction
outcomes = list(product("HT", repeat=3)) # 8 equally likely outcomes
total = len(outcomes)
# The random variable: a rule from outcome to number
def X(outcome):
return outcome.count("H")
# Build P(X = x) for each value x
dist = {}
for o in outcomes:
x = X(o)
dist[x] = dist.get(x, 0) + Fraction(1, total)
for x in sorted(dist):
print(x, dist[x])
# Event: X >= 2
p_at_least_2 = sum(p for x, p in dist.items() if x >= 2)
print("P(X >= 2) =", p_at_least_2)Running it prints the four probabilities 1/8, 3/8, 3/8, 1/8, and then P(X >= 2) = 1/2. Notice that X is written as a function. That mirrors the definition: a random variable is a rule applied to outcomes.
Different random variables from the same process
One process can support many random variables. Roll two fair dice. Each of the following is a different random variable defined on the same 36 outcomes.
| Random variable | Rule | Possible values |
|---|---|---|
| S | Sum of the two dice | 2 through 12 |
| M | Larger of the two dice | 1 through 6 |
| D | Absolute difference of the dice | 0 through 5 |
The questions "what is P(S = 7)?" and "what is P(M = 6)?" have different answers because S and M are different rules. When a problem names a random variable, the first job is to read its rule carefully.
For S, six of the 36 outcomes sum to 7: (1,6), (2,5), (3,4), (4,3), (5,2), (6,1). So P(S = 7) = 6/36 = 1/6.
Common errors
- Confusing the outcome with the value. The outcome is HTH. The value of X is 2. Different outcomes can share a value, so count outcomes carefully when finding P(X = x).
- Forgetting that probabilities sum to 1. If your probabilities for all values of X add to something other than 1, there is a counting mistake or a missing value.
- Treating X as a number to solve for. X describes a spread of possibilities. Do not try to isolate it like an unknown in an equation.
- Mixing up strict and non-strict inequalities. P(X > 2) and P(X ≥ 2) differ by P(X = 2) when X is discrete.
- Assuming all values are equally likely. The values 0, 1, 2, 3 of X above are not equally likely. Only the underlying outcomes were equally likely. Equal likelihood of outcomes does not carry over to values of X.
Why this matters for the normal distribution
The normal distribution, which is the main subject of this tutorial, describes a random variable that can take any value along a number line, such as a height or a score. To use it, you will repeatedly state a question in the form "what is the probability that X is between a and b?" That is exactly the event notation introduced above. The remaining steps are learning how to describe the shape of X's distribution and how to read probabilities from it.
For now, the points to keep are these: a random variable assigns numbers to outcomes, an event is a statement about X, and a probability belongs to such an event.
Exercise
Two fair coins are flipped. Let Y be the number of tails. List the possible values of Y, give P(Y = y) for each, and find P(Y ≥ 1).
Show answer
The outcomes are HH, HT, TH, TT, each with probability 1/4. Y takes the values 0, 1, 2. P(Y = 0) = 1/4 (HH). P(Y = 1) = 2/4 = 1/2 (HT, TH). P(Y = 2) = 1/4 (TT). The probabilities sum to 1. P(Y ≥ 1) = 1/2 + 1/4 = 3/4, which also equals 1 − P(Y = 0).
Exercise
A student says: "When I roll two dice and let S be the sum, the values 2 through 12 are all equally likely because there are 11 of them, so P(S = 7) = 1/11." Explain the error and give the correct probability.
Show answer
The student treated the values of S as equally likely. Only the 36 underlying outcomes are equally likely, and different sums arise from different numbers of outcomes. Six outcomes give a sum of 7, so P(S = 7) = 6/36 = 1/6. By comparison, P(S = 2) = 1/36, since only (1,1) gives 2.
Exercise
A number is chosen at random from the set {1, 2, 3, 4, 5, 6}, each with equal probability. Let W be the chosen number. Find P(W > 4) and P(W ≥ 4), and explain why they differ.
Show answer
P(W > 4) counts the values 5 and 6, so it is 2/6 = 1/3. P(W ≥ 4) counts 4, 5, and 6, so it is 3/6 = 1/2. They differ by P(W = 4) = 1/6, because W is discrete and the value 4 is included in one event and excluded from the other.