Introduction

New information changes probabilities. Knowing that a test came back positive, that a packet arrived late, or that the first card drawn was an ace, we should update how likely the other events are. Conditional probability is the rule for that update. Two theorems follow from it: the law of total probability (compute a probability by splitting into cases) and Bayes theorem (reverse the direction of conditioning: from "probability of the evidence given the cause" to "probability of the cause given the evidence"). Bayes theorem underlies spam filters, diagnostic reasoning and naive Bayes classifiers.

Prerequisites

Core concepts

Definition

For events AA and BB with P(B)>0P(B) > 0, the conditional probability of AA given BB is

P(A∣B)=P(A∩B)P(B).P(A \mid B) = \frac{P(A \cap B)}{P(B)} .

Knowing BB occurred shrinks the sample space to BB; P(A∣B)P(A \mid B) is the share of BB that also lies in AA. With equally likely outcomes, P(A∣B)=∣A∩B∣/∣B∣P(A \mid B) = |A \cap B| / |B|. P(A∣B)P(A \mid B) is undefined when P(B)=0P(B) = 0.

For fixed BB, P(⋅∣B)P(\cdot \mid B) is itself a probability: it satisfies the axioms, so P(Ac∣B)=1−P(A∣B)P(A^c \mid B) = 1 - P(A \mid B) and P(A1∪A2∣B)=P(A1∣B)+P(A2∣B)−P(A1∩A2∣B)P(A_1 \cup A_2 \mid B) = P(A_1 \mid B) + P(A_2 \mid B) - P(A_1 \cap A_2 \mid B). But in general P(A∣Bc)≠1−P(A∣B)P(A \mid B^c) \ne 1 - P(A \mid B).

Multiplication rule and chain rule

P(A∩B)=P(B) P(A∣B)=P(A) P(B∣A),P(A \cap B) = P(B)\,P(A \mid B) = P(A)\,P(B \mid A),
P(A1∩A2∩⋯∩An)=P(A1) P(A2∣A1) P(A3∣A1∩A2)⋯P(An∣A1∩⋯∩An−1),P(A_1 \cap A_2 \cap \cdots \cap A_n) = P(A_1)\,P(A_2 \mid A_1)\,P(A_3 \mid A_1 \cap A_2) \cdots P(A_n \mid A_1 \cap \cdots \cap A_{n-1}),

provided the conditioning events have positive probability. This is the rule for sequential experiments such as drawing without replacement.

Independence revisited

For P(B)>0P(B) > 0: AA and BB are independent if and only if P(A∣B)=P(A)P(A \mid B) = P(A). So independence means "learning BB does not change the probability of AA".

AA and BB are conditionally independent given CC if P(A∩B∣C)=P(A∣C) P(B∣C)P(A \cap B \mid C) = P(A \mid C)\,P(B \mid C). Conditional independence and independence do not imply each other.

Law of total probability

Let B1,…,BnB_1, \ldots, B_n be a partition of SS (mutually exclusive, exhaustive) with every P(Bi)>0P(B_i) > 0. Then for any event AA:

P(A)=∑i=1nP(A∣Bi) P(Bi).P(A) = \sum_{i=1}^{n} P(A \mid B_i)\, P(B_i) .

The simplest case uses BB and BcB^c: P(A)=P(A∣B)P(B)+P(A∣Bc)P(Bc)P(A) = P(A \mid B)P(B) + P(A \mid B^c)P(B^c).

Bayes theorem

With the same partition and P(A)>0P(A) > 0:

P(Bj∣A)=P(A∣Bj) P(Bj)∑i=1nP(A∣Bi) P(Bi).P(B_j \mid A) = \frac{P(A \mid B_j)\, P(B_j)}{\sum_{i=1}^{n} P(A \mid B_i)\, P(B_i)} .

Vocabulary: P(Bj)P(B_j) is the prior, P(A∣Bj)P(A \mid B_j) the likelihood, P(Bj∣A)P(B_j \mid A) the posterior, and the denominator is P(A)P(A) by total probability. The posteriors over the partition add to 1.

Probability tree method. Draw a branch for each BiB_i labelled P(Bi)P(B_i), then sub-branches for AA and AcA^c labelled with conditional probabilities. Multiply along a path for the joint probability; add paths ending in AA for P(A)P(A); divide one path by that sum for Bayes.

Probability tree for total probability and Bayes theorem
Figure 1. The diagnostic-test tree of Example 1: first split on disease (0.01) or no disease (0.99), then on test result. The two "positive" leaves carry 0.0099 and 0.0495; the posterior is 0.0099/0.0594=1/60.0099/0.0594 = 1/6.

P(A∣B)P(A \mid B) is not P(B∣A)P(B \mid A)

Confusing the two is the prosecutor's fallacy. They are related by Bayes: P(B∣A)=P(A∣B) P(B)/P(A)P(B \mid A) = P(A \mid B)\,P(B)/P(A). They are equal only when P(A)=P(B)P(A) = P(B) (or P(A∩B)=0P(A \cap B) = 0).

Worked examples

Example 1: diagnostic test (base rates)

