Docsity

04A - Probability Notes - G, Lecture notes of Computer science

Toggle sidebar
bg1
Chapter 18
Introduction to Probability
Probability plays a key role in the sciences —”hard” and social —including com-
puter science. Many algorithms rely on randomization. Investigating their cor-
rectness and performance requires probability theory. Moreover, computer sys-
tems designs, such as memory management, branch prediction, packet routing,
and load balancing are based on probabilistic assumptions and analyses. Probabil-
ity is central as well in related subjects such as information theory, cryptography,
artiïŹcial intelligence, and game theory. But we’ll start with a more down-to-earth
application: getting a prize in a game show.
18.1 Monty Hall
In the September 9, 1990 issue of Parade magazine, the columnist Marilyn vos Sa-
vant responded to this letter:
Suppose you’re on a game show, and you’re given the choice of three doors.
Behind one door is a car, behind the others, goats. You pick a door, say number
1, and the host, who knows what’s behind the doors, opens another door, say
number 3, which has a goat. He says to you, ”Do you want to pick door
number 2?” Is it to your advantage to switch your choice of doors?
Craig. F. Whitaker
Columbia, MD
The letter describes a situation like one faced by contestants on the 1970’s game
show Let’s Make a Deal, hosted by Monty Hall and Carol Merrill. Marilyn replied
that the contestant should indeed switch. She explained that if the car was behind
either of the two unpicked doors —which is twice as likely as the the car being
behind the picked door —the contestant wins by switching. But she soon received
a torrent of letters, many from mathematicians, telling her that she was wrong. The
problem generated thousands of hours of heated debate.
409
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b

Partial preview of the text

Download 04A - Probability Notes - G and more Lecture notes Computer science in PDF only on Docsity!

Chapter 18

Introduction to Probability

Probability plays a key role in the sciences —”hard” and social —including com puter science. Many algorithms rely on randomization. Investigating their cor rectness and performance requires probability theory. Moreover, computer sys tems designs, such as memory management, branch prediction, packet routing, and load balancing are based on probabilistic assumptions and analyses. Probabil ity is central as well in related subjects such as information theory, cryptography, artificial intelligence, and game theory. But we’ll start with a more down-to-earth application: getting a prize in a game show.

18.1 Monty Hall

In the September 9, 1990 issue of Parade magazine, the columnist Marilyn vos Sa vant responded to this letter:

Suppose you’re on a game show, and you’re given the choice of three doors. Behind one door is a car, behind the others, goats. You pick a door, say number 1, and the host, who knows what’s behind the doors, opens another door, say number 3, which has a goat. He says to you, ”Do you want to pick door number 2?” Is it to your advantage to switch your choice of doors? Craig. F. Whitaker Columbia, MD

The letter describes a situation like one faced by contestants on the 1970’s game show Let’s Make a Deal, hosted by Monty Hall and Carol Merrill. Marilyn replied that the contestant should indeed switch. She explained that if the car was behind either of the two unpicked doors —which is twice as likely as the the car being behind the picked door —the contestant wins by switching. But she soon received a torrent of letters, many from mathematicians, telling her that she was wrong. The problem generated thousands of hours of heated debate.

409

410 CHAPTER 18. INTRODUCTION TO PROBABILITY

This incident highlights a fact about probability: the subject uncovers lots of examples where ordinary intuition leads to completely wrong conclusions. So un til you’ve studied probabilities enough to have refined your intuition, a way to avoid errors is to fall back on a rigorous, systematic approach such as the Four Step Method.

18.1.1 The Four Step Method

Every probability problem involves some sort of randomized experiment, process, or game. And each such problem involves two distinct challenges:

  1. How do we model the situation mathematically?
  2. How do we solve the resulting mathematical problem?

In this section, we introduce a four step approach to questions of the form, “What is the probability that —– ?” In this approach, we build a probabilistic model step-by-step, formalizing the original question in terms of that model. Remark ably, the structured thinking that this approach imposes provides simple solutions to many famously-confusing problems. For example, as you’ll see, the four step method cuts through the confusion surrounding the Monty Hall problem like a Ginsu knife. However, more complex probability questions may spin off chal lenging counting, summing, and approximation problems— which, fortunately, you’ve already spent weeks learning how to solve.

