Mathematics · Book 2 · Grades 10–12

High School Mathematics

High School Mathematics · Grades 10–12

32Conditional Probability and Independence

Probability quantifies uncertainty; conditional probability quantifies how information changes it. Learning that an event BB occurred reshapes the probabilities of all other events — a mechanism formalized by Bayes and misused daily in courtrooms and newspapers. This chapter sets up the rules of conditioning and the exact meaning of independence.

32.1 Probability spaces (reminder)

An experiment with finitely many outcomes is modeled by a sample space Ω\Omega (the set of outcomes) and a probability P\P assigning to each event AΩA \subseteq \Omega a number P(A)[0,1]\P(A) \in \intcc{0}{1}, additive over disjoint unions and with P(Ω)=1\P(\Omega) = 1. Recall the basic rules:

P(Aˉ)=1P(A),P(AB)=P(A)+P(B)P(AB).\P(\bar A) = 1 - \P(A), \qquad \P(A \cup B) = \P(A) + \P(B) - \P(A \cap B).

When all outcomes are equally likely, P(A)=AΩ\P(A) = \frac{\abs A}{\abs\Omega} — and computing probabilities reduces to the counting techniques of Chapter 27.

32.2 Conditional probability

Definition 32.1 (Conditional probability)

Let BB be an event with P(B)>0\P(B) > 0. The probability of AA given BB is

PB ⁣(A)=P(AB)P(B).\pcond{B}{A} = \frac{\P(A \cap B)}{\P(B)} .

The map APB ⁣(A)A \mapsto \pcond BA is itself a probability (all rules apply); it represents the new state of knowledge of someone who has learned that BB occurred.

Proposition 32.2 (Multiplication rule)

For events with nonzero probabilities:

P(AB)=P(B)PB ⁣(A)=P(A)PA ⁣(B),\P(A \cap B) = \P(B)\,\pcond{B}{A} = \P(A)\,\pcond{A}{B},

and more generally P(A1A2A3)=P(A1)PA1 ⁣(A2)PA1A2 ⁣(A3)\P(A_1 \cap A_2 \cap A_3) = \P(A_1)\,\pcond{A_1}{A_2}\, \pcond{A_1 \cap A_2}{A_3}, etc.

Proof. Rearrange the definition; the chain formula follows by iterating.

Theorem 32.3 (Law of total probability)

Let B1,,BnB_1, \dots, B_n be a partition of Ω\Omega into events of nonzero probability. For every event AA:

P(A)=i=1nP(Bi)PBi ⁣(A).\P(A) = \sum_{i=1}^{n} \P(B_i)\,\pcond{B_i}{A}.

Proof. The sets ABiA \cap B_i are pairwise disjoint with union AA, so P(A)=iP(ABi)=iP(Bi)PBi ⁣(A)\P(A) = \sum_i \P(A \cap B_i) = \sum_i \P(B_i)\pcond{B_i}{A} by the multiplication rule.

Method 32.4 (Probability trees)

A tree diagram organizes conditional probabilities: each branch carries the probability of the next event given the path so far.

  • The probability of a leaf (a complete path) is the product of the probabilities along its branches (multiplication rule).
  • The probability of an event is the sum of the probabilities of the leaves realizing it (total probability).
  • Probabilities on branches leaving one node add up to 11.
A two-level tree: multiply along a path, add over the leaves. For instance (A) is the sum of the first and third leaf probabilities.
A two-level tree: multiply along a path, add over the leaves. For instance P(A)\P(A) is the sum of the first and third leaf probabilities.

Theorem 32.5 (Bayes’ formula)

Let B1,,BnB_1, \dots, B_n be a partition of Ω\Omega as above and AA an event with P(A)>0\P(A) > 0. Then

PA ⁣(Bj)=P(Bj)PBj ⁣(A)i=1nP(Bi)PBi ⁣(A).\pcond{A}{B_j} = \frac{\P(B_j)\,\pcond{B_j}{A}}{\sum_{i=1}^{n} \P(B_i)\,\pcond{B_i}{A}} .

Proof. PA ⁣(Bj)=P(ABj)P(A)\pcond{A}{B_j} = \frac{\P(A \cap B_j)}{\P(A)}; expand the numerator by the multiplication rule and the denominator by total probability.

