Foundations of Computer Science Lecture 16 Conditional Probability - - PowerPoint PPT Presentation

foundations of computer science lecture 16 conditional
SMART_READER_LITE
LIVE PREVIEW

Foundations of Computer Science Lecture 16 Conditional Probability - - PowerPoint PPT Presentation

Foundations of Computer Science Lecture 16 Conditional Probability Updating a Probability when New Information Arrives Conditional Probability Traps Law of Total Probability Last Time 1 Outcome-tree method for computing probability. 2


slide-1
SLIDE 1

Foundations of Computer Science Lecture 16 Conditional Probability

Updating a Probability when New Information Arrives Conditional Probability Traps Law of Total Probability

slide-2
SLIDE 2

Last Time

1 Outcome-tree method for computing probability. 2 Probability and sets. ◮ Probability space. ◮ Event is a subset of outcomes. ◮ Can get complex events using set (logical) operations. 3 Uniform probability space ◮ Toss 10 coins. Each sequence (e.g. HTHHHTTTHH) has equal probability. ◮ Roll 3 dice. Each sequence (e.g. (2,4,5)) has equal probability. ◮ Probability of event ∼ event size. 4 Infinite probability space. ◮ Toss a coin until you get heads (possibly never ending). Creator: Malik Magdon-Ismail Conditional Probability: 2 / 16 Today →

slide-3
SLIDE 3

Today: Conditional Probability

1

New information changes a probability.

2

Definition of conditional probability from regular probability.

3

Conditional probability traps

Sampling bias. Transposed conditional.

4

Law of total probability.

Probabilistic case-by-case analysis.

Creator: Malik Magdon-Ismail Conditional Probability: 3 / 16 Flu Season →

slide-4
SLIDE 4

Flu Season

1 Chances a random person has the flu is about 0.01 (or 1%) (prior probability).

Probability of flu : P[flu] ≈ 0.01.

Creator: Malik Magdon-Ismail Conditional Probability: 4 / 16 CS, MATH and Dual CS-MATH Majors →

slide-5
SLIDE 5

Flu Season

1 Chances a random person has the flu is about 0.01 (or 1%) (prior probability).

Probability of flu : P[flu] ≈ 0.01.

2 You have a slight fever – new information. Chances of flu “increase”.

Probability of flu given fever : P[flu | fever] ≈ 0.4.

◮ New information changes the prior probability to the posterior probability. ◮ Translate posterior as “After you get the new information.”

P[A | B] is the (updated) conditional probability of A, given the new information B.

Creator: Malik Magdon-Ismail Conditional Probability: 4 / 16 CS, MATH and Dual CS-MATH Majors →

slide-6
SLIDE 6

Flu Season

1 Chances a random person has the flu is about 0.01 (or 1%) (prior probability).

Probability of flu : P[flu] ≈ 0.01.

2 You have a slight fever – new information. Chances of flu “increase”.

Probability of flu given fever : P[flu | fever] ≈ 0.4.

◮ New information changes the prior probability to the posterior probability. ◮ Translate posterior as “After you get the new information.”

P[A | B] is the (updated) conditional probability of A, given the new information B.

3 Roommie has flu (more new information). Flu for sure, take counter-measures.

Probability of flu given fever and roommie flu : P[flu | fever and roommie flu] ≈ 1.

Pop Quiz. Estimate these probabilities:

P[Humans alive tomorrow], P[No Sun tomorrow], P[Humans alive tomorrow | No Sun tomorrow].

Creator: Malik Magdon-Ismail Conditional Probability: 4 / 16 CS, MATH and Dual CS-MATH Majors →

slide-7
SLIDE 7

CS, MATH and Dual CS-MATH Majors

5,000 students: 1,000 CS; 100 MATH; 80 dual MATH-CS.

ALL

CS MATH

Creator: Malik Magdon-Ismail Conditional Probability: 5 / 16 Conditional Probability P[A | B] →

slide-8
SLIDE 8

CS, MATH and Dual CS-MATH Majors

5,000 students: 1,000 CS; 100 MATH; 80 dual MATH-CS.

Pick a random student:

P[CS] = 1000

5000 = 0.2;

P[MATH] = 100

5000 = 0.02;

P[CS and MATH] =

80 5000 = 0.016.

ALL

CS MATH

Creator: Malik Magdon-Ismail Conditional Probability: 5 / 16 Conditional Probability P[A | B] →

slide-9
SLIDE 9

CS, MATH and Dual CS-MATH Majors

5,000 students: 1,000 CS; 100 MATH; 80 dual MATH-CS.

Pick a random student:

P[CS] = 1000

5000 = 0.2;

P[MATH] = 100

5000 = 0.02;

P[CS and MATH] =

80 5000 = 0.016.

New information: student is MATH. What is P[CS|MATH]?