18.1.2 Clarifying the Problem

Craig’s original letter to Marilyn vos Savant is a bit vague, so we must make some assumptions in order to have any hope of modeling the game formally:

  1. The car is equally likely to be hidden behind each of the three doors.
  2. The player is equally likely to pick each of the three doors, regardless of the car’s location.
  3. After the player picks a door, the host must open a different door with a goat behind it and offer the player the choice of staying with the original door or switching.
  4. If the host has a choice of which door to open, then he is equally likely to select each of them.

In making these assumptions, we’re reading a lot into Craig Whitaker’s letter. Other interpretations are at least as defensible, and some actually lead to differ ent answers. But let’s accept these assumptions for now and address the question, “What is the probability that a player who switches wins the car?”

412 CHAPTER 18. INTRODUCTION TO PROBABILITY

car location

player’s initial guess

door revealed

C

C

C

A

B

A

B

A B C A B C A B

A

C

A

C C

B

A

B

outcome

B

(A,A,B)

(A,A,C)

(A,B,C)

(B,A,C)

(B,B,A)

(B,B,C)

(B,C,A)

(C,A,B)

(C,B,A)

(C,C,A)

(C,C,B)

(A,C,B)

Notice that the third layer reflects the fact that the host has either one choice or two, depending on the position of the car and the door initially selected by the player. For example, if the prize is behind door A and the player picks door B, then the host must open door C. However, if the prize is behind door A and the player picks door A, then the host could open either door B or door C. Now let’s relate this picture to the terms we introduced earlier: the leaves of the tree represent outcomes of the experiment, and the set of all leaves represents the sample space. Thus, for this experiment, the sample space consists of 12 outcomes. For reference, we’ve labeled each outcome with a triple of doors indicating:

(door concealing prize, door initially chosen, door opened to reveal a goat)

In these terms, the sample space is the set:

(A, A, B), (A, A, C), (A, B, C), (A, C, B), (B, A, C), (B, B, A), (B, B, C), (B, C, A), (C, A, B), (C, B, A), (C, C, A), (C, C, B)

The tree diagram has a broader interpretation as well: we can regard the whole experiment as following a path from the root to a leaf, where the branch taken at each stage is “randomly” determined. Keep this interpretation in mind; we’ll use it again later.

18.1. MONTY HALL 413

18.1.4 Step 2: Define Events of Interest

Our objective is to answer questions of the form “What is the probability that... ?”, where the missing phrase might be “the player wins by switching”, “the player initially picked the door concealing the prize”, or “the prize is behind door C”, for example. Each of these phrases characterizes a set of outcomes: the outcomes specified by “the prize is behind door C” is:

{(C, A, B), (C, B, A), (C, C, A), (C, C, B)}

A set of outcomes is called an event. So the event that the player initially picked the door concealing the prize is the set:

{(A, A, B), (A, A, C), (B, B, A), (B, B, C), (C, C, A), (C, C, B)}

And what we’re really after, the event that the player wins by switching, is the set of outcomes:

{(A, B, C), (A, C, B), (B, A, C), (B, C, A), (C, A, B), (C, B, A)}

Let’s annotate our tree diagram to indicate the outcomes in this event.

car location

player’s initial guess

door revealed

switch wins?

C

C

C

A

B

A

B

A B C A B C A B

A

C

A

C C

B

A

B

outcome

X X X X X X B

(A,A,B)

(A,A,C)

(A,B,C)

(B,A,C)

(B,B,A)

(B,B,C)

(B,C,A)

(C,A,B)

(C,B,A)

(C,C,A)

(C,C,B)

(A,C,B)

18.1. MONTY HALL 415

car location

player’s initial guess

door revealed switch wins?

C

C

C

A

B

A

B

A B C A B C A B

A

C

A

C C

1/

1/

1/

1/ 1/

1/

1/ 1/

1/

1/

1/

1/