Example 32.6 (Screening test)

A disease affects 1%1\% of a population. A test detects it with probability 0.990.99 (sensitivity) and gives a false positive with probability 0.050.05. Given a positive test, the probability of actually having the disease is

0.01×0.990.01×0.99+0.99×0.05=0.00990.0099+0.0495=160.17.\frac{0.01 \times 0.99}{0.01\times0.99 + 0.99\times0.05} = \frac{0.0099}{0.0099 + 0.0495} = \frac{1}{6} \approx 0.17 .

Despite the accurate test, five positives out of six are false — because the disease is rare. Confusing PA ⁣(B)\pcond{A}{B} with PB ⁣(A)\pcond{B}{A} is the prosecutor’s fallacy.

The screening test as a tree (D: diseased, T: positive test). The two positive leaves (red) have total weight 0.0594, of which the false positives contribute five sixths.
The screening test as a tree (DD: diseased, TT: positive test). The two positive leaves (red) have total weight 0.05940.0594, of which the false positives contribute five sixths.

32.3 Independence

Definition 32.7 (Independent events)

Two events AA and BB are independent if

P(AB)=P(A)P(B).\P(A \cap B) = \P(A)\,\P(B) .

When P(B)>0\P(B) > 0, this is equivalent to PB ⁣(A)=P(A)\pcond{B}{A} = \P(A): knowing BB does not change the probability of AA.

Proposition 32.8

If AA and BB are independent, so are AA and Bˉ\bar B (and Aˉ\bar A and Bˉ\bar B).

Proof. P(ABˉ)=P(A)P(AB)=P(A)P(A)P(B)=P(A)(1P(B))=P(A)P(Bˉ)\P(A \cap \bar B) = \P(A) - \P(A \cap B) = \P(A) - \P(A)\P(B) = \P(A)\bigl(1 - \P(B)\bigr) = \P(A)\,\P(\bar B).

Remark 32.9

Do not confuse independent (P(AB)=P(A)P(B)\P(A\cap B) = \P(A)\P(B)) with incompatible (AB=A \cap B = \varnothing). Two incompatible events of nonzero probability are never independent: knowing one occurred guarantees the other did not.

Definition 32.10 (Independent repetitions)

When an experiment is repeated nn times so that the outcome of each trial does not influence the others, the probability of a specified sequence of outcomes is the product of the individual probabilities. This is the model underlying the binomial distribution (Chapter 33).

32.4 Exercises

Exercise 32.1

A card is drawn from a standard 52-card deck. Compute the probability that it is a king, given that it is a face card (jack, queen or king). Are the events “king” and “heart” independent?

Solution

Solution of Exercise 32.1.

There are 1212 face cards, of which 44 are kings: Pface ⁣(king)=412=13\pcond{\text{face}}{\text{king}} = \frac{4}{12} = \frac13.

Independence: P(kingheart)=152\P(\text{king} \cap \text{heart}) = \frac{1}{52} (the king of hearts), and P(king)P(heart)=452×1352=152\P(\text{king})\,\P(\text{heart}) = \frac{4}{52}\times\frac{13}{52} = \frac{1}{52}. Equal: the events are independent.

Exercise 32.2

An urn contains 5 red and 3 blue balls. Two balls are drawn in succession without replacement.

  1. Draw the probability tree.
  2. Compute the probability that both are red, and the probability that the second is red.
Solution

Solution of Exercise 32.2.

1. First branch: red 58\frac58, blue 38\frac38; second branches (without replacement): after red, red 47\frac47 / blue 37\frac37; after blue, red 57\frac57 / blue 27\frac27.

2. P(RR)=58×47=514\P(RR) = \frac58 \times \frac47 = \frac{5}{14}. By total probability,

P(2nd red)=5847+3857=20+1556=58.\P(\text{2nd red}) = \frac58\cdot\frac47 + \frac38\cdot\frac57 = \frac{20 + 15}{56} = \frac58 .

(The same as the first draw — by symmetry, the second ball is a uniformly random ball of the urn.)

Exercise 32.3

Two fair dice are rolled. Let AA = “the sum is 77”, BB = “the first die shows 33”, CC = “the sum is 66”. Determine whether AA and BB are independent, then whether BB and CC are.

Solution

