Statistics · AP Statistics
Probability and random variables
chance, counted
Chance can’t be predicted one case at a time, but it can in the long run. Probability is the mathematics of that long run.
In the figure each ball falls through 10 rows of pins. At every pin it goes left or right with equal chance, so no one can say where the next ball will land.
Yet 240 balls pile up in a shape that can be predicted. The red marks are the heights expected in each bin, worked out before any ball fell. The middle three bins should hold 65.6% of the balls; they hold 164 of 240, or 68.3%.
This chapter asks when a pattern is just chance, estimates probabilities by simulation, and builds the rules for combining them: complements, “or”, “and”, conditional probability and independence. Then it turns outcomes into numbers. A random variable has a distribution with a mean and a standard deviation, and these combine in fixed ways. Two distributions come up again and again: the binomial (the board in the figure) and the geometric.
is it just chance?
A random process generates outcomes by chance. Streaks and clusters are part of what it produces, so a pattern in random data need not mean anything.
One grid in the figure is 50 tosses of a fair coin. The other was written down by a person trying to look random. People avoid streaks, and that gives them away:
| real tosses | made up |
|---|
| heads | 19 | 25 |
| switches H ↔ T | 25 | 35 |
| longest run | 5 | 3 |
After each toss of a fair coin, the next one switches with probability 1/2, so about 24.5 switches are typical. The made-up sequence switches 35 times; the real one 25.
How often does chance alone do this? In 10,000 simulated sets of 50 fair tosses (the bars), 82% had a run of 5 or more. Only 2.0% had a longest run of 3 or less. The run of 5 tails is ordinary. The made-up sequence is the unusual one.
So a basketball player’s streak, or a cluster of illnesses in one town, is not evidence of anything on its own. First ask how often random chance would produce a pattern like it. That question runs through the rest of the course.
the long-run relative frequency
The probability of an outcome is the proportion of times it would occur in a very long series of repetitions.
The law of large numbers. As a chance process is repeated more and more times, the relative frequency of an outcome gets closer to its probability. In the figure, run 1 had 4 sixes in its first 10 rolls (0.400), 14 in 50 (0.280) and 95 in 600 (0.158). Every run wanders early and settles near 1/6 ≈ 0.167.
This is a statement about the long run only. A die has no memory: after a run without sixes, a six is no more likely. Early deviations are not corrected; they are swamped by the many rolls that follow.
A simulation imitates a chance process to estimate a probability:
1. Describe how one trial is imitated with random numbers. 2. Say what is recorded. 3. Run many trials. 4. Take the relative frequency as the estimate.
Example. What is the probability of at least one six in four rolls of a die? One trial: four random integers from 1 to 6, each a roll. Record whether any is 6. The first 6 trials:
| trial | 1 | 2 | 3 | 4 | 5 | 6 |
|---|
| rolls | 2 2 4 4 | 5 5 1 4 | 5 4 5 6 | 2 1 4 6 | 6 6 2 4 | 5 2 5 3 |
| a six? | no | no | yes | yes | yes | no |
Of 1000 trials, 539 had a six: an estimate of 0.539. The exact value (4.3) is 1 − (5/6)4 = 0.518. More trials would give an estimate closer to it, on average. With a table of random digits, use 1–6 for the faces and skip 0, 7, 8 and 9.
sample spaces, events and complements
The sample space S of a chance process is the set of all its possible outcomes. An event is a set of outcomes, and its probability is a number from 0 to 1.
Roll two dice. The sample space has 6 × 6 = 36 outcomes, one tile each in the figure, all equally likely. When outcomes are equally likely,
The event A, “the sum is 7”, has 6 outcomes (red): (1, 6), (2, 5), (3, 4), (4, 3), (5, 2), (6, 1). So P(A) = 6/36 = 0.167. The order matters: (1, 6) and (6, 1) are different outcomes.
Every event has 0 ≤ P(A) ≤ 1, and P(S) = 1: something in S always happens. An event with probability 0 never occurs; one with probability 1 always does.
The complement AC is the event that A does not happen. A and AC share no outcomes and together fill S, so
The complement is the quick way to “at least one”. P(at least one six) = 1 − P(no sixes) = 1 − 25/36 = 11/36: count the tiles in the top row and right column, and there are 11.
events that cannot happen together
Two events are mutually exclusive (disjoint) when they cannot both occur: P(A ∩ B) = 0.
The notation: A ∩ B (“A and B”) is the event that both happen; A ∪ B (“A or B”) is the event that at least one happens. In a Venn diagram the rectangle is the sample space, and here areas are drawn to scale: each region’s area is its probability.
A donor’s ABO blood type is one of four:
| type | O | A | B | AB |
|---|
| probability | 0.44 | 0.42 | 0.10 | 0.04 |
The events “type A” and “type B” are mutually exclusive: no one has both (type AB is a type of its own). Their discs don’t overlap, so the areas simply add:
The darts in the figure land at random, so the share landing in a region approaches its area: the share in A or B approaches 0.52. The rest, O or AB, has probability 0.48 = 1 − 0.52.
Only add probabilities this way when the events are mutually exclusive. If they can overlap, the overlap gets counted twice (4.6).
the probability of A, given B
The conditional probability P(A | B) is the probability that A happens, given that B has happened. Knowing B shrinks the sample space to B.
A survey asked 500 drivers whether they had texted while driving in the past month:
| texted | did not | total |
|---|
| 16–24 | 72 | 48 | 120 |
| 25 and older | 95 | 285 | 380 |
| total | 167 | 333 | 500 |
Choose one driver at random. Let T be “texted” and Y “aged 16–24”. P(T) = 167/500 = 0.334. But given that the driver is 16–24, only that row counts:
The figure on the right shows each row on its own: 0.60 of the young drivers texted, against 0.25 of the older ones.
The order matters. P(Y | T) = 72/167 = 0.431: of the drivers who texted, 43.1% were young. The numerator is the same; the denominator is whatever is given.
Rearranged, the definition is the multiplication rule, P(A ∩ B) = P(B) · P(A | B): P(T ∩ Y) = 0.24 × 0.60 = 0.144 = 72/500.
multiply along the branches, add across them
When a chance process happens in stages, a tree diagram shows each stage’s outcomes as branches. The probability of a path is the product of the probabilities along it.
4% of a population has a condition. A screening test is positive for 90% of people who have it, and for 10% of people who don’t. The second-stage branches are conditional probabilities: 0.9 is P(+ | condition).
| path | probability | per 1000 people |
|---|
| condition, + | 0.04 × 0.9 = 0.036 | 36 |
| condition, − | 0.04 × 0.10 = 0.004 | 4 |
| no condition, + | 0.96 × 0.1 = 0.096 | 96 |
| no condition, − | 0.96 × 0.90 = 0.864 | 864 |
Two paths end in a positive test. They are mutually exclusive, so their probabilities add: P(+) = 0.036 + 0.096 = 0.132.
Someone tests positive. What is the probability they have the condition (C)?
Only about 27%. In 1000 people there are 36 true positives and 96 false ones: the condition is rare, so the few errors among the many healthy people outnumber the cases. The figure sends 400 people down the tree at random; watch the red and blue leaves.
the addition rule, and when knowing one tells nothing
Events A and B are independent if knowing that one has happened doesn’t change the probability of the other: P(A | B) = P(A).
At one school, 35% of students take AP Statistics (S), 25% take AP Biology (B) and 10% take both. The discs overlap.
The addition rule. Adding P(S) and P(B) counts the overlap (red) twice, so take it off once:
So 0.50 take neither. For mutually exclusive events P(A ∩ B) = 0, and the rule becomes the one in 4.4.
Checking independence. P(S | B) = 0.10/0.25 = 0.40, but P(S) = 0.35. Knowing a student takes Biology raises the chance they take Statistics, so S and B are not independent. The same check in another form: if independent, P(S ∩ B) would equal P(S) · P(B) = 0.0875, not 0.10.
For independent events, and only then, the multiplication rule becomes P(A ∩ B) = P(A) · P(B). Two separate dice are independent: P(both six) = 1/6 × 1/6 = 1/36.
Don’t confuse the two ideas. Mutually exclusive events (with positive probabilities) are never independent: if one happens, the other’s probability drops to 0. In 4.5, P(texted | 16–24) = 0.600 ≠ P(texted) = 0.334, so texting and age group are not independent.
outcomes as numbers
A random variable takes numerical values that depend on the outcome of a chance process. Its probability distribution gives its possible values and their probabilities.
Let X be the number of cars owned by a randomly chosen household in one town. X is discrete: it takes a list of separate values.
| x | 0 | 1 | 2 | 3 | 4 |
|---|
| P(X = x) | 0.08 | 0.32 | 0.38 | 0.15 | 0.07 |
| P(X ≤ x) | 0.08 | 0.40 | 0.78 | 0.93 | 1.00 |
A valid distribution has every probability between 0 and 1, and they add to 1. In the figure, the bars are P(X = x). The black steps are the cumulative probabilities P(X ≤ x), the bars added from the left.
Read the words carefully:
P(X ≥ 2), “at least two”: 0.38 + 0.15 + 0.07 = 0.60, or 1 − P(X ≤ 1) = 1 − 0.40.
P(X > 2), “more than two”: 0.22, without the 2.
P(1 ≤ X ≤ 3) = P(X ≤ 3) − P(X ≤ 0) = 0.93 − 0.08 = 0.85.
The red dots are households drawn at random: the share of each value so far. As draws pile up they settle on the bars. This is the law of large numbers again: a probability distribution is the long-run pattern of the values.
the balance point, and a typical distance from it
The mean (expected value) μX of a random variable is its long-run average value. The standard deviation σX is a typical distance of its values from that mean.
Each value is weighted by its probability:
The mean is the histogram’s balance point (the red wedge). It need not be a value X can take: no household owns 1.81 cars.
In context. “If many households were chosen at random, the average number of cars per household would be about 1.81.” “The number of cars owned by a randomly chosen household typically varies from the mean of 1.81 by about 1.02 cars.”
The variance is σ2X = 1.0339. A shortcut gives the same number: Σx2P(x) − μ2 = 4.31 − 1.812 = 1.0339.
Under the axis, the black ball is the mean of all the households drawn so far. It wanders, then settles on μ: the law of large numbers, for means.
a linear transformation: Y = a + bX
Adding a constant to a random variable shifts its mean and leaves its spread alone. Multiplying by a constant multiplies both.
A wheel is spun once. X, the number it lands on, has this distribution:
| x | 1 | 2 | 3 | 4 |
|---|
| P(X = x) | 0.4 | 0.3 | 0.2 | 0.1 |
μX = 2 and σX = 1. It costs $7 to play, and the prize is $3 times the number. The net gain is Y = 3X − 7 dollars.
The figure does it in two moves. Multiplying by 3 spreads the bars 3 times as far apart: the mean and the standard deviation both triple. Subtracting 7 slides every bar down by 7: the mean moves, the spread doesn’t. Neither move changes the heights, so the shape stays the same.
In context. Over many games a player loses $1 a game on average. A player wins money only when X ≥ 3: P(Y > 0) = 0.3.
The variance is multiplied by b2: σ2Y = 32 × 1 = 9. Adding a constant changes the centre (mean, median, quartiles); multiplying changes the centre and every measure of spread (SD, IQR, range).
means add; for independent variables, variances add
The mean of a sum is the sum of the means. When the variables are independent, the variance of a sum, and of a difference, is the sum of the variances.
Spin the wheel (X, from the page before) and roll a fair die (Y, mean 3.5, SD 1.708). The spin and the roll are independent. Their total T = X + Y has the distribution in red, found by adding every pair of outcomes.
Standard deviations do not add: 1 + 1.71 = 2.71 is too big. They combine like the sides of a right triangle (right of the figure).
Differences. D = Y − X has mean 3.5 − 2 = 1.5, and its variance is still σ2X + σ2Y, so σD = 1.979. Subtracting a random amount adds variability; it never takes it away.
The means rule holds for any random variables. The variance rule needs independence. And two spins X1 + X2 is not 2X: its SD is √2 σX, while 2X has SD 2σX.
Normal variables. A sum or difference of independent normal random variables is normal. A relay’s two legs take N(24, 1.5) and N(26.5, 2) minutes. The total is N(50.5, 2.5), with √(1.52 + 22) = 2.5. P(total < 48) = P(z < −1.00) = 0.1587.
counting successes in n trials
A binomial random variable counts the successes in a fixed number of independent trials that each have the same probability of success.
Check the four conditions (BINS): Binary, each trial a success or a failure; Independent trials; a fixed Number of trials, n; the Same probability of success, p, on every trial.
On the board each pin is a trial and “right” is a success: n = 10, p = 0.5. X, the number of rights, is the bin a ball lands in. To land in bin 6, a ball must go right at 6 of the 10 pins. Each such route has probability (1/2)10, and there are C(10, 6) = 210 of them:
Bin 6 should get 240 × 0.205 ≈ 49 of the balls; it got 47.
In context. A player makes 70% of her free throws and takes 10, which we treat as independent. X, the number made, is binomial with n = 10, p = 0.7.
P(X = 8) = C(10, 8)(0.7)8(0.3)2 = 0.2335.
P(X ≥ 8) = 1 − P(X ≤ 7) = 1 − 0.6172 = 0.3828: “at least” uses the cumulative probability of the complement.
Not binomial: drawing cards without replacement (the trials are not independent); counting tosses until the first head (no fixed n: that is 4.12).
μ = np, σ = √(np(1 − p))
A binomial distribution is fixed by its two parameters, n and p. Its mean and standard deviation follow from them.
For the board, μ = 10(0.5) = 5 and σ = √(10 × 0.5 × 0.5) = 1.58. The bins within one σ of the mean, 4, 5, 6, hold 0.656 of the probability.
These are the rules of 4.9 at work. X is a sum of 10 independent trials, each worth 1 with probability p and 0 otherwise. One trial has mean p and variance p(1 − p). Means add, and so do variances.
In context. For the free throws, μ = 10(0.7) = 7 and σ = √(10 × 0.7 × 0.3) = 1.45. “Over many sets of 10 free throws she makes 7 on average; the number made typically varies from 7 by about 1.45.”
Shape. With p = 0.5 the distribution is symmetric. With p near 0 or 1 it is skewed, less so as n grows. When np ≥ 10 and n(1 − p) ≥ 10 it is close to normal, which unit 5 uses.
The 10% condition. Sampling without replacement makes the trials dependent. If the sample is at most 10% of the population, the dependence is slight and the binomial model is still good.
trials up to the first success
A geometric random variable counts the trials up to and including the first success, in independent trials that each have the same probability of success.
A cereal brand puts a prize in 20% of its boxes. Open boxes one at a time until you find a prize; X is the number of boxes opened. There is no fixed number of trials, so X is not binomial. To first succeed on trial x (x = 1, 2, 3, …), the first x − 1 trials must fail:
Each bar is 0.8 times the one before, so the distribution is always skewed right, and its most likely value is always 1.
P(X ≤ 3) = 1 − P(no prize in the first 3) = 1 − 0.83 = 0.488.
P(X > 5) = 0.85 = 0.328: the first five boxes all fail.
In context. “If this were repeated many times, it would take 5 boxes on average to find a prize.” The figure plays one run after another: boxes open until the red one, then the ball marks that run’s X.
← Collecting data · Sampling distributions →