1 1 1 1 1 1

1/2 B

1/

1/

1/

A

B

1/

1/

outcome

X X X X X X B

(A,A,B)

(A,A,C)

(A,B,C)

(B,A,C)

(B,B,A)

(B,B,C)

(B,C,A)

(C,A,B)

(C,B,A)

(C,C,A)

(C,C,B)

(A,C,B)

Step 3b: Compute Outcome Probabilities

Our next job is to convert edge probabilities into outcome probabilities. This is a purely mechanical process: the probability of an outcome is equal to the product of the edge-probabilities on the path from the root to that outcome. For example, the probability of the topmost outcome, (A, A, B) is

1 1 1 1 =. 3

There’s an easy, intuitive justification for this rule. As the steps in an experi ment progress randomly along a path from the root of the tree to a leaf, the proba bilities on the edges indicate how likely the walk is to proceed along each branch. For example, a path starting at the root in our example is equally likely to go down each of the three top-level branches. Now, how likely is such a walk to arrive at the topmost outcome, (A, A, B)? Well, there is a 1-in-3 chance that a walk would follow the A-branch at the top level, a 1-in-3 chance it would continue along the A-branch at the second level, and 1-in-2 chance it would follow the B-branch at the third level. Thus, it seems that about 1 walk in 18 should arrive at the (A, A, B) leaf, which is precisely the probability we assign it. Anyway, let’s record all the outcome probabilities in our tree diagram.

416 CHAPTER 18. INTRODUCTION TO PROBABILITY

car location

player’s initial guess

door revealed switch wins?

C

C

C

A

B

A

B

A B C A B C A B

A

C

A

C C

1/

1/

1/

1/ 1/

1/

1/ 1/

1/

1/

1/

1/

1 1 1 1 1 1

1/2 B

1/

1/

1/

A

B

1/

1/

outcome

X X X X X X

probability 1/

1/

1/

1/

1/

1/

1/

1/

1/

1/

1/

1/

B

(A,A,B)

(A,A,C)

(A,B,C)

(B,A,C)

(B,B,A)

(B,B,C)

(B,C,A)

(C,A,B)

(C,B,A)

(C,C,A)

(C,C,B)

(A,C,B)

Specifying the probability of each outcome amounts to defining a function that maps each outcome to a probability. This function is usually called Pr. In these terms, we’ve just determined that:

Pr {(A, A, B)} = 18 1 Pr {(A, A, C)} = 18 1 Pr {(A, B, C)} = 9 etc.

18.1.6 Step 4: Compute Event Probabilities

We now have a probability for each outcome, but we want to determine the prob ability of an event which will be the sum of the probabilities of the outcomes in it. The probability of an event, E, is written Pr {E}. For example, the probability of

418 CHAPTER 18. INTRODUCTION TO PROBABILITY

Problem 18.2. To determine which of two people gets a prize, a coin is flipped twice. If the flips are a Head and then a Tail, the first player wins. If the flips are a Tail and then a Head, the second player wins. However, if both coins land the same way, the flips don’t count and whole the process starts over. Assume that on each flip, a Head comes up with probability p, regardless of what happened on other flips. Use the four step method to find a simple formula for the probability that the first player wins. What is the probability that neither player wins? Suggestions: The tree diagram and sample space are infinite, so you’re not go ing to finish drawing the tree. Try drawing only enough to see a pattern. Summing all the winning outcome probabilities directly is difficult. However, a neat trick solves this problem and many others. Let s be the sum of all winning outcome probabilities in the whole tree. Notice that you can write the sum of all the winning probabilities in certain subtrees as a function of s. Use this observation to write an equation in s and then solve.

Problem 18.3. [The Four-Door Deal] Let’s see what happens when Let’s Make a Deal is played with four doors. A prize is hidden behind one of the four doors. Then the contestant picks a door. Next, the host opens an unpicked door that has no prize behind it. The contestant is allowed to stick with their original door or to switch to one of the two unopened, unpicked doors. The contestant wins if their final choice is the door hiding the prize. Use The Four Step Method of Section 18.1 to find the following probabilities. The tree diagram may become awkwardly large, in which case just draw enough of it to make its structure clear.