Solution of Exercise 32.3.

P(A)=636=16\P(A) = \frac{6}{36} = \frac16 (six pairs sum to 77), P(B)=16\P(B) = \frac16, and AB={(3,4)}A \cap B = \{(3,4)\} has probability 136=P(A)P(B)\frac{1}{36} = \P(A)\P(B): AA and BB are independent. (The sum 77 is special: whatever the first die, exactly one value of the second gives it.)

P(C)=536\P(C) = \frac{5}{36} and BC={(3,3)}B \cap C = \{(3,3)\}: P(BC)=13616×536=5216\P(B \cap C) = \frac{1}{36} \neq \frac16 \times \frac{5}{36} = \frac{5}{216}. Not independent.

Exercise 32.4 ★★

A factory has three machines producing respectively 50%50\%, 30%30\% and 20%20\% of total output, with defect rates 1%1\%, 2%2\% and 4%4\%.

  1. What proportion of the production is defective?
  2. A randomly chosen item is defective. What is the probability it came from the third machine?
Solution

Solution of Exercise 32.4.

1. Total probability with the partition by machine:

P(D)=0.5×0.01+0.3×0.02+0.2×0.04=0.005+0.006+0.008=0.019=1.9%.\P(D) = 0.5\times0.01 + 0.3\times0.02 + 0.2\times0.04 = 0.005 + 0.006 + 0.008 = 0.019 = 1.9\% .

2. Bayes: PD ⁣(M3)=0.0080.019=8190.42\pcond{D}{M_3} = \dfrac{0.008}{0.019} = \dfrac{8}{19} \approx 0.42. The machine producing only a fifth of the output accounts for over 40%40\% of the defects.

Exercise 32.5 ★★

In Example 32.6, at what disease prevalence pp (instead of 1%1\%) would a positive test mean at least a 90%90\% chance of disease? Solve the inequality and comment.

Solution

Solution of Exercise 32.5.

The condition is

0.99p0.99p+0.05(1p)0.9.\frac{0.99\,p}{0.99\,p + 0.05\,(1-p)} \geq 0.9 .

The denominator is positive, so this reads 0.99p0.891p+0.0450.045p0.99p \geq 0.891p + 0.045 - 0.045p, i.e. 0.144p0.0450.144\,p \geq 0.045, i.e.

p0.0450.144=0.3125.p \geq \frac{0.045}{0.144} = 0.3125 .

The test alone reaches 90%90\% certainty only if the disease already affects more than 31%31\% of the tested population — which is why mass screening of rare diseases requires confirmation tests.

Exercise 32.6 ★★

A biased coin lands heads with probability p(0,1)p \in \intoo{0}{1}. It is tossed three times, tosses being independent.

  1. Compute the probability of the event EE = “exactly two heads”.
  2. For which pp is P(E)\P(E) maximal?
Solution

Solution of Exercise 32.6.

1. Three sequences realize EE (HHT, HTH, THH), each of probability p2(1p)p^2(1-p) by independence: P(E)=3p2(1p)\P(E) = 3p^2(1 - p).

2. f(p)=3p23p3f(p) = 3p^2 - 3p^3 has f(p)=6p9p2=3p(23p)f'(p) = 6p - 9p^2 = 3p(2 - 3p), positive then negative on (0,1)\intoo{0}{1}: maximum at p=23p = \frac23, where P(E)=34913=49\P(E) = 3\cdot\frac49\cdot\frac13 = \frac49.

Exercise 32.7 ★★★

(Monty Hall.) A prize hides behind one of three doors. You pick a door; the host, who knows where the prize is, opens one of the two remaining doors, always revealing an empty one (choosing at random if both are empty), and offers you to switch to the other closed door. Using Bayes’ formula, compute the probability of winning if you switch, and if you do not.

Solution

Solution of Exercise 32.7.

Say you picked door 1 and the host opened door 3 (event H3H_3). With BiB_i = “prize behind door ii”, P(Bi)=13\P(B_i) = \frac13 and

PB1 ⁣(H3)=12,PB2 ⁣(H3)=1,PB3 ⁣(H3)=0\pcond{B_1}{H_3} = \frac12, \qquad \pcond{B_2}{H_3} = 1, \qquad \pcond{B_3}{H_3} = 0