A disease affects 1% of a population. A test detects it in 99% of patients who have it (sensitivity), and gives a false positive for 5% of people who do not. A random person tests positive. What is the probability they have the disease?

P(+)=0.99×0.01+0.05×0.99=0.0099+0.0495=0.0594,P(+) = 0.99 \times 0.01 + 0.05 \times 0.99 = 0.0099 + 0.0495 = 0.0594,
P(D∣+)=0.00990.0594=16≈0.167.P(D \mid +) = \frac{0.0099}{0.0594} = \frac{1}{6} \approx 0.167 .

Despite a 99% sensitive test, a positive result means only about a 1 in 6 chance of disease, because healthy people vastly outnumber sick ones. A second independent positive test (conditionally independent given the disease status) raises it to 0.992×0.010.992×0.01+0.052×0.99=0.0098010.012276≈0.798\dfrac{0.99^2 \times 0.01}{0.99^2 \times 0.01 + 0.05^2 \times 0.99} = \dfrac{0.009801}{0.012276} \approx 0.798.

Example 2: machines and defects

Machines M1,M2,M3M_1, M_2, M_3 make 50%, 30% and 20% of a factory's items, with defect rates 1%, 2% and 3%.

P(D)=0.5(0.01)+0.3(0.02)+0.2(0.03)=0.005+0.006+0.006=0.017.P(D) = 0.5(0.01) + 0.3(0.02) + 0.2(0.03) = 0.005 + 0.006 + 0.006 = 0.017 .

A random item is defective. P(M3∣D)=0.006/0.017=6/17≈0.353P(M_3 \mid D) = 0.006/0.017 = 6/17 \approx 0.353; similarly P(M1∣D)=5/17P(M_1 \mid D) = 5/17, P(M2∣D)=6/17P(M_2 \mid D) = 6/17. The three posteriors add to 1.

Example 3: drawing without replacement

An urn has 5 red and 3 blue balls. Two are drawn without replacement.

  • P(both red)=58⋅47=2056=514P(\text{both red}) = \frac{5}{8} \cdot \frac{4}{7} = \frac{20}{56} = \frac{5}{14} (chain rule).
  • P(second red)=58⋅47+38⋅57=3556=58P(\text{second red}) = \frac{5}{8}\cdot\frac{4}{7} + \frac{3}{8}\cdot\frac{5}{7} = \frac{35}{56} = \frac{5}{8} (total probability). By symmetry, every draw position has the same marginal probability of red.
  • P(first red∣second red)=20/5635/56=47P(\text{first red} \mid \text{second red}) = \dfrac{20/56}{35/56} = \dfrac{4}{7}.

Example 4: conditioning on partial information

A family has two children, each independently a boy or girl with probability 1/21/2. Given that at least one is a boy, the probability that both are boys is 1/43/4=13\dfrac{1/4}{3/4} = \dfrac{1}{3}, not 1/21/2. Given that the elder is a boy, it is 1/21/2. The sample spaces differ: {BB,BG,GB}\{BB, BG, GB\} versus {BB,BG}\{BB, BG\}.

Example 5: Monty Hall

A prize is behind one of three doors. You pick door 1. The host, who knows where the prize is and always opens an unpicked door without the prize (choosing at random when he has a choice), opens door 3. Switching to door 2 wins with probability 2/32/3: P(prize at 2∣host opens 3)=1⋅1312⋅13+1⋅13+0⋅13=23P(\text{prize at 2} \mid \text{host opens 3}) = \dfrac{1 \cdot \frac13}{\frac12 \cdot \frac13 + 1 \cdot \frac13 + 0 \cdot \frac13} = \dfrac{2}{3}. The answer depends on the stated host behaviour.

Example 6: a noisy binary channel

A transmitter sends 0 with probability 0.6 and 1 with probability 0.4. The channel flips a 0 into a 1 with probability 0.1, and a 1 into a 0 with probability 0.2.

P(receive 1)=0.6×0.1+0.4×0.8=0.06+0.32=0.38,P(sent 1∣receive 1)=0.320.38=1619≈0.842.P(\text{receive } 1) = 0.6 \times 0.1 + 0.4 \times 0.8 = 0.06 + 0.32 = 0.38, \qquad P(\text{sent } 1 \mid \text{receive } 1) = \frac{0.32}{0.38} = \frac{16}{19} \approx 0.842 .

Similarly P(receive 0)=0.62P(\text{receive } 0) = 0.62 and P(sent 0∣receive 0)=0.54/0.62=27/31≈0.871P(\text{sent } 0 \mid \text{receive } 0) = 0.54/0.62 = 27/31 \approx 0.871. The probability of a correct decision when the receiver outputs whatever arrives is 0.54+0.32=0.860.54 + 0.32 = 0.86.

Example 7: moving a ball between urns

Urn I has 3 white and 2 black balls; urn II has 4 white and 4 black. One ball is moved at random from urn I to urn II, then a ball is drawn from urn II. Split on the moved ball:

P(W)=35⋅59+25⋅49=1545+845=2345≈0.511.P(W) = \frac35 \cdot \frac59 + \frac25 \cdot \frac49 = \frac{15}{45} + \frac{8}{45} = \frac{23}{45} \approx 0.511 .