(a) Contestant Stu, a sanitation engineer from Trenton, New Jersey, stays with his original door. What is the probability that Stu wins the prize?

(b) Contestant Zelda, an alien abduction researcher from Helena, Montana, switches to one of the remaining two doors with equal probability. What is the probability that Zelda wins the prize?

Problem 18.4. [Simulating a fair coin] Suppose you need a fair coin to decide which door to choose in the 6.042 Monty Hall game. After making everyone in your group empty their pockets, all you managed to turn up is some crumpled bubble gum wrappers, a few used tissues, and one penny. However, the penny was from Prof. Meyer’s pocket, so it is not safe to assume that it is a fair coin. How can we use a coin of unknown bias to get the same effect as a fair coin

18.2. SET THEORY AND PROBABILITY 419

of bias 1 / 2? Draw the tree diagram for your solution, but since it is infinite, draw only enough to see a pattern. Suggestion: A neat trick allows you to sum all the outcome probabilities that cause you to say ”Heads”: Let s be the sum of all ”Heads” outcome probabilities in the whole tree. Notice that you can write the sum of all the ”Heads” outcome proba bilities in certain subtrees as a function of s. Use this observation to write an equation in s and then solve.

Homework Problems

Problem 18.5. I have a deck of 52 regular playing cards, 26 red, 26 black, randomly shuffled. They all lie face down in the deck so that you can’t see them. I will draw a card off the top of the deck and turn it face up so that you can see it and then put it aside. I will continue to turn up cards like this but at some point while there are still cards left in the deck, you have to declare that you want the next card in the deck to be turned up. If that next card turns up black you win and otherwise you lose. Either way, the game is then over.

(a) Show that if you take the first card before you have seen any cards, you then have probability 1 / 2 of winning the game.

(b) Suppose you don’t take the first card and it turns up red. Show that you have then have a probability of winning the game that is greater than 1 / 2.

(c) If there are r red cards left in the deck and b black cards, show that the proba bility of winning in you take the next card is b/(r + b).

(d) Either,

  1. come up with a strategy for this game that gives you a probability of winning strictly greater than 1 / 2 and prove that the strategy works, or,
  2. come up with a proof that no such strategy can exist.

18.2 Set Theory and Probability

Let’s abstract what we’ve just done in this Monty Hall example into a general mathematical definition of probability. In the Monty Hall example, there were only finitely many possible outcomes. Other examples in this course will have a countably infinite number of outcomes. General probability theory deals with uncountable sets like the set of real num bers, but we won’t need these, and sticking to countable sets lets us define the probability of events using sums instead of integrals. It also lets us avoid some distracting technical problems in set theory like the Banach-Tarski “paradox” men tioned in Chapter 5.2.5.

18.2. SET THEORY AND PROBABILITY 421

Rule (Complement Rule).

Pr A = 1 − Pr {A}.

Sometimes the easiest way to compute the probability of an event is to compute the probability of its complement and then apply this formula. Some further basic facts about probability parallel facts about cardinalities of finite sets. In particular:

Pr {B − A} = Pr {B} − Pr {A ∩ B} , (Difference Rule) Pr {A âˆȘ B} = Pr {A} + Pr {B} − Pr {A ∩ B} , (Inclusion-Exclusion) Pr {A âˆȘ B} ≀ Pr {A} + Pr {B}. (Boole’s Inequality)

The Difference Rule follows from the Sum Rule because B is the union of the dis joint sets B − A and A ∩ B. Inclusion-Exclusion then follows from the Sum and Difference Rules, because AâˆȘB is the union of the disjoint sets A and B−A. Boole’s inequality is an immediate consequence of Inclusion-Exclusion since probabilities are nonnegative. The two event Inclusion-Exclusion equation above generalizes to n events in the same way as the corresponding Inclusion-Exclusion rule for n sets. Boole’s inequality also generalizes to

Pr {E 1 âˆȘ · · · âˆȘ En} ≀ Pr {E 1 } + · · · + Pr {En}. (Union Bound)