(if the prize is behind your door, the host chooses between doors 2 and 3 at random; if it is behind door 2, he is forced to open 3). Bayes:

PH3 ⁣(B1)=13121312+131+0=1/61/2=13,PH3 ⁣(B2)=1312=23.\pcond{H_3}{B_1} = \frac{\frac13\cdot\frac12}{\frac13\cdot\frac12 + \frac13\cdot1 + 0} = \frac{1/6}{1/2} = \frac13, \qquad \pcond{H_3}{B_2} = \frac{\frac13}{\frac12} = \frac23 .

Staying wins with probability 13\frac13, switching with probability 23\frac23.

Exercise 32.8 ★★★

An information channel transmits bits. Each bit is flipped by noise with probability ε=0.1\varepsilon = 0.1, independently. To protect a bit, it is sent three times and decoded by majority.

  1. Compute the probability that the decoded bit is wrong.
  2. The received word is 101101. What is the probability that the sent bit was 11? (Assume 00 and 11 are sent with equal probability.)
Solution

Solution of Exercise 32.8.

1. The majority is wrong when at least two of the three copies are flipped:

3ε2(1ε)+ε3=3(0.01)(0.9)+0.001=0.028,3\varepsilon^2(1-\varepsilon) + \varepsilon^3 = 3(0.01)(0.9) + 0.001 = 0.028,

much smaller than ε=0.1\varepsilon = 0.1: repetition coding works.

2. If 11 was sent (as 111111), receiving 101101 requires exactly one flip: probability ε(1ε)2=0.081\varepsilon(1-\varepsilon)^2 = 0.081. If 00 was sent (000000), two flips are needed: ε2(1ε)=0.009\varepsilon^2(1-\varepsilon) = 0.009. Bayes with equal priors:

P101 ⁣(sent 1)=0.0810.081+0.009=0.9.\pcond{101}{\,\text{sent }1} = \frac{0.081}{0.081 + 0.009} = 0.9 .

The majority decoding (1011101 \mapsto 1) is indeed the more probable guess.

32.5 Problem: The doctor, the judge and the spam filter

Problem 32.1

Weekend problem — Bayes’ formula against the base-rate fallacy: why a 99%99\,\% test can mean 2%2\,\%, why a one-in-a-million match convicts nobody, and how your mailbox thinks

A test that catches 99%99\,\% of cases comes back positive — and the true probability of disease is below 2%2\,\%. A DNA profile matching one person in a million is found — and the suspect is probably innocent. Both statements are correct, both have been misjudged by doctors and courts, and both are settled by one line of this chapter: Bayes’ formula (Theorem 32.5). This problem trains it on urns, then in the clinic, the courtroom and the inbox.

Part I — Fluency.

  1. A fair coin chooses urn I (22 red, 11 blue) or urn II (11 red, 33 blue), then one ball is drawn. Compute P(red)\P(\text{red}) with the law of total probability (Theorem 32.3).
  2. The ball is red: compute P(urn Ired)\P(\text{urn I} \mid \text{red}).
  3. One die roll: are the events “even” and “4\leq 4independent (Definition 32.7)? And “even” and “3\leq 3”?
  4. Two independent smoke alarms each trigger with probability 0.90.9 in a fire. Using Proposition 32.8, compute the probability that at least one triggers.
  5. Two cards without replacement: compute P(two kings)\P(\text{two kings}) with the multiplication rule (Proposition 32.2).

Part II — The doctor. A disease affects 11 person in 10001\,000. The test detects 99%99\,\% of the sick (sensitivity) but also fires on 5%5\,\% of the healthy (false positives).

  1. Natural frequencies: imagine 100000100\,000 people. How many are sick, how many healthy? How many positives does each group produce, and how many positives in all?
  2. From the counts, compute P(sickpositive)\P(\text{sick} \mid \text{positive}). Absorb the shock.
  3. Recompute it with Bayes’ formula and check the agreement.
  4. In surveys, most physicians answer “about 99%99\,\%”. Name the two conditional probabilities being confused, and explain why the tiny base rate drives the true answer.
  5. A second, independent test also comes back positive. Update: taking 1.9%1.9\,\% as the new prior, compute P(sicktwo positives)\P(\text{sick} \mid \text{two positives}). What is evidence accumulation doing?
  6. Compute P(sickpositive)\P(\text{sick} \mid \text{positive}) if the same test is used only on a high-risk group with prevalence 5%5\,\%. Deduce the public-health moral about mass screening of rare conditions.