Effectively picking a random student from MATH. ALL

CS MATH

Creator: Malik Magdon-Ismail Conditional Probability: 5 / 16 Conditional Probability P[A | B] →

slide-10
SLIDE 10

CS, MATH and Dual CS-MATH Majors

5,000 students: 1,000 CS; 100 MATH; 80 dual MATH-CS.

Pick a random student:

P[CS] = 1000

5000 = 0.2;

P[MATH] = 100

5000 = 0.02;

P[CS and MATH] =

80 5000 = 0.016.

New information: student is MATH. What is P[CS|MATH]?

Effectively picking a random student from MATH. New probability of CS ∼ striped area |CS ∩ MATH|. ALL

CS MATH

Creator: Malik Magdon-Ismail Conditional Probability: 5 / 16 Conditional Probability P[A | B] →

slide-11
SLIDE 11

CS, MATH and Dual CS-MATH Majors

5,000 students: 1,000 CS; 100 MATH; 80 dual MATH-CS.

Pick a random student:

P[CS] = 1000

5000 = 0.2;

P[MATH] = 100

5000 = 0.02;

P[CS and MATH] =

80 5000 = 0.016.

New information: student is MATH. What is P[CS|MATH]?

Effectively picking a random student from MATH. New probability of CS ∼ striped area |CS ∩ MATH|. ALL

CS MATH

P[CS | MATH] = |CS ∩ MATH| |MATH| = 80 100 = 0.8.

MATH students are 4 times more likely to be CS majors than a random student.

Pop Quiz. What is P[MATH | CS]? What is P[CS | CS or MATH]? Exercise 16.2.

Creator: Malik Magdon-Ismail Conditional Probability: 5 / 16 Conditional Probability P[A | B] →

slide-12
SLIDE 12

Conditional Probability P[A | B]

P[A | B] = frequency of outcomes known to be in B that are also in A.

Creator: Malik Magdon-Ismail Conditional Probability: 6 / 16 Chances of Rain →

slide-13
SLIDE 13

Conditional Probability P[A | B]

P[A | B] = frequency of outcomes known to be in B that are also in A. nB ooutcomes in event B when you repeat an experiment n times. P[B] = nB n .

Creator: Malik Magdon-Ismail Conditional Probability: 6 / 16 Chances of Rain →

slide-14
SLIDE 14

Conditional Probability P[A | B]

P[A | B] = frequency of outcomes known to be in B that are also in A. nB ooutcomes in event B when you repeat an experiment n times. P[B] = nB n .

Of the nB outcomes in B, the number also in A is nA∩B,

P[A ∩ B] = nA∩B n .

Creator: Malik Magdon-Ismail Conditional Probability: 6 / 16 Chances of Rain →

slide-15
SLIDE 15

Conditional Probability P[A | B]

P[A | B] = frequency of outcomes known to be in B that are also in A. nB ooutcomes in event B when you repeat an experiment n times. P[B] = nB n .

Of the nB outcomes in B, the number also in A is nA∩B,

P[A ∩ B] = nA∩B n .

The frequency of outcomes in A among those outcomes in B is nA∩B/nB,

P[A | B] = nA∩B nB = nA∩B n × n nB = P[A ∩ B] P[B] .

Creator: Malik Magdon-Ismail Conditional Probability: 6 / 16 Chances of Rain →

slide-16
SLIDE 16

Conditional Probability P[A | B]

P[A | B] = frequency of outcomes known to be in B that are also in A. nB ooutcomes in event B when you repeat an experiment n times. P[B] = nB n .

Of the nB outcomes in B, the number also in A is nA∩B,

P[A ∩ B] = nA∩B n .

The frequency of outcomes in A among those outcomes in B is nA∩B/nB,

P[A | B] = nA∩B nB = nA∩B n × n nB = P[A ∩ B] P[B] . P[A | B] = nA∩B nB = P[A ∩ B] P[B] = P[A and B] P[B]

Creator: Malik Magdon-Ismail Conditional Probability: 6 / 16 Chances of Rain →

slide-17
SLIDE 17

Chances of Rain Given Clouds

It is cloudy one in five days, P[Clouds] = 1

  • 5. It rains one in seven days, P[Rain] = 1

7.

Creator: Malik Magdon-Ismail Conditional Probability: 7 / 16 Conditioning with Dice →

slide-18
SLIDE 18

Chances of Rain Given Clouds

It is cloudy one in five days, P[Clouds] = 1

  • 5. It rains one in seven days, P[Rain] = 1

7.

What are the chances of rain on a cloudy day?

P[Rain | Clouds] = P[Rain ∩ Clouds] P[Clouds] .

Creator: Malik Magdon-Ismail Conditional Probability: 7 / 16 Conditioning with Dice →

