Skip to content

Mathematics · Ch 9 — Probability

Bayes' Theorem

9.5

Bayes' Theorem

Partition of a Sample Space

To understand Bayes' Theorem we first see how a sample space can be broken into useful pieces. Consider a random experiment with sample space SS and nn events E1,E2,…,EnE_1, E_2, \ldots, E_n that are:

  1. Mutually exclusive: Ei∩Ej=∅E_i \cap E_j = \emptyset for all i≠ji \neq j.
  2. Exhaustive: E1∪E2∪⋯∪En=SE_1 \cup E_2 \cup \cdots \cup E_n = S.

Such a set {E1,E2,…,En}\{E_1, E_2, \ldots, E_n\} is called a partition of SS.

Note

A partition divides the sample space into non-overlapping pieces that together account for every outcome — like cutting a cake into slices, each separate, every part belonging to exactly one slice.

For any event AA, the partition lets us write AA as a union of disjoint pieces:

A=(A∩E1)∪(A∩E2)∪⋯∪(A∩En)A = (A \cap E_1) \cup (A \cap E_2) \cup \cdots \cup (A \cap E_n)

Since the EiE_i are mutually exclusive, so are the A∩EiA \cap E_i, hence:

P(A)=P(A∩E1)+P(A∩E2)+⋯+P(A∩En)P(A) = P(A \cap E_1) + P(A \cap E_2) + \cdots + P(A \cap E_n)

Using P(A∩Ei)=P(Ei)⋅P(A∣Ei)P(A \cap E_i) = P(E_i) \cdot P(A|E_i), we obtain the law of total probability:

P(A)=P(E1)P(A∣E1)+P(E2)P(A∣E2)+⋯+P(En)P(A∣En)P(A) = P(E_1) P(A|E_1) + P(E_2) P(A|E_2) + \cdots + P(E_n) P(A|E_n)

This is the backbone of Bayes' Theorem.

Important

The law of total probability requires that the EiE_i form a partition of SS and that P(Ei)>0P(E_i) > 0 for every ii.


The Problem of Reverse Probability

Consider the opening example. Bag I has 2 white and 3 red balls; Bag II has 4 white and 5 red. A bag is chosen at random, then a ball is drawn. It is easy to find the probability of drawing white given which bag was chosen. But the real question is the reverse: if the drawn ball is white, what is the probability it came from Bag II?