Part III — The judge.

  1. A crime-scene DNA profile matches one person in a million. The suspect, found by searching a database of the city’s 1010 million inhabitants, matches. Expected number of innocent matches in the city? Given only the match, what is P(innocentmatch)\P(\text{innocent} \mid \text{match}), roughly?
  2. Name the fallacy — which probability did the prosecutor quote, which one did the court need? — and its exact parallel with question 9.
  3. The independence trap: two rare tragedies in one family were once squared into “one in 7373 million” by treating them as independent, convicting an innocent mother (the Sally Clark case). If the events share family risk factors so that the second, given the first, is 55 times likelier than the base rate, recompute the order of magnitude — and state the lesson about multiplying probabilities.
  4. The defense can cheat too: “ten innocents match, so the match proves nothing” ignores everything else. What does Bayes’ formula do with several pieces of evidence, and what single sentence should every juror know?

Part IV — The spam filter.

  1. Your mail is 40%40\,\% spam. The word “lottery” appears in 15%15\,\% of spam and 0.5%0.5\,\% of honest mail. A message contains it: compute P(spamlottery)\P(\text{spam} \mid \text{lottery}).
  2. Error-correcting repetition (Exercise 32.8 continued): with flip probability ε=0.1\varepsilon = 0.1, majority decoding of five copies fails with what probability? Compare with the three-copy code.
  3. A bit crosses 44 independent noisy relays, each flipping it with probability 0.10.1: it arrives correct exactly when the number of flips is even. Compute that probability twice: by summing the binomial terms, and by the elegant formula 1+(12ε)42\frac{1 + (1 - 2\varepsilon)^4}{2}.
  4. Real spam filters multiply the evidence of many words as if independent (“naive” Bayes). Why is that assumption false for words like “win” and “lottery” — and why does the filter work well anyway? (One or two sentences.)
  5. Finale — Bayes as the arithmetic of belief: prior ×\times likelihood, renormalize, posterior. Replay the three verdicts (clinic, courtroom, inbox) in one sentence each, then list the three traps this problem exposed: forgotten base rates, fake independence, and evidence read one piece at a time.
Solution

Solution of Problem 32.1.

1. P(red)=1223+1214=13+18=1124\P(\text{red}) = \frac12 \cdot \frac23 + \frac12 \cdot \frac14 = \frac13 + \frac18 = \frac{11}{24}.

2. P(Ired)=12231124=1/311/24=811\P(\text{I} \mid \text{red}) = \dfrac{\frac12 \cdot \frac23}{\frac{11}{24}} = \dfrac{1/3}{11/24} = \dfrac{8}{11}.

3. P(even4)=P({2,4})=13\P(\text{even} \cap \leq 4) = \P(\{2, 4\}) = \frac13 and P(even)P(4)=1223=13\P(\text{even})\P(\leq 4) = \frac12 \cdot \frac23 = \frac13: independent (unexpectedly!). For 3\leq 3: P({2})=16\P(\{2\}) = \frac16 against 1212=14\frac12 \cdot \frac12 = \frac14: dependent.

4. The complements of independent events are themselves independent, so

P(none)=0.1×0.1=0.01,P(at least one)=0.99.\P(\text{none}) = 0.1 \times 0.1 = 0.01, \qquad \P(\text{at least one}) = 0.99 .

5. 452×351=1221\frac{4}{52} \times \frac{3}{51} = \frac{1}{221}.

6. Sick: 100100; healthy: 9990099\,900. Positives: 9999 true (99 % of 100100) and 49954\,995 false (5 % of 9990099\,900): 50945\,094 positives in all.

7. P(sick+)=9950941.9%\P(\text{sick} \mid +) = \frac{99}{5\,094} \approx 1.9\,\%: of the people the test flags, fewer than one in fifty is actually sick.

8. 0.001×0.990.001×0.99+0.999×0.05=0.000990.050940.019\dfrac{0.001 \times 0.99}{0.001 \times 0.99 + 0.999 \times 0.05} = \dfrac{0.00099}{0.05094} \approx 0.019: the counts and the formula agree.