Given that the ball drawn is white, the moved ball was white with probability 15/4523/45=1523≈0.652\dfrac{15/45}{23/45} = \dfrac{15}{23} \approx 0.652, up from the prior 3/53/5.

Example 8: a randomly chosen coin

A box holds one fair coin and one two-headed coin. A coin is picked at random and tossed twice. Given the coin, the tosses are independent. Unconditionally, P(H1)=P(H2)=12⋅12+12⋅1=34P(H_1) = P(H_2) = \frac12 \cdot \frac12 + \frac12 \cdot 1 = \frac34, but

P(H1∩H2)=12⋅14+12⋅1=58≠916=P(H1)P(H2),P(H_1 \cap H_2) = \frac12 \cdot \frac14 + \frac12 \cdot 1 = \frac58 \ne \frac{9}{16} = P(H_1)P(H_2),

so the tosses are dependent: a first head is evidence for the two-headed coin. After two heads, P(two-headed∣H1∩H2)=1/25/8=45P(\text{two-headed} \mid H_1 \cap H_2) = \dfrac{1/2}{5/8} = \dfrac45, and the next toss is a head with probability 45⋅1+15⋅12=910\frac45 \cdot 1 + \frac15 \cdot \frac12 = \frac{9}{10}.

Example 9: "at least one" conditions

Two fair dice. "At least one six" has 11 of the 36 outcomes, so P(both six∣at least one six)=1/11P(\text{both six} \mid \text{at least one six}) = 1/11 and P(sum 7∣at least one six)=2/11P(\text{sum } 7 \mid \text{at least one six}) = 2/11 (outcomes (1,6)(1, 6) and (6,1)(6, 1)). Conditioning on "the first die is a six" instead gives 1/61/6 for both. As in Example 4, the wording of the condition changes the reduced sample space.

Important properties and observations

  • P(A∣B)+P(Ac∣B)=1P(A \mid B) + P(A^c \mid B) = 1, but P(A∣B)+P(A∣Bc)P(A \mid B) + P(A \mid B^c) can be anything in [0,2][0, 2].
  • If B⊆AB \subseteq A, then P(A∣B)=1P(A \mid B) = 1. If A∩B=∅A \cap B = \emptyset, P(A∣B)=0P(A \mid B) = 0.
  • P(A∣B)>P(A)P(A \mid B) > P(A) if and only if P(B∣A)>P(B)P(B \mid A) > P(B) (positive association is symmetric), assuming both probabilities are positive.
  • A low base rate makes most positives false unless the false-positive rate is small compared with the base rate. Writing p=P(D)p=P(D) for the disease prevalence, P(D∣+)<1/2P(D \mid +) < 1/2 if and only if P(+∣Dc)(1−p)>P(+∣D)pP(+ \mid D^c)(1 - p) > P(+ \mid D)p. In Example 1 this holds (0.0495 against 0.0099). If instead p=0.01p = 0.01, sensitivity is 0.99 and specificity is 0.9999, then P(D∣+)≈0.990P(D \mid +) \approx 0.990, so almost all positives are true.
  • Finite-ratio odds form of Bayes (assume 0<P(B)<10<P(B)<1, P(A∣Bc)>0P(A\mid B^c)>0, and P(A)>0P(A)>0; zero denominators/infinite odds require separate handling): P(B∣A)P(Bc∣A)=P(A∣B)P(A∣Bc)⋅P(B)P(Bc)\dfrac{P(B \mid A)}{P(B^c \mid A)} = \dfrac{P(A \mid B)}{P(A \mid B^c)} \cdot \dfrac{P(B)}{P(B^c)} (posterior odds = likelihood ratio times prior odds).
  • Sequential updating. If observations are conditionally independent given the hypothesis, updating one observation at a time (each posterior becomes the next prior) gives the same answer as conditioning on all of them at once. In Example 1, updating twice on a positive test gives the same 0.7980.798.

GATE examination perspective

  • Bayes with a partition. Two or three sources (machines, urns, channels) with given rates, and a question about the source given an outcome. Draw the tree, multiply along paths, divide.
  • Total probability. "Probability that the second item is defective", "probability that a bit is received as 1".
  • Sequential draws. Chain rule; symmetry of draw positions without replacement.
  • Trap: swapping P(A∣B)P(A \mid B) and P(B∣A)P(B \mid A).
  • Trap: "at least one is a boy" versus "the elder is a boy"; restate the condition as a precise event before computing.
  • Numerical answers. Keep fractions exact until the last step; round only when the required precision is known.
  • Two-stage experiments. Move a ball, pick an urn or a coin, then observe: total probability over the first stage, Bayes for "which first-stage outcome" (Examples 7 and 8).
  • Trap: treating tosses of a randomly chosen coin as independent; they are independent only given the coin.

Summary

Sources

  1. S. Ross, A First Course in Probability, 8th ed., Pearson Prentice Hall, 2010: Chapter 3 (Conditional Probability and Independence), Sections 3.2 (Conditional Probabilities), 3.3 (Bayes's Formula) and 3.4 (Independent Events).

Next steps