This simple Union Bound is actually useful in many calculations. For example, suppose that Ei is the event that the i-th critical component in a spacecraft fails. Then E 1 âˆȘ · · · âˆȘ En is the event that some critical component fails. The Union Bound can give an adequate upper bound on this vital probability. Similarly, the Difference Rule implies that

If A ⊆ B, then Pr {A} ≀ Pr {B}. (Monotonicity)

18.2.2 An Infinite Sample Space

Suppose two players take turns flipping a fair coin. Whoever flips heads first is declared the winner. What is the probability that the first player wins? A tree diagram for this problem is shown below:

422 CHAPTER 18. INTRODUCTION TO PROBABILITY

1/

1/

1/

1/

1/

1/

1/

1/

etc.

H

H

H

H

T

T

T

T

first player

second player

first player

second player

1/

1/

1/

1/

The event that the first player wins contains an infinite number of outcomes, but we can still sum their probabilities:

1 1 1 1 Pr {first player wins} = + + + + 2 8 32 128

∞ ïżœ^

ïżœn

(^2) n=0 4 1 1 2 = =. 2 1 − 1 / 4 3 Similarly, we can compute the probability that the second player wins: 1 1 1 1 Pr {second player wins} = + + + + 4 16 64 256

To be formal about this, sample space is the infinite set

S ::= {TnH | n ∈ N}

where Tn^ stands for a length n string of T’s. The probability function is

1 Pr {TnH} ::=. 2 n+

Since this function is obviously nonnegative, To verify that this is a probability space, we just have to check that all the probabilities sum to 1. But this follows directly from the formula for the sum of a geometric series:

ïżœ ïżœ 1 1 ïżœ (^1) Pr {TnH} = = = 1. TnH∈S n∈N 2 n+1^2 n∈N^2 n Notice that this model does not have an outcome corresponding to the possi bility that both players keep flipping tails forever —in the diagram, flipping for ever corresponds to following the infinite path in the tree without ever reaching

424 CHAPTER 18. INTRODUCTION TO PROBABILITY

(a) Show that the probability that the system fails could be as small as p by de scribing appropriate probabilities for the outcomes. Make sure to verify that the sum of your outcome probabilities is 1.

(b) Show that the probability that the system fails could actually be as large as np by describing appropriate probabilities for the outcomes. Make sure to verify that the sum of your outcome probabilities is 1.

(c) Prove inequality (18.1).

Problem 18.7. Here are some handy rules for reasoning about probabilities that all follow directly from the Disjoint Sum Rule in the Appendix. Prove them.

Pr {A − B} = Pr {A} − Pr {A ∩ B} (Difference Rule)

Pr A = 1 − Pr {A} (Complement Rule)

Pr {A âˆȘ B} = Pr {A} + Pr {B} − Pr {A ∩ B} (Inclusion-Exclusion)

Pr {A âˆȘ B} ≀ Pr {A} + Pr {B}. (2-event Union Bound)

If A ⊆ B, then Pr {A} ≀ Pr {B}. (Monotonicity)

Problem 18.8. Suppose Pr {} : S → [0, 1] is a probability function on a sample space, S, and let B be an event such that Pr {B} > 0. Define a function PrB {·} on events outcomes w ∈ S by the rule:

PrB {w} ::=

Pr {w} / Pr {B} if w ∈ B, (18.2) 0 if w /∈ B.

(a) Prove that PrB {·} is also a probability function on S according to Defini tion 18.2.2.

(b) Prove that Pr {A ∩ B} PrB {A} = Pr {B}

for all A ⊆ S.

18.3. CONDITIONAL PROBABILITY 425

18.3 Conditional Probability

Suppose that we pick a random person in the world. Everyone has an equal chance of being selected. Let A be the event that the person is an MIT student, and let B be the event that the person lives in Cambridge. What are the probabilities of these events? Intuitively, we’re picking a random point in the big ellipse shown below and asking how likely that point is to fall into region A or B:

A

B

set of all people

in the world

set of people who

live in Cambridge

set of MIT

