girgit.org

Probability

Working backwards from the clue: Bayes' theorem

The big ideaBayes' theorem turns "the chance of the clue, given the cause" into "the chance of the cause, given the clue": take the one path that leads through your cause and divide by all the paths that produce the clue.

In simple words

You find a muddy footprint on the kitchen floor. Was it your brother or the dog? You think about how often each one comes in, and how likely each is to leave that kind of print. The one who is both common and messy is the best guess. Bayes' theorem is that kind of thinking, done with exact numbers.

Back to the two bags

Bag I has 3 red and 2 blue balls; Bag II has 1 red and 4 blue. A coin picks the bag and a ball is drawn. It is red. What is the chance it came from Bag I?

Think of the tree from the last page. There are two paths to "red": Bag I then red, with chance \( \frac12 \times \frac35 = \frac{3}{10} \), and Bag II then red, with \( \frac12 \times \frac15 = \frac1{10} \). Together P(red) = \( \frac25 \). Knowing the ball is red, we keep only these two paths, and the Bag I path is \( \frac{3}{10} \) of the \( \frac{4}{10} \):

\[ \text{P}(\text{Bag I} \mid \text{red}) = \frac{3/10}{4/10} = \frac34 \]

Before the draw, Bag I had chance \( \frac12 \). The red ball pushed it up to \( \frac34 \), because Bag I is much richer in red.

Bayes' theorem

Let \( E_1, E_2, \dots, E_n \) be non-empty events forming a partition of S, and let A be any event with \( \text{P}(A) \ne 0 \). Then for each i,

\[ \text{P}(E_i \mid A) = \frac{\text{P}(E_i)\,\text{P}(A \mid E_i)}{\sum_{j=1}^{n} \text{P}(E_j)\,\text{P}(A \mid E_j)} \]

Proof in three steps. (1) By definition, \( \text{P}(E_i \mid A) = \frac{\text{P}(A \cap E_i)}{\text{P}(A)} \). (2) By the multiplication rule, the top is \( \text{P}(E_i)\,\text{P}(A \mid E_i) \). (3) By the theorem of total probability, the bottom is \( \sum_j \text{P}(E_j)\,\text{P}(A \mid E_j) \).

The theorem is named after Thomas Bayes (1701–1761), an English minister and mathematician; it was published in 1763, after his death. It solves the problem of reverse probability.

The words that go with it

  • The events \( E_1, \dots, E_n \) are called hypotheses: the possible causes or explanations.
  • \( \text{P}(E_i) \) is the a priori probability (priori probability) of \( E_i \): what you believed before the clue. "Prior" for short.
  • \( \text{P}(E_i \mid A) \) is the a posteriori probability of \( E_i \): what you believe after seeing the clue A. "Posterior" for short.
  • Because exactly one hypothesis is true, Bayes' theorem gives the chance that a particular one was the cause. So it is also called the formula for the probability of causes.

Try it: guess first, then see the table below as a picture, and change the factory.

A table that does the work

Back to the phone factory: lines 1, 2, 3 make 50%, 30%, 20% of the phones, with defect rates 1%, 2%, 3%. A phone is found defective. Which line made it?

CausePrior P(Eᵢ)P(defective | Eᵢ)ProductPosterior = product ÷ 0.017
Line 10.50.010.005\( \frac{5}{17} \approx 0.29 \)
Line 20.30.020.006\( \frac{6}{17} \approx 0.35 \)
Line 30.20.030.006\( \frac{6}{17} \approx 0.35 \)
Total10.0171

Line 1 makes half the phones, but only 5 in 17 of the faulty ones. Line 3 makes the fewest phones but, being the sloppiest, as many faulty ones as line 2. The "Product" column is the multiplication rule; its total is the theorem of total probability; the last column is Bayes.

Worked example: three cards in a hat

One card is red on both sides, one is white on both sides, and one is red on one side and white on the other. A card is picked at random and laid down; the top is red. What is the chance the other side is red too? (Most people guess \( \frac12 \).)

  1. Hypotheses: RR, WW, RW cards, each with prior \( \frac13 \).
  2. P(red on top | RR) = 1, P(red on top | WW) = 0, P(red on top | RW) = \( \frac12 \).
  3. Total: P(red on top) \( = \frac13(1 + 0 + \frac12) = \frac12 \).
  4. P(RR | red on top) \( = \frac{\frac13 \times 1}{\frac12} = \frac23 \).

The RR card has two red faces that could be on top, the RW card only one. So a red face is twice as likely to belong to RR.

Try it. In the moving-ball problem (Bag I: 2 red, 3 black; Bag II: 3 red, 3 black; one ball moved from I to II, then a ball drawn from II), the ball drawn is red. What is the chance the moved ball was black?

Answer
Paths to red: moved red, \( \frac25 \times \frac47 = \frac{8}{35} \); moved black, \( \frac35 \times \frac37 = \frac{9}{35} \). So P(moved black | red) \( = \frac{9/35}{17/35} = \frac{9}{17} \).

Words to know

Bayes' theorem
P(Eᵢ|A) = P(Eᵢ) P(A|Eᵢ) ÷ Σ P(Eⱼ) P(A|Eⱼ).
Hypotheses
The possible causes Eᵢ, which form a partition.
A priori probability
P(Eᵢ): the chance of a cause before the clue.
A posteriori probability
P(Eᵢ|A): the chance of a cause after the clue.
Probability of causes
Another name for Bayes' formula: it finds which cause produced the result.

Box X has 4 good and 1 bad bulb; box Y has 2 good and 3 bad. A box is chosen at random and a bulb taken from it is bad. What is P(it came from Y)?

  1. \( \frac35 \)
  2. \( \frac34 \)
  3. \( \frac12 \)

In Bayes' theorem, the denominator \( \sum_j \text{P}(E_j)\,\text{P}(A \mid E_j) \) equals

  1. 1, always
  2. P(A)
  3. P(Eᵢ ∩ A)

A posteriori probability means

  1. the chance of a cause before any evidence
  2. the chance of the evidence given a cause
  3. the chance of a cause after the evidence