9. Confused: P(+sick)=99%\P(+ \mid \text{sick}) = 99\,\% (the test’s advertised quality) with P(sick+)\P(\text{sick} \mid +) (the patient’s actual question). With a base rate of 11000\frac{1}{1000}, the sick are so rare that even a 5%5\,\% leak from the huge healthy majority swamps the true positives fifty to one.

10. 0.019×0.990.019×0.99+0.981×0.0528%\dfrac{0.019 \times 0.99}{0.019 \times 0.99 + 0.981 \times 0.05} \approx 28\,\%. Each independent positive multiplies the odds by the same factor: evidence accumulates, and a third positive would push past 90%90\,\% — which is why confirmatory tests exist.

11. 0.05×0.990.05×0.99+0.95×0.0551%\dfrac{0.05 \times 0.99}{0.05 \times 0.99 + 0.95 \times 0.05} \approx 51\,\%: on a high-risk group the same test is informative. Moral: screen where the base rate is substantial; mass-screening a rare condition manufactures false alarms by the thousand.

12. Expected innocent matches: 107×106=1010^7 \times 10^{-6} = 10. Among the roughly 1111 matching people (1010 innocent, 11 guilty — if the culprit is in the city), the suspect found by the match alone is innocent with probability about 101191%\frac{10}{11} \approx 91\,\%.

13. The prosecutor quoted P(matchinnocent)=106\P(\text{match} \mid \text{innocent}) = 10^{-6}; the court needed P(innocentmatch)\P(\text{innocent} \mid \text{match}) — question 9’s confusion under oath. (And in the real case that popularized these errors, a second blunder compounded it: see question 14.)

14. Naive squaring: (18500)2172 million\left(\frac{1}{8500}\right)^2 \approx \frac{1}{72 \text{ million}}. With the second tragedy five times likelier given the first: 18500×58500114.5 million\frac{1}{8500} \times \frac{5}{8500} \approx \frac{1}{14.5 \text{ million}} — five times larger, and still ignoring that the alternative hypothesis must be weighed by Bayes too. Lesson: multiplying probabilities requires independence, and shared causes (genetics, environment) destroy it.

15. Bayes multiplies the likelihood ratios of all the evidence into one posterior: the match, the alibi, the fibers, each shifting the odds. The juror’s sentence: ask how probable the evidence is under both hypotheses, and never mistake the one conditional for its reverse.

16. 0.4×0.150.4×0.15+0.6×0.005=0.0600.06395%\dfrac{0.4 \times 0.15}{0.4 \times 0.15 + 0.6 \times 0.005} = \dfrac{0.060}{0.063} \approx 95\,\% spam: one word nearly settles it.

17. Five copies fail when 33, 44 or 55 flip: (53)ε3(1ε)2+(54)ε4(1ε)+ε50.0086\binom53 \varepsilon^3(1-\varepsilon)^2 + \binom54 \varepsilon^4 (1 - \varepsilon) + \varepsilon^5 \approx 0.0086 — against 0.0280.028 for three copies: repetition buys reliability at the price of bandwidth.

18. Even flips: (40)0.94+(42)0.920.12+(44)0.14=0.6561+0.0486+0.0001=0.7048\binom40 0.9^4 + \binom42 0.9^2 0.1^2 + \binom44 0.1^4 = 0.6561 + 0.0486 + 0.0001 = 0.7048; and 1+0.842=1+0.40962=0.7048\frac{1 + 0.8^4}{2} = \frac{1 + 0.4096}{2} = 0.7048: the trick formula tracks the bias (12ε)(1 - 2\varepsilon) through each relay.

19. Spammy words travel in packs — a message with “lottery” very likely contains “win”, so their joint evidence is weaker than the product pretends. The filter still works because the exaggeration usually pushes in the right direction: classification needs the correct side of 50%50\,\%, not the correct posterior.

20. Clinic: a rare condition turns a strong test into a weak verdict — update from the base rate, then accumulate. Courtroom: a rare match in a large city indicts the city, not the man — likelihoods are not verdicts. Inbox: many weak clues, multiplied, sort the mail — even naively. The three traps: forget the prior and be fooled; fake independence and be very fooled; read evidence piecemeal and never know what you know.