1 of 64

Chapter 3 �Conditional Probability and Independence

Part 1: Theory

Ver. 100825

2 of 64

the probability that E occurs given that F occurs !

Probability/Ch3

2

Definition

3 of 64

Probability/Ch3

3

4 of 64

Quiz

Probability/Ch3

4

A box contains 3 cards. One is black on both sides. One is red on both sides. One is black on one side and red on the other.

You draw a random card and see a black side. What are the chances the other side is red?

A: 1/4

B: 1/3

C: 1/2

5 of 64

Solution

Probability/Ch3

5

F1

F2

F3

B1

B2

B3

S = { F1, B1, F2, B2, F3, B3 }

The event you see a black side is SB = { F1, B1, F3 }

The event the other side is red is OR = { F2, B2, F3 }

P(OR | SB) =

equally likely outcomes

P(OR SB)

P(SB)

=

1/|S|

3/|S|

= 1/3

6 of 64

Probability/Ch3

6

7 of 64

Probability/Ch3

7

8 of 64

Probability/Ch3

8

9 of 64

Probability/Ch3

9

10 of 64

Probability/Ch3

10

11 of 64

Probability/Ch3

11

Law of total probability

12 of 64

Probability/Ch3

12

Bayes’s Rule

Independent Event

13 of 64

Probability/Ch3

13

14 of 64

Probability/Ch3

14

Problem of the point

1623 – 1662

15 of 64

Probability/Ch3

15

1601 –1665

16 of 64

Probability/Ch3

16

Color a complete graph

17 of 64

Probability/Ch3

17

18 of 64

Probability/Ch3

18

Then what ?

19 of 64

Probability/Ch3

19

20 of 64

Probability/Ch3

20

21 of 64

Probability/Ch3

21

Catalan number (counting T-path)

If we walk in a lattice and in each step we can choose “going right” or “going up” one unit. How many paths are there from (0,0) to (n,n), without crossing the diagonal line ?

(0,0)

(n,n)

Swap and push

cross then swap

22 of 64

Probability/Ch3

22

Bertrand’s ballot problem (counting NT-path)

Suppose in an election candidate A receives n votes and B receives m where n>m.

What is the probability that A always wins B during the counting process ?

Cycle Lemma!

(0,0)

(m,m)

(n,m)

(n,0)

(0,m)

touch then swap

23 of 64

Probability/Ch3

23

Cycle lemma for the Catalan number

Note that the number of T-path from (0,0) to (n,n) equals that of NT-path from (0,0) to (n+1,n). Therefore by the cycle lemma, Catalan number is

Q. How many NT-paths and T-paths from (0,0) to (km+p,m)

for positive integers m,k and p? (check wiki for details)

(0, m)

(0, 0)

(km, 0)

(km+p, 0)

(km+p, m)

24 of 64

3. Conditional probability�part two

25 of 64

Cause and effect

Probability/Ch3

25

1

2

3

effect:

B

cause:

C1

C2

C3

26 of 64

Bayes’ rule

Probability/Ch3

26

P(E|C) P(C)

P(E)

P(E|C) P(C)

P(E|C) P(C) + P(E|Cc) P(Cc)

=

More generally, if C1,…, Cn partition S then

P(C|E) =

P(Ci|E) =

P(E|Ci) P(Ci)

P(E|C1) P(C1) + … + P(E|Cn) P(Cn)

27 of 64

Cause and effect

Probability/Ch3

27

1

2

3

cause:

C1

C2

C3

effect:

B

P(Ci|B) =

P(B|Ci) P(Ci)

P(B|C1) P(C1) + P(B|C2) P(C2) + P(B|C3) P(C3)

28 of 64

Medical tests

Probability/Ch3

28

If you are sick (S), a blood test comes out positive (P) 95% of the time.

If you are not sick, the test is positive 1% of the time.

Suppose 0.5% people in Hong Kong are sick.

You take the test and come out positive. What are the chances that you are sick?

P(P|S) P(S)