slide-19
SLIDE 19

Chances of Rain Given Clouds

It is cloudy one in five days, P[Clouds] = 1

  • 5. It rains one in seven days, P[Rain] = 1

7.

What are the chances of rain on a cloudy day?

P[Rain | Clouds] = P[Rain ∩ Clouds] P[Clouds] . {Rainy Days} ⊆ {Cloudy Days} → P[Rain ∩ Clouds] = P[Rain].

All Days

Cloudy Rainy

Creator: Malik Magdon-Ismail Conditional Probability: 7 / 16 Conditioning with Dice →

slide-20
SLIDE 20

Chances of Rain Given Clouds

It is cloudy one in five days, P[Clouds] = 1

  • 5. It rains one in seven days, P[Rain] = 1

7.

What are the chances of rain on a cloudy day?

P[Rain | Clouds] = P[Rain ∩ Clouds] P[Clouds] . {Rainy Days} ⊆ {Cloudy Days} → P[Rain ∩ Clouds] = P[Rain]. P[Rain | Clouds] = P[Rain] P[Clouds] =

1 7 1 5

= 5 7.

All Days

Cloudy Rainy

5-times more likely to rain on a cloudy day than on a random day. Crucial first step: identify the conditional probability. What is the “new information”?

Creator: Malik Magdon-Ismail Conditional Probability: 7 / 16 Conditioning with Dice →

slide-21
SLIDE 21

P[Sum of 2 Dice is 10 | Both are Odd]

Two dice have both rolled odd. What are the chances the sum is 10?

P[Sum is 10 | Both are Odd] = P[(Sum is 10) and (Both are Odd)] P[Both are Odd]

Creator: Malik Magdon-Ismail Conditional Probability: 8 / 16 Computing a Conditional Probability →

slide-22
SLIDE 22

P[Sum of 2 Dice is 10 | Both are Odd]

Two dice have both rolled odd. What are the chances the sum is 10?

P[Sum is 10 | Both are Odd] = P[(Sum is 10) and (Both are Odd)] P[Both are Odd]

Probability Space

Die 1 Value Die 2 Value

Creator: Malik Magdon-Ismail Conditional Probability: 8 / 16 Computing a Conditional Probability →

slide-23
SLIDE 23

P[Sum of 2 Dice is 10 | Both are Odd]

Two dice have both rolled odd. What are the chances the sum is 10?

P[Sum is 10 | Both are Odd] = P[(Sum is 10) and (Both are Odd)] P[Both are Odd]

1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36

Probability Space

Die 1 Value Die 2 Value

Creator: Malik Magdon-Ismail Conditional Probability: 8 / 16 Computing a Conditional Probability →

slide-24
SLIDE 24

P[Sum of 2 Dice is 10 | Both are Odd]

Two dice have both rolled odd. What are the chances the sum is 10?

P[Sum is 10 | Both are Odd] = P[(Sum is 10) and (Both are Odd)] P[Both are Odd]

1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36

Probability Space

Die 1 Value Die 2 Value

1 P[Sum is 10] = 3

36 = 1 12.

Creator: Malik Magdon-Ismail Conditional Probability: 8 / 16 Computing a Conditional Probability →

slide-25
SLIDE 25

P[Sum of 2 Dice is 10 | Both are Odd]

Two dice have both rolled odd. What are the chances the sum is 10?

P[Sum is 10 | Both are Odd] = P[(Sum is 10) and (Both are Odd)] P[Both are Odd]

1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36

Probability Space

Die 1 Value Die 2 Value

1 P[Sum is 10] = 3

36 = 1 12.

2 P[Both are Odd] = 9

36 = 1 4.

Creator: Malik Magdon-Ismail Conditional Probability: 8 / 16 Computing a Conditional Probability →

slide-26
SLIDE 26

P[Sum of 2 Dice is 10 | Both are Odd]

Two dice have both rolled odd. What are the chances the sum is 10?

P[Sum is 10 | Both are Odd] = P[(Sum is 10) and (Both are Odd)] P[Both are Odd]

1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36

Probability Space

Die 1 Value Die 2 Value

1 P[Sum is 10] = 3

36 = 1 12.

2 P[Both are Odd] = 9

36 = 1 4.

3 P[(Sum is 10) and (Both are Odd)] = 1

36.

Creator: Malik Magdon-Ismail Conditional Probability: 8 / 16 Computing a Conditional Probability →

slide-27
SLIDE 27

P[Sum of 2 Dice is 10 | Both are Odd]

Two dice have both rolled odd. What are the chances the sum is 10?

P[Sum is 10 | Both are Odd] = P[(Sum is 10) and (Both are Odd)] P[Both are Odd]

1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36 1 36

Probability Space

Die 1 Value Die 2 Value

1 P[Sum is 10] = 3