students

The vast majority of people in the world neither live in Cambridge nor are MIT students, so events A and B both have low probability. But what is the probability that a person is an MIT student, given that the person lives in Cambridge? This should be much greater— but what is it exactly? What we’re asking for is called a conditional probability; that is, the probability that one event happens, given that some other event definitely happens. Questions about conditional probabilities come up all the time:

  • What is the probability that it will rain this afternoon, given that it is cloudy this morning?
  • What is the probability that two rolled dice sum to 10, given that both are odd?
  • What is the probability that I’ll get four-of-a-kind in Texas No Limit Hold ’Em Poker, given that I’m initially dealt two queens?

There is a special notation for conditional probabilities. In general, Pr {A | B} denotes the probability of event A, given that event B happens. So, in our example, Pr {A | B} is the probability that a random person is an MIT student, given that he or she is a Cambridge resident. How do we compute Pr {A | B}? Since we are given that the person lives in Cambridge, we can forget about everyone in the world who does not. Thus, all outcomes outside event B are irrelevant. So, intuitively, Pr {A | B} should be the fraction of Cambridge residents that are also MIT students; that is, the answer

18.3. CONDITIONAL PROBABILITY 427

L 1/

W

W

L 2/

L (^) 1/

W

L

L (^) 1/

W

W

1st game outcome 2nd game outcome

3rd game outcome probability

outcome

event B: win the 1st game?

event A: win the series?

WW

WLW

WLL

LWW

LWL

LL

outcome

Step 1: Find the Sample Space

Each internal vertex in the tree diagram has two children, one corresponding to a win for the Halting Problem (labeled W ) and one corresponding to a loss (labeled L). The complete sample space is:

S = {W W, W LW, W LL, LW W, LW L, LL}

Step 2: Define Events of Interest

The event that the Halting Problem wins the whole tournament is:

T = {W W, W LW, LW W }

And the event that the Halting Problem wins the first game is:

F = {W W, W LW, W LL}

The outcomes in these events are indicated with checkmarks in the tree diagram.

Step 3: Determine Outcome Probabilities

Next, we must assign a probability to each outcome. We begin by labeling edges as specified in the problem statement. Specifically, The Halting Problem has a 1 / 2 chance of winning the first game, so the two edges leaving the root are each as signed probability 1 / 2. Other edges are labeled 1 / 3 or 2 / 3 based on the outcome

428 CHAPTER 18. INTRODUCTION TO PROBABILITY

of the preceding game. We then find the probability of each outcome by multiply ing all probabilities along the corresponding root-to-leaf path. For example, the probability of outcome W LL is:

1 1 2 1

2

Step 4: Compute Event Probabilities

We can now compute the probability that The Halting Problem wins the tourna ment, given that they win the first game:

Pr {A ∩ B} Pr {A | B} = Pr {B} Pr {{W W, W LW }} = Pr {{W W, W LW, W LL}} 1 /3 + 1/ 18 = 1 /3 + 1/ 18 + 1 / 9 7 = 9

We’re done! If the Halting Problem wins the first game, then they win the whole tournament with probability 7 / 9.

18.3.2 Why Tree Diagrams Work

We’ve now settled into a routine of solving probability problems using tree dia grams. But we’ve left a big question unaddressed: what is the mathematical justi fication behind those funny little pictures? Why do they work? The answer involves conditional probabilities. In fact, the probabilities that we’ve been recording on the edges of tree diagrams are conditional probabilities. For example, consider the uppermost path in the tree diagram for the Halting Prob lem, which corresponds to the outcome W W. The first edge is labeled 1 / 2 , which is the probability that the Halting Problem wins the first game. The second edge is labeled 2 / 3 , which is the probability that the Halting Problem wins the second game, given that they won the first— that’s a conditional probability! More gener ally, on each edge of a tree diagram, we record the probability that the experiment proceeds along that path, given that it reaches the parent vertex. So we’ve been using conditional probabilities all along. But why can we mul tiply edge probabilities to get outcome probabilities? For example, we concluded that:

1 2 Pr {W W } = 2