P(P|S) P(S) + P(P|Sc) P(Sc)

P(S|P) =

95% 0.5%

1% 99.5%

≈ 32.3%

29 of 64

Computer science vs. nursing

Probability/Ch3

29

Two classes take place in Lady Shaw Building.

One is a computer science class with 100 students, out of which 20% are girls.

The other is a nursing class with 10 students, out of which 80% are girls.

A girl walks out. What are the chances that she is from the computer science class?

30 of 64

Two effects

Probability/Ch3

30

Cup one has 9 blue balls and 1 red ball.

Cup two has 9 red balls and 1 blue ball.

I choose a cup at random and draw a ball. It is blue.

I draw another ball from the same cup (without replacement). What is the probability it is blue?

31 of 64

Russian roulette

Probability/Ch3

31

Alice

Bob

BANG

Alice and Bob take turns spinning the 6 hole cylinder and shooting at each other.

What is the probability that Alice wins (Bob dies)?

32 of 64

Russian roulette

Probability/Ch3

32

S = { H, MH, MMH, MMMH, MMMH, …}

E.g. MMH: Alice misses, then Bob misses, then Alice hits

A = “Alice wins” = { H, MMH, MMMMH, …}

Probability model

outcomes are not equally likely!

33 of 64

Russian roulette

Probability/Ch3

33

P(A)

outcome H MH MMH MMMH MMMH

probability

1/6

5/6 ∙ 1/6

(5/6)2 ∙ 1/6

(5/6)3 ∙ 1/6

(5/6)4 ∙ 1/6

= 1/6 + (5/6)2 ∙ 1/6 + (5/6)4 ∙ 1/6 + …

= 1/6 ∙ (1 + (5/6)2 + (5/6)4 + …)

= 1/6 ∙ 1/(1 – (5/6)2)

= 6/11

34 of 64

Russian roulette

Probability/Ch3

34

Solution using conditional probabilities:

P(A) = P(A|W1) P(W1) + P(A|W1c) P(W1c)

A = “Alice wins” = { H, MMH, MMMMH, …}

W1 = “Alice wins in first round” = { H }

Ac = “Bob wins” = { MH, MMMH, MMMMMH, …}

5/6

1/6

1

P(Ac)

P(A) = 1 ∙ 1/6 + (1 – P(A)) ∙ 5/6

11/6 P(A) = 1

so P(A) = 6/11

35 of 64

Infinite sample spaces

Probability/Ch3

35

Axioms of probability:

S

E

1. for every E, 0 ≤ P(E) ≤ 1

S

2. P(S) = 1

S

E

F

3. If EF = ∅ then

P(EF) = P(E) + P(F)

3. If E1, E2, … are pairwise disjoint:

P(E1E2∪…) = P(E1) + P(E2) + …

36 of 64

Problem for you to solve

Probability/Ch3

36

Charlie tosses a pair of dice. Alice wins if the sum is 7. Bob wins if the sum is 8.

Charlie keeps tossing until one of them wins.

What is the probability that Alice wins?

37 of 64

Hats again

Probability/Ch3

37

The hats of n men are exchanged at random. What is the probability that no man gets back his hat?

Solution using conditional probabilities:

N = “No man gets back his hat”

H1 = 1 gets back his own hat”

P(N) = P(N|H1) P(H1) + P(N|H1c) P(H1c)

(n-1)/n

1/n

0

38 of 64

Hats again

Probability/Ch3

38

N = “No man gets back his hat”

H1 = 1 gets back his own hat”

S1 = 1 exchanges hats with another man”

P(N) = P(N|H1c)

n 1

n

P(N|H1c) = P(NS1|H1c) + P(NS1c|H1c)

= P(S1|H1c) P(N|S1H1c) + P(NS1c|H1c)

1/(n-1)

pn-2

let pn = P(N)

pn-1

pn =

pn = pn-1 + pn-2

n 1

n

1

n

39 of 64

Hats again

Probability/Ch3

39

N = “No man gets back his hat”