36 = 1 12.

2 P[Both are Odd] = 9

36 = 1 4.

3 P[(Sum is 10) and (Both are Odd)] = 1

36.

4 P[Sum is 10 | Both are Odd] = 1

36 ÷ 1 4 = 1 9.

Pop Quiz. Compute P[Both are Odd | Sum is 10]. Compare with P[Sum is 10 | Both are Odd].

Creator: Malik Magdon-Ismail Conditional Probability: 8 / 16 Computing a Conditional Probability →

slide-28
SLIDE 28

Computing a Conditional Probability

1: Identify that you need a conditional probability P[A | B]. 2: Determine the probability space (Ω, P(·)) using the outcome-tree method. 3: Identify the events A and B appearing in P[A | B] as subsets of Ω. 4: Compute P[A ∩ B] and P[B]. 5: Compute P[A | B] = P[A ∩ B]

P[B] .

Creator: Malik Magdon-Ismail Conditional Probability: 9 / 16 Monty Prefers Door 3 →

slide-29
SLIDE 29

Monty Prefers Door 3

1 2 3 2 3 3 2 P(1, 2) = 1

9

P(1, 3) = 2

9

P(2, 3) = 1

3

P(3, 2) = 1

3 Prize Host Probability 1 3 1 3 1 3 1 3 2 3

1 1

Creator: Malik Magdon-Ismail Conditional Probability: 10 / 16 A Pair of Boys →

slide-30
SLIDE 30

Monty Prefers Door 3

1 2 3 2 3 3 2 P(1, 2) = 1

9

P(1, 3) = 2

9

P(2, 3) = 1

3

P(3, 2) = 1

3 Prize Host Probability 1 3 1 3 1 3 1 3 2 3

1 1

Best strategy is always switch. Winning outcomes: (2,3) or (3,2).

P[WinBySwitching] = 2

3.

Creator: Malik Magdon-Ismail Conditional Probability: 10 / 16 A Pair of Boys →

slide-31
SLIDE 31

Monty Prefers Door 3

1 2 3 2 3 3 2 P(1, 2) = 1

9

P(1, 3) = 2

9

P(2, 3) = 1

3

P(3, 2) = 1

3 Prize Host Probability 1 3 1 3 1 3 1 3 2 3

1 1

Best strategy is always switch. Winning outcomes: (2,3) or (3,2).

P[WinBySwitching] = 2

3.

Perk up if Monty opens door 2!

Intuition: Why didn’t Monty open door 3 if he prefers door 3?

Creator: Malik Magdon-Ismail Conditional Probability: 10 / 16 A Pair of Boys →

slide-32
SLIDE 32

Monty Prefers Door 3

1 2 3 2 3 3 2 P(1, 2) = 1

9

P(1, 3) = 2

9

P(2, 3) = 1

3

P(3, 2) = 1

3 Prize Host Probability 1 3 1 3 1 3 1 3 2 3

1 1

Best strategy is always switch. Winning outcomes: (2,3) or (3,2).

P[WinBySwitching] = 2

3.

Perk up if Monty opens door 2!

Intuition: Why didn’t Monty open door 3 if he prefers door 3?

P[Win|Monty opens Door 3] = P[Win and Monty opens Door 3] P[Monty opens Door 3] =

1 3 1 3 + 1 9

=

3 4.

Your chances improved from 2

3 to 3 4!

Creator: Malik Magdon-Ismail Conditional Probability: 10 / 16 A Pair of Boys →

slide-33
SLIDE 33

A Pair of Boys

Your friends Ayfos, Ifar, Need and Niaz have two children each. What is the probability of two boys?

Creator: Malik Magdon-Ismail Conditional Probability: 11 / 16 Conditional Probability Traps →

slide-34
SLIDE 34

A Pair of Boys

Your friends Ayfos, Ifar, Need and Niaz have two children each. What is the probability of two boys? Answer: 1

4.

Creator: Malik Magdon-Ismail Conditional Probability: 11 / 16 Conditional Probability Traps →

slide-35
SLIDE 35

A Pair of Boys

Your friends Ayfos, Ifar, Need and Niaz have two children each. What is the probability of two boys? Answer: 1

4.

New information:

1 Ayfos has at least one boy. 2 Ifar’s older child is a boy. 3 One day you met Need on a walk with a boy. 4 Niaz is Clingon. Clingons always take a son on a walk if

  • possible. One day, you met Niaz on a walk with a boy.

Now, what is the probability of two boys in each case?

Creator: Malik Magdon-Ismail Conditional Probability: 11 / 16 Conditional Probability Traps →

slide-36
SLIDE 36

A Pair of Boys

Your friends Ayfos, Ifar, Need and Niaz have two children each. What is the probability of two boys? Answer: 1

4.

