Bayes' Rule

Probability 1 · Lecture slides

The plan

  • Several cases, and one thing we observe
  • Part 1: which case is behind it, on the Titanic
  • Part 2: the same with probabilities only, and then a second observation

Last time: the late bus

  • Rain on 3 mornings in 10
  • The bus was late, and rain went up to about 7 in 10
  • That was two cases: rain or dry
  • Today: any number of cases, and the names of the two rules

The Titanic, by class

  • First class: 15% of the people on board. About 62% of them survived
  • Second class: 13% of the people. About 41% survived
  • Third class: 32% of the people. About 25% survived
  • Crew: 40% of the people. About 24% survived

What share of everyone on board survived?

  1. About 24%
  2. About 32%
  3. About 38%
  4. About 50%

Each group counts by its size

P(survived)≈0.15⋅0.62+0.13⋅0.41+0.32⋅0.25+0.40⋅0.24≈0.09+0.05+0.08+0.10=0.32\begin{aligned} P(\text{survived}) &\approx 0.15 \cdot 0.62 + 0.13 \cdot 0.41 \\[1.5ex] &\qquad + 0.32 \cdot 0.25 + 0.40 \cdot 0.24 \\[2.5ex] &\approx 0.09 + 0.05 + 0.08 + 0.10 \\[2.5ex] &= 0.32 \end{aligned}

The law of total probability

Rule

P(B)=P(A1) P(B∣A1)+⋯+P(An) P(B∣An)\begin{gathered} P(B) = P(A_1)\,P(B \mid A_1) \\[1ex] {} + \dots + P(A_n)\,P(B \mid A_n) \end{gathered}

BB is what we observe. The cases A1,…,AnA_1, \dots, A_n are a partition: exactly one of them happens.

Pick a survivor at random. Which group is most likely?

  1. First class
  2. Second class
  3. Third class
  4. Crew

Before we look

On paper The four groups had 325, 285, 706, and 885 people, and about 62%, 41%, 25%, and 24% of them survived. About how many people survived in each group?

The 2201 people, group by group

Bayes' rule

Rule

P(Ai∣B)=P(Ai) P(B∣Ai)P(B)P(A_i \mid B) = \frac{P(A_i)\,P(B \mid A_i)}{P(B)}

BB is what we observe, and AiA_i is one of the cases. P(B)P(B) is the sum from the law of total probability.

The rule gives the same 30%

P(crew∣survived)=P(crew) P(survived∣crew)P(survived)=8852201⋅212885711/2201=212711≈0.30\begin{aligned} P(\text{crew} \mid \text{survived}) &= \frac{P(\text{crew})\,P(\text{survived} \mid \text{crew})}{P(\text{survived})} \\[2.5ex] &= \frac{\dfrac{885}{2201} \cdot \dfrac{212}{885}}{711/2201} \\[3.5ex] &= \frac{212}{711} \approx 0.30 \end{aligned}

Your turn: use the rule

On paper Second class was 13% of the people on board, and 41% of second class survived. Of everyone on board, 32% survived. Find the probability that a survivor was in second class.

Second class, given survived

P(second∣survived)=P(second) P(survived∣second)P(survived)≈0.13⋅0.410.32≈0.17\begin{aligned} P(\text{second} \mid \text{survived}) &= \frac{P(\text{second})\,P(\text{survived} \mid \text{second})}{P(\text{survived})} \\[2.5ex] &\approx \frac{0.13 \cdot 0.41}{0.32} \\[2.5ex] &\approx 0.17 \end{aligned}

Your turn: a person who died

On paper Survived: 203 of 325 in first class, 118 of 285 in second, 178 of 706 in third, and 212 of 885 in the crew. Pick a person who died at random. Find the probability that this person was in the crew, and the probability that this person was in first class.

A person who died