pn = P(N)

pn = pn-1 + pn-2

n 1

n

1

n

p1 = 0

pn pn-1 = (pn-1 pn-2)

1

n

p3 p2 = (p2 p1)

1

3

1

3!

=

p3 =

1

3!

1

2

p4 p3 = (p3 p2)

1

4

1

4!

=

p4 = – +

1

3!

1

2

1

4!

p2 =

1

2

40 of 64

Summary of conditional probability

Probability/Ch3

40

Conditional probabilities are used:

to estimate the probability of a cause when we observe an effect

Conditioning on the right event can simplify the description of the sample space

When there are causes and effects

1

To calculate ordinary probabilities

2

41 of 64

Independence of two events

Probability/Ch3

41

Let E1 be “first coin comes up H

E2 be “second coin comes up H

Then P(E2 | E1) = P(E2)

Events A and B are independent if

P(A B) = P(A) P(B)

P(E2E1) = P(E2)P(E1)

42 of 64

Examples of (in)dependence

Probability/Ch3

42

Let E1 be “first die is a 4

S6 be “sum of dice is a 6

S7 be “sum of dice is a 7

P(E1) =

P(S6) =

P(E1S6) =

E1, S6 are dependent

P(S7) =

P(E1S7) =

E1, S7 are independent

P(S6S7) =

S6, S7 are dependent

1/6

5/36

1/36

1/6

1/36

0

43 of 64

Algebra of independent events

Probability/Ch3

43

If A and B are independent, then A and Bc are also independent.

Proof: Assume A and B are independent.

P(ABc)

= P(A) – P(AB)

= P(A) – P(A)P(B)

= P(A)P(Bc)

so Bc and A are independent.

Taking complements preserves independence.

44 of 64

Independence of three events

Probability/Ch3

44

Events A, B, and C are independent if

P(AB) = P(A) P(B)

P(BC) = P(B) P(C)

P(AC) = P(B) P(C)

and P(ABC) = P(A) P(B) P(C).

This is important!

45 of 64

(In)dependence of three events

Probability/Ch3

45

Let E1 be “first die is a 4

E2 be “second die is a 3

S7 be “sum of dice is a 7

P(E1E2) = P(E1) P(E2)

P(E1S7) = P(E1) P(S7)

P(E2S7) = P(E2) P(S7)

P(E1E2S7) = P(E1) P(E2) P(S7)

1/6

1/6

1/6

1/36

E1

E2

S7

1/6

1/6

1/6

1/36

46 of 64

Independence of many events

Probability/Ch3

46

Events A1, A2, are independent if for every subset Ai1, …, Air of the events

P(Ai1Air) = P(Ai1) … P(Air)

Independence is preserved if we replace some event(s) by their complements, intersections, unions

Algebra of independent events

47 of 64

The proof can also be done by induction.

Probability/Ch3

47

48 of 64

Playoffs

Probability/Ch3

48

Alice wins 60% of her ping pong matches against Bob. They meet for a 3 match playoff. What are the chances that Alice will win the playoff?

Probability model

Let Wi be the event Alice wins match i

We assume P(W1) = P(W2) = P(W3) = 0.6

We also assume W1, W2, W3 are independent

49 of 64

Playoffs

Probability/Ch3

49

Probability model

To convince ourselves this is a probability model, let’s redo it as in Lecture 2:

S = { AAA, AAB, ABA, ABB, BAA, BAB, BBA, BBB }

the probability of AAA is P(W1W2W3) = 0.63

AAB

P(W1W2W3c) = 0.62 ∙ 0.4

ABA

P(W1W2cW3) = 0.62 ∙ 0.4

BBB

P(W1cW2cW3c) = 0.43

The probabilities add up to one.

50 of 64

Playoffs

Probability/Ch3

50

A = { AAA, AAB, ABA, BAA }

For Alice to win the tournament, she must win at least 2 out of 3 games. The corresponding event is

0.63

0.62 ∙ 0.4 each