New information:

1 Ayfos has at least one boy.

(Answer: 1

3.) 2 Ifar’s older child is a boy.

(Answer: 1

2.) 3 One day you met Need on a walk with a boy.

(Answer: 1

2.) 4 Niaz is Clingon. Clingons always take a son on a walk if

  • possible. One day, you met Niaz on a walk with a boy.

(Answer: 1

3.)

Now, what is the probability of two boys in each case? It’s the same question in each case, but with slightly different additional information. You need conditional probabilities.

Creator: Malik Magdon-Ismail Conditional Probability: 11 / 16 Conditional Probability Traps →

slide-37
SLIDE 37

Conditional Probability Traps

These four probabilities are all different.

P[A] P [A | B] P [B | A] P [A and B]

Don’t use one when you should use another.

Creator: Malik Magdon-Ismail Conditional Probability: 12 / 16 The LAME Test →

slide-38
SLIDE 38

Conditional Probability Traps

These four probabilities are all different.

P[A] P [A | B] P [B | A] P [A and B]

Don’t use one when you should use another.

Sampling Bias: Using P[A] instead of P[A | B] P[Voter will vote Republican] ≈ 1

2.

Ask Appletm to call up i-Phonetm users to see how they will vote. P[Voter will vote Republican | Voter has an i-Phone] ≫ 1

2.

(Why?) This has trapped many US election-pollers. For a famous example, Googletm “Dewey Defeats Truman.”

Creator: Malik Magdon-Ismail Conditional Probability: 12 / 16 The LAME Test →

slide-39
SLIDE 39

Conditional Probability Traps

These four probabilities are all different.

P[A] P [A | B] P [B | A] P [A and B]

Don’t use one when you should use another.

Sampling Bias: Using P[A] instead of P[A | B] P[Voter will vote Republican] ≈ 1

2.

Ask Appletm to call up i-Phonetm users to see how they will vote. P[Voter will vote Republican | Voter has an i-Phone] ≫ 1

2.

(Why?) This has trapped many US election-pollers. For a famous example, Googletm “Dewey Defeats Truman.” Transposed Condtional: Using P[B | A] instead of P[A | B] Famous Lombard study on the riskiest profession: Student! Lombard confused: P[Student | Die Young] with P [Die Young | Student]

Creator: Malik Magdon-Ismail Conditional Probability: 12 / 16 The LAME Test →

slide-40
SLIDE 40

The LAME Test and Transposed Conditionals

If you are lame, the test makes a mistake in only 10% of cases. If you are not lame, the test makes a mistake in only 5% of cases.

Creator: Malik Magdon-Ismail Conditional Probability: 13 / 16 Total Probability →

slide-41
SLIDE 41

The LAME Test and Transposed Conditionals

If you are lame, the test makes a mistake in only 10% of cases. If you are not lame, the test makes a mistake in only 5% of cases. You get tested positive. What are the chances you are lame?

Creator: Malik Magdon-Ismail Conditional Probability: 13 / 16 Total Probability →

slide-42
SLIDE 42

The LAME Test and Transposed Conditionals

If you are lame, the test makes a mistake in only 10% of cases. If you are not lame, the test makes a mistake in only 5% of cases. You get tested positive. What are the chances you are lame?

If you are not lame, the test wouldn’t make a mistake. So you are likely lame.

Creator: Malik Magdon-Ismail Conditional Probability: 13 / 16 Total Probability →

slide-43
SLIDE 43

The LAME Test and Transposed Conditionals

If you are lame, the test makes a mistake in only 10% of cases. If you are not lame, the test makes a mistake in only 5% of cases. You get tested positive. What are the chances you are lame?

If you are not lame, the test wouldn’t make a mistake. So you are likely lame.

It’s wrong to look at P[positive | not lame]. We need P[not lame | positive].

Creator: Malik Magdon-Ismail Conditional Probability: 13 / 16 Total Probability →

slide-44
SLIDE 44

The LAME Test and Transposed Conditionals

If you are lame, the test makes a mistake in only 10% of cases. If you are not lame, the test makes a mistake in only 5% of cases. You get tested positive. What are the chances you are lame?

If you are not lame, the test wouldn’t make a mistake. So you are likely lame.

It’s wrong to look at P[positive | not lame]. We need P[not lame | positive].

not lame

0.99

no

P(not lame, no) = 0.99 × 0.95 0.95

yes

P(not lame, yes) = 0.99 × 0.05 0.05

lame

0.01

no

P(lame, no) = 0.01 × 0.1 0.1

yes

P(lame, yes) = 0.01 × 0.9 0.9 lame or not lame-test Probability

Creator: Malik Magdon-Ismail Conditional Probability: 13 / 16 Total Probability →

slide-45
SLIDE 45

The LAME Test and Transposed Conditionals