This is a reverse probability problem — we know the effect (the ball's colour) and want to infer the cause (which bag). Bayes' formula uses conditional probability to reverse the conditioning, from P(effect∣cause)P(\text{effect}|\text{cause}) to P(cause∣effect)P(\text{cause}|\text{effect}).


Statement of Bayes' Theorem

Let E1,E2,…,EnE_1, E_2, \ldots, E_n be a partition of SS with P(Ei)>0P(E_i) > 0, and let AA be any event with P(A)>0P(A) > 0. Then for any k=1,2,…,nk = 1, 2, \ldots, n:

P(Ek∣A)=P(Ek)P(A∣Ek)∑i=1nP(Ei)P(A∣Ei)P(E_k|A) = \frac{P(E_k) P(A|E_k)}{\displaystyle\sum_{i=1}^{n} P(E_i) P(A|E_i)}

The denominator is just P(A)P(A) by the law of total probability.

P(Ek∣A)=P(Ek)P(A∣Ek)P(A)P(E_k|A) = \frac{P(E_k) P(A|E_k)}{P(A)}


Proof of Bayes' Theorem

›Proof

By the definition of conditional probability, P(Ek∣A)=P(Ek∩A)P(A)P(E_k|A) = \dfrac{P(E_k \cap A)}{P(A)}.

The multiplication rule gives P(Ek∩A)=P(Ek)⋅P(A∣Ek)P(E_k \cap A) = P(E_k) \cdot P(A|E_k), and the law of total probability gives P(A)=∑i=1nP(Ei)P(A∣Ei)P(A) = \sum_{i=1}^{n} P(E_i) P(A|E_i). Substituting:

P(Ek∣A)=P(Ek)P(A∣Ek)∑i=1nP(Ei)P(A∣Ei)P(E_k|A) = \frac{P(E_k) P(A|E_k)}{\displaystyle\sum_{i=1}^{n} P(E_i) P(A|E_i)}


Understanding the Terms

  • P(Ek)P(E_k) — the prior probability: our initial belief in EkE_k before observing data.
  • P(A∣Ek)P(A|E_k) — the likelihood: the probability of observing AA given EkE_k.
  • P(Ek∣A)P(E_k|A) — the posterior probability: our updated belief in EkE_k after observing AA.
  • P(A)P(A) — the evidence: the total probability of AA under all causes.
Tip

Posterior=Prior×LikelihoodEvidence\text{Posterior} = \frac{\text{Prior} \times \text{Likelihood}}{\text{Evidence}}


Worked Example: The Two-Bag Problem

Step 1 — Define events. Let E1E_1 = Bag I chosen, E2E_2 = Bag II chosen, AA = a white ball is drawn.

Step 2 — Given probabilities. A bag is chosen at random, so P(E1)=P(E2)=12P(E_1) = P(E_2) = \frac{1}{2}. Bag I has 2 white of 5, Bag II has 4 white of 9:

P(A∣E1)=25,P(A∣E2)=49P(A|E_1) = \frac{2}{5}, \quad P(A|E_2) = \frac{4}{9}

Step 3 — Total probability of white.

P(A)=12⋅25+12⋅49=15+29=945+1045=1945P(A) = \frac{1}{2} \cdot \frac{2}{5} + \frac{1}{2} \cdot \frac{4}{9} = \frac{1}{5} + \frac{2}{9} = \frac{9}{45} + \frac{10}{45} = \frac{19}{45}

Step 4 — Apply Bayes' Theorem for P(E2∣A)P(E_2|A):

P(E2∣A)=P(E2)P(A∣E2)P(A)=291945=29×4519=1019P(E_2|A) = \frac{P(E_2) P(A|E_2)}{P(A)} = \frac{\frac{2}{9}}{\frac{19}{45}} = \frac{2}{9} \times \frac{45}{19} = \frac{10}{19}

Important

The answer 1019\frac{10}{19} differs from the prior 12\frac{1}{2}: observing a white ball has updated our belief, making Bag II more likely because it had a higher proportion of white balls.


Related Results

Property (I): Bayes' Rule for Two Events

When the partition is just EE and its complement E′E', Bayes' Theorem becomes:

P(E∣A)=P(E)P(A∣E)P(E)P(A∣E)+P(E′)P(A∣E′)P(E|A) = \frac{P(E) P(A|E)}{P(E) P(A|E) + P(E') P(A|E')}

The denominator is the two-event law of total probability P(A)=P(E)P(A∣E)+P(E′)P(A∣E′)P(A) = P(E) P(A|E) + P(E') P(A|E').

Property (II): Posterior Odds Ratio

For any two events EiE_i, EjE_j from the partition:

P(Ei∣A)P(Ej∣A)=P(Ei)P(Ej)×P(A∣Ei)P(A∣Ej)\frac{P(E_i|A)}{P(E_j|A)} = \frac{P(E_i)}{P(E_j)} \times \frac{P(A|E_i)}{P(A|E_j)}

so the posterior odds equal the prior odds times the likelihood ratio.

›Proof

Dividing P(Ei∣A)=P(Ei)P(A∣Ei)P(A)P(E_i|A) = \frac{P(E_i) P(A|E_i)}{P(A)} by P(Ej∣A)=P(Ej)P(A∣Ej)P(A)P(E_j|A) = \frac{P(E_j) P(A|E_j)}{P(A)}, the common P(A)P(A) cancels, giving the result. …