P(A) = 0.63 + 3 0.62 0.4 = 0.648.

Alice wins a p fraction of her ping pong games against Bob. What are the chances Alice beats Bob in an n match tournament (n is odd)?

General playoff

51 of 64

Playoffs

Probability/Ch3

51

Solution

Probability model similar as before.

Let A be the event “Alice wins playoff”

Ak be the event “Alice wins exactly k matches”

P(Ak) = C(n, k) pk (1 – p)n - k

A = A(n+1)/2An

P(A) = P(A(n+1)/2) + … + P(An) (they are disjoint)

number of arrangements of k As, nk Bs

probability of each such arrangement

52 of 64

Playoffs

Probability/Ch3

52

P(A) = ∑ k = (n+1)/2

n

C(n, k) pk (1 – p)n - k

p = 0.6

p = 0.7

The probability that Alice wins an n game tournament

n

n

53 of 64

Problem for you

Probability/Ch3

53

The Lakers and the Celtics meet for a 7-game playoff. They play until one team wins four games.

Suppose the Lakers win 60% of the time. What is the probability that all 7 games are played?

54 of 64

Suppose Pk is the probability that k games are played. We have

Probability/Ch3

54

Can you verify

55 of 64

Gambler’s ruin

Probability/Ch3

55

You have $100. You keep betting $1 on red at roulette.

You stop when you win $200, �or when you run out of money.

What is the probability you win $200?

56 of 64

Gambler’s ruin

Probability/Ch3

56

Probability model

S = all infinite sequences of Reds and Others

Let Ri be the event of red in the ith round � (there is an R in position i)

Probabilities:

P(R1) = P(R2) = … = 18/37

R1, R2, … are independent

call this p

57 of 64

Gambler’s ruin

Probability/Ch3

57

Let W be the event you win $200 and wn = P(W).

You have $100. You stop when you win $200.

$n

= P(W|R1) P(R1) + P(W|R1c) P(R1c)

wn = P(W)

1-p

p

wn+1

wn-1

wn = (1-p)wn-1 + pwn+1

w0 = 0

w200 = 1.

58 of 64

Gambler’s ruin

Probability/Ch3

58

p(wn+1wn ) = (1-p)(wnwn-1)

wn = (1-p)wn-1 + pwn+1

w0 = 0

w200 = 1.

wn+1wn = λ (wnwn-1)

let λ = (1-p)/p = 19/18

= λ2 (wn-1wn-2)

= … = λn (w1w0)

wn+1 = wn + λnw1

= wn-1 + λn-1w1 + λnw1

= … = w1 + λw1 + … + λnw1

59 of 64

Gambler’s ruin

Probability/Ch3

59

wn = (1-p)wn-1 + pwn+1

w0 = 0

w200 = 1.

λ = (1-p)/p = 19/18

wn+1 = w1 + … + λnw1

= (λn+1 – 1)/(λ – 1)w1

w200 = (λ200 – 1)/(λ – 1)w1

wn+1 =

λn+1 – 1

λ200 – 1

You have $100.

You stop when you win

$200 or run out.

The probability you win is

w100 ≈ 0.0045

60 of 64

The general gambler’s ruin problem

Probability/Ch3

60

Two people play a game with each other. The loser pays one dollar to the winner at the end of the game. Initially they have r1 and r2 dollars and the winning rates are p and 1-p respectively. They continue to play until one of them goes bankrupt. Find the probability that the guy with r1 dollars initially loses all the money at the end.

Let Pr1 be the probability then

61 of 64

Consequently,

Probability/Ch3

61

62 of 64

Laplace rule of succession

Probability/Ch3

62

As k is large,

This probability tends to 1 as n tends to infinity.

63 of 64

Laplace rule of succession

Probability/Ch3

63

If in the first n flips, only r flips are heads, n-r are tails, what is the probability that the (n+1)st flip is head ?

As k is large,

64 of 64

Probability/Ch3

64

we can use integration by parts. That is,

As a result,

and

as k is large