If you are lame, the test makes a mistake in only 10% of cases. If you are not lame, the test makes a mistake in only 5% of cases. You get tested positive. What are the chances you are lame?

If you are not lame, the test wouldn’t make a mistake. So you are likely lame.

It’s wrong to look at P[positive | not lame]. We need P[not lame | positive].

P [not lame | yes] = P[not lame and yes] P[yes]

not lame

0.99

no

P(not lame, no) = 0.99 × 0.95 0.95

yes

P(not lame, yes) = 0.99 × 0.05 P(not lame, yes) = 0.99 × 0.05 0.05

lame

0.01

no

P(lame, no) = 0.01 × 0.1 0.1

yes

P(lame, yes) = 0.01 × 0.9 P(lame, yes) = 0.01 × 0.9 0.9 lame or not lame-test Probability

Creator: Malik Magdon-Ismail Conditional Probability: 13 / 16 Total Probability →

slide-46
SLIDE 46

The LAME Test and Transposed Conditionals

If you are lame, the test makes a mistake in only 10% of cases. If you are not lame, the test makes a mistake in only 5% of cases. You get tested positive. What are the chances you are lame?

If you are not lame, the test wouldn’t make a mistake. So you are likely lame.

It’s wrong to look at P[positive | not lame]. We need P[not lame | positive].

P [not lame | yes] = P[not lame and yes] P[yes] = 0.99 × 0.05 0.99 × 0.05 + 0.9 × 0.01 ≈ 85%.

not lame

0.99

no

P(not lame, no) = 0.99 × 0.95 0.95

yes

P(not lame, yes) = 0.99 × 0.05 P(not lame, yes) = 0.99 × 0.05 0.05

lame

0.01

no

P(lame, no) = 0.01 × 0.1 0.1

yes

P(lame, yes) = 0.01 × 0.9 P(lame, yes) = 0.01 × 0.9 0.9 lame or not lame-test Probability

Creator: Malik Magdon-Ismail Conditional Probability: 13 / 16 Total Probability →

slide-47
SLIDE 47

The LAME Test and Transposed Conditionals

If you are lame, the test makes a mistake in only 10% of cases. If you are not lame, the test makes a mistake in only 5% of cases. You get tested positive. What are the chances you are lame?

If you are not lame, the test wouldn’t make a mistake. So you are likely lame.

It’s wrong to look at P[positive | not lame]. We need P[not lame | positive].

P [not lame | yes] = P[not lame and yes] P[yes] = 0.99 × 0.05 0.99 × 0.05 + 0.9 × 0.01 ≈ 85%.

not lame

0.99

no

P(not lame, no) = 0.99 × 0.95 0.95

yes

P(not lame, yes) = 0.99 × 0.05 P(not lame, yes) = 0.99 × 0.05 0.05

lame

0.01

no

P(lame, no) = 0.01 × 0.1 0.1

yes

P(lame, yes) = 0.01 × 0.9 P(lame, yes) = 0.01 × 0.9 0.9 lame or not lame-test Probability

The (accurate) test says yes but the chances are 85% that you are not lame! You are lame (rare) plus the test was right (likely) You are not lame (very likely) plus the test got it wrong (rare). Wins!

Creator: Malik Magdon-Ismail Conditional Probability: 13 / 16 Total Probability →

slide-48
SLIDE 48

Total Probability: Case by Case Probability

Two types of outcomes in any event A:

A

Creator: Malik Magdon-Ismail Conditional Probability: 14 / 16 Three Coins →

slide-49
SLIDE 49

Total Probability: Case by Case Probability

Two types of outcomes in any event A: The outcomes in B (green);

A A ∩ B B

Creator: Malik Magdon-Ismail Conditional Probability: 14 / 16 Three Coins →

slide-50
SLIDE 50

Total Probability: Case by Case Probability

Two types of outcomes in any event A: The outcomes in B (green); The outcomes not in B (red).

A A ∩ B A ∩ B B

Creator: Malik Magdon-Ismail Conditional Probability: 14 / 16 Three Coins →

slide-51
SLIDE 51

Total Probability: Case by Case Probability

Two types of outcomes in any event A: The outcomes in B (green); The outcomes not in B (red).

P[A] = P[A ∩ B] + P[A ∩ B].

(∗)

(Similar to sum rule from counting.) Ω

A A ∩ B A ∩ B B

Creator: Malik Magdon-Ismail Conditional Probability: 14 / 16 Three Coins →

slide-52
SLIDE 52

Total Probability: Case by Case Probability

Two types of outcomes in any event A: The outcomes in B (green); The outcomes not in B (red).

P[A] = P[A ∩ B] + P[A ∩ B].

(∗)

(Similar to sum rule from counting.) Ω

A A ∩ B A ∩ B B