P(crew∣died)=885−2122201−711=6731490≈0.45P(first class∣died)=325−2032201−711=1221490≈0.08\begin{aligned} P(\text{crew} \mid \text{died}) &= \frac{885 - 212}{2201 - 711} = \frac{673}{1490} \approx 0.45 \\[2.5ex] P(\text{first class} \mid \text{died}) &= \frac{325 - 203}{2201 - 711} = \frac{122}{1490} \approx 0.08 \end{aligned}

A large group with a low rate can count for as much as a small group with a high rate.

Part 1 is done

Part 2: no counts, and a second observation.

A wreck on the sea floor

  • It lies in one of three zones: north, middle, or south
  • North with probability 2/5, middle with 2/5, south with 1/5
  • A search of the right zone finds it 9 times in 10
  • A search of a wrong zone finds nothing

The north zone is searched. Nothing. How likely is the north now?

  1. 4%
  2. About 6%
  3. 10%
  4. Still 40%

Nobody searched the south zone. What happens to its probability?

  1. It goes up
  2. It stays at 1/5
  3. It goes down

Draw it in stages

On paper North 2/5, middle 2/5, south 1/5. A search of the right zone finds the wreck 9 times in 10. Draw a tree: first which zone holds the wreck, then whether the search of the north finds it. Write a probability on every branch.

The tree for the search of the north

Bayes' rule for the north zone

P(north∣nothing)=P(north) P(nothing∣north)P(nothing)=25⋅11016/25=1/2516/25=116\begin{aligned} P(\text{north} \mid \text{nothing}) &= \frac{P(\text{north})\,P(\text{nothing} \mid \text{north})}{P(\text{nothing})} \\[2.5ex] &= \frac{\dfrac{2}{5} \cdot \dfrac{1}{10}}{16/25} \\[3.5ex] &= \frac{1/25}{16/25} = \frac{1}{16} \end{aligned}

The map, before and after

Prior and posterior

  • Prior: the probability of a case before the observation
  • Posterior: the probability of the case given the observation
  • On the map, the large number is the posterior and "was" is the prior

Search again: the middle zone. Nothing.

On paper Start from 1/16, 10/16, and 5/16. The middle zone is searched, and a search of the right zone misses 1 time in 10. Nothing is found. Find the three new probabilities.

The second search: the middle zone

Both searches find nothing, in one step

P(both)=25⋅110+25⋅110+15⋅1=125+125+525=725P(north∣both)=1/257/25=17\begin{aligned} P(\text{both}) &= \frac{2}{5} \cdot \frac{1}{10} + \frac{2}{5} \cdot \frac{1}{10} + \frac{1}{5} \cdot 1 \\[2.5ex] &= \frac{1}{25} + \frac{1}{25} + \frac{5}{25} = \frac{7}{25} \\[2.5ex] P(\text{north} \mid \text{both}) &= \frac{1/25}{7/25} = \frac{1}{7} \end{aligned}

The south zone went from 1 in 5 to 5 in 7, and nobody searched it.

One more report

  • The search ship reports a calm sea
  • The sea is calm on 7 days in 10, wherever the wreck is
  • Does the map change?

Given a calm sea

P(south∣calm)=57⋅710(17+17+57)⋅710=57\begin{aligned} P(\text{south} \mid \text{calm}) &= \frac{\dfrac{5}{7} \cdot \dfrac{7}{10}}{\left(\dfrac{1}{7} + \dfrac{1}{7} + \dfrac{5}{7}\right) \cdot \dfrac{7}{10}} \\[3.5ex] &= \frac{5}{7} \end{aligned}

An observation that is equally likely in every case changes nothing.

Summary

  • A partition: exactly one of the cases happens
  • Total probability: add one term for each case
  • Bayes' rule: the term of one case, divided by the sum
  • A posterior is the prior for the next observation

Before the next class

  • Read the lesson "Bayes' Rule"
  • Work its six practice problems on paper
  • Bring your answer to "Three doors" and be ready to defend it

Arrow keys to step and move · N for notes · F to fill the screen