From the definition of conditional probability:

P[A ∩ B] = P[A and B] = P[A | B] × P[B]; P[A ∩ B] = P[A and B] = P[A | B] × P[B].

Creator: Malik Magdon-Ismail Conditional Probability: 14 / 16 Three Coins →

slide-53
SLIDE 53

Total Probability: Case by Case Probability

Two types of outcomes in any event A: The outcomes in B (green); The outcomes not in B (red).

P[A] = P[A ∩ B] + P[A ∩ B].

(∗)

(Similar to sum rule from counting.) Ω

A A ∩ B A ∩ B B

From the definition of conditional probability:

P[A ∩ B] = P[A and B] = P[A | B] × P[B]; P[A ∩ B] = P[A and B] = P[A | B] × P[B].

Plugging these into (∗), we get a FUNDAMENTAL result for case by case analysis: Law of Total Probability

P[A] = P[A | B] · P[B] + P[A | B] · P[B].

(Weight conditional probabilities for each case by probabilities of each case and add.)

Creator: Malik Magdon-Ismail Conditional Probability: 14 / 16 Three Coins →

slide-54
SLIDE 54

Three Coins: Two Are Fair, One is 2-Headed

Pick a random coin and flip. What is the probability of H?

Creator: Malik Magdon-Ismail Conditional Probability: 15 / 16 Fair Coin from Biased Coin →

slide-55
SLIDE 55

Three Coins: Two Are Fair, One is 2-Headed

Pick a random coin and flip. What is the probability of H? Outcome-Tree Method

fair

1 3

T

1 2

H

1 2

fair

1 3

T

1 2

H

1 2

biased

1 3

T H 1

1 6 1 6 1 6 1 6 1 3

probability

P[H] = 1

6 + 1 6 + 1 3 = 2 3.

Creator: Malik Magdon-Ismail Conditional Probability: 15 / 16 Fair Coin from Biased Coin →

slide-56
SLIDE 56

Three Coins: Two Are Fair, One is 2-Headed

Pick a random coin and flip. What is the probability of H? Outcome-Tree Method

fair

1 3

T

1 2

H

1 2

fair

1 3

T

1 2

H

1 2

biased

1 3

T H 1

1 6 1 6 1 6 1 6 1 3

probability

P[H] = 1

6 + 1 6 + 1 3 = 2 3.

Total Probability

Case 1. B :You picked one of the fair coins Case 2. B :You picked the two-headed coin

Creator: Malik Magdon-Ismail Conditional Probability: 15 / 16 Fair Coin from Biased Coin →

slide-57
SLIDE 57

Three Coins: Two Are Fair, One is 2-Headed

Pick a random coin and flip. What is the probability of H? Outcome-Tree Method

fair

1 3

T

1 2

H

1 2

fair

1 3

T

1 2

H

1 2

biased

1 3

T H 1

1 6 1 6 1 6 1 6 1 3

probability

P[H] = 1

6 + 1 6 + 1 3 = 2 3.

Total Probability

Case 1. B :You picked one of the fair coins Case 2. B :You picked the two-headed coin

P[H] = P[H | B] ↑

1 2

· P[B] ↑

2 3

+ P[H | B] ↑ 1 · P[B] ↑

1 3

Creator: Malik Magdon-Ismail Conditional Probability: 15 / 16 Fair Coin from Biased Coin →

slide-58
SLIDE 58

Three Coins: Two Are Fair, One is 2-Headed

Pick a random coin and flip. What is the probability of H? Outcome-Tree Method

fair

1 3

T

1 2

H

1 2

fair

1 3

T

1 2

H

1 2

biased

1 3

T H 1

1 6 1 6 1 6 1 6 1 3

probability

P[H] = 1

6 + 1 6 + 1 3 = 2 3.

Total Probability

Case 1. B :You picked one of the fair coins Case 2. B :You picked the two-headed coin

P[H] = P[H | B] ↑

1 2

· P[B] ↑

2 3

+ P[H | B] ↑ 1 · P[B] ↑

1 3

=

1 2 · 2 3 + 1 · 1 3

=

2 3.

Creator: Malik Magdon-Ismail Conditional Probability: 15 / 16 Fair Coin from Biased Coin →

slide-59
SLIDE 59

Three Coins: Two Are Fair, One is 2-Headed

Pick a random coin and flip. What is the probability of H? Outcome-Tree Method

fair

1 3

T

1 2

H

1 2

fair

1 3

T

1 2

H

1 2

biased

1 3

T H 1

1 6 1 6 1 6 1 6 1 3

probability

P[H] = 1

6 + 1 6 + 1 3 = 2 3.

Total Probability

Case 1. B :You picked one of the fair coins Case 2. B :You picked the two-headed coin

P[H] = P[H | B] ↑

1 2

· P[B] ↑

2 3

+ P[H | B] ↑ 1 · P[B] ↑

1 3

=

1 2 · 2 3 + 1 · 1 3

=

2 3.

  • Exercise. A box has 10 coins: 6 fair and 4 biased (probability of heads 2

3). What is P[2 heads] in each case?

(a)

Pick a single random coin and flip it 3 times.

(b)

Flip 3 times. For each flip, pick a random coin, flip it and then put the coin back.

Creator: Malik Magdon-Ismail Conditional Probability: 15 / 16 Fair Coin from Biased Coin →

slide-60
SLIDE 60

Fair Toss from Biased Coin (unknown probability p of heads)?

Creator: Malik Magdon-Ismail Conditional Probability: 16 / 16

slide-61
SLIDE 61

Fair Toss from Biased Coin (unknown probability p of heads)?

Make two tosses of the biased coin. (Lower case ‘h’ and ‘t’ denote the outcomes of a toss.) If you get ‘ht’ output H; ‘th’ output T; otherwise restart.

t 1 − p t 1 − p restart h p T h p t 1 − p H h p restart Toss 1 Toss 2 Output

Creator: Malik Magdon-Ismail Conditional Probability: 16 / 16

slide-62
SLIDE 62

Fair Toss from Biased Coin (unknown probability p of heads)?

Make two tosses of the biased coin. (Lower case ‘h’ and ‘t’ denote the outcomes of a toss.) If you get ‘ht’ output H; ‘th’ output T; otherwise restart. P(‘ht’) = P(‘th’) = p(1 − p). This suggests that an H is as likely as a T.

t 1 − p t 1 − p restart h p T h p t 1 − p H h p restart Toss 1 Toss 2 Output

Creator: Malik Magdon-Ismail Conditional Probability: 16 / 16

slide-63
SLIDE 63

Fair Toss from Biased Coin (unknown probability p of heads)?

Make two tosses of the biased coin. (Lower case ‘h’ and ‘t’ denote the outcomes of a toss.) If you get ‘ht’ output H; ‘th’ output T; otherwise restart. P(‘ht’) = P(‘th’) = p(1 − p). This suggests that an H is as likely as a T.

t 1 − p t 1 − p restart h p T h p t 1 − p H h p restart Toss 1 Toss 2 Output

By the law of total probability (3 cases),

P [H] = P[H | restart]

P[H] · P[restart]

p2 + (1 − p)2 + P[H | ‘ht’]

1 · P[‘ht’]

p(1 − p) + P[H | ‘th’]

· P[‘th’]

p(1 − p)

Creator: Malik Magdon-Ismail Conditional Probability: 16 / 16

slide-64
SLIDE 64

Fair Toss from Biased Coin (unknown probability p of heads)?

Make two tosses of the biased coin. (Lower case ‘h’ and ‘t’ denote the outcomes of a toss.) If you get ‘ht’ output H; ‘th’ output T; otherwise restart. P(‘ht’) = P(‘th’) = p(1 − p). This suggests that an H is as likely as a T.

t 1 − p t 1 − p restart h p T h p t 1 − p H h p restart Toss 1 Toss 2 Output

By the law of total probability (3 cases),

P [H] = P[H | restart]

P[H] · P[restart]

p2 + (1 − p)2 + P[H | ‘ht’]

1 · P[‘ht’]

p(1 − p) + P[H | ‘th’]

· P[‘th’]

p(1 − p) = P[H](p2 + (1 − p)2) + p(1 − p)

Creator: Malik Magdon-Ismail Conditional Probability: 16 / 16

slide-65
SLIDE 65

Fair Toss from Biased Coin (unknown probability p of heads)?

Make two tosses of the biased coin. (Lower case ‘h’ and ‘t’ denote the outcomes of a toss.) If you get ‘ht’ output H; ‘th’ output T; otherwise restart. P(‘ht’) = P(‘th’) = p(1 − p). This suggests that an H is as likely as a T.

t 1 − p t 1 − p restart h p T h p t 1 − p H h p restart Toss 1 Toss 2 Output

By the law of total probability (3 cases),

P [H] = P[H | restart]

P[H] · P[restart]

p2 + (1 − p)2 + P[H | ‘ht’]

1 · P[‘ht’]

p(1 − p) + P[H | ‘th’]

· P[‘th’]

p(1 − p) = P[H](p2 + (1 − p)2) + p(1 − p)

Solve for P[H]

P[H] = p(1 − p) 1 − (p2 + (1 − p)2) = p(1 − p) 2p − 2p2 = p(1 − p) 2p(1 − p) = 1 2.

(You can also solve this problem using an infinite outcome tree and computing an infinite sum.)

Creator: Malik Magdon-Ismail Conditional Probability: 16 / 16