36
03: Intro to Probability Lisa Yan April 10, 2020 1

03: Intro to Probability - Stanford University · Lisa Yan, CS109, 2020 Target revisited Screen size = 800×800 Radius of target: 200 The dart is equally likely to land anywhere on

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: 03: Intro to Probability - Stanford University · Lisa Yan, CS109, 2020 Target revisited Screen size = 800×800 Radius of target: 200 The dart is equally likely to land anywhere on

03: Intro to ProbabilityLisa YanApril 10, 2020

1

Page 2: 03: Intro to Probability - Stanford University · Lisa Yan, CS109, 2020 Target revisited Screen size = 800×800 Radius of target: 200 The dart is equally likely to land anywhere on

Lisa Yan, CS109, 2020

Quick slide reference

2

3 Defining Probability 03a_definitions

13 Axioms of Probability 03b_axioms

20 Equally likely outcomes 03c_elo

30 Corollaries 03d_corollaries

37 Exercises LIVE

Today’s discussion thread: https://us.edstem.org/courses/109/discussion/24492

Page 3: 03: Intro to Probability - Stanford University · Lisa Yan, CS109, 2020 Target revisited Screen size = 800×800 Radius of target: 200 The dart is equally likely to land anywhere on

Defining Probability

3

Gradescope quiz, blank slide deck, etc.http://cs109.stanford.edu/

03a_definitions

Page 4: 03: Intro to Probability - Stanford University · Lisa Yan, CS109, 2020 Target revisited Screen size = 800×800 Radius of target: 200 The dart is equally likely to land anywhere on

Lisa Yan, CS109, 2020

Key definitions

An experiment in probability:

Sample Space, !: The set of all possible outcomes of an experimentEvent, ": Some subset of ! (" ⊆ !).

Outcome

4

Experiment

!

"

Page 5: 03: Intro to Probability - Stanford University · Lisa Yan, CS109, 2020 Target revisited Screen size = 800×800 Radius of target: 200 The dart is equally likely to land anywhere on

Lisa Yan, CS109, 2020 5

Key definitionsEvent, "• Flip lands heads" = Heads

• ≥ 1 head on 2 coin flips" = (H,H), (H,T), (T,H)

• Roll is 3 or less:" = 1, 2, 3

• Low email day (≤ 20 emails)" = 1 | 1 ∈ ℤ, 0 ≤ 1 ≤ 20

• Wasted day (≥ 5 TT hours):" = 1 | 1 ∈ ℝ, 5 ≤ 1 ≤ 24

Sample Space, !• Coin flip! = Heads, Tails

• Flipping two coins! = (H,H), (H,T), (T,H), (T,T)

• Roll of 6-sided die! ={1,2,3,4,5,6}

• # emails in a day! = 1 | 1 ∈ ℤ, 1 ≥ 0

• TikTok hours in a day! = 1 | 1 ∈ ℝ, 0 ≤ 1 ≤ 24

Page 6: 03: Intro to Probability - Stanford University · Lisa Yan, CS109, 2020 Target revisited Screen size = 800×800 Radius of target: 200 The dart is equally likely to land anywhere on

Lisa Yan, CS109, 2020

What is a probability?

A number between 0 and 1to which we ascribe meaning.*

6

*our belief that an event " occurs.

Page 7: 03: Intro to Probability - Stanford University · Lisa Yan, CS109, 2020 Target revisited Screen size = 800×800 Radius of target: 200 The dart is equally likely to land anywhere on

Lisa Yan, CS109, 2020

What is a probability?

! " = lim!→#'(")'

A = # of total trialsA(") = # trials where " occurs

7

Let " = the set of outcomeswhere you hit the target.

Page 8: 03: Intro to Probability - Stanford University · Lisa Yan, CS109, 2020 Target revisited Screen size = 800×800 Radius of target: 200 The dart is equally likely to land anywhere on

Lisa Yan, CS109, 2020

What is a probability?

! " = lim!→#'(")'

A = # of total trialsA(") = # trials where " occurs

8

Let " = the set of outcomeswhere you hit the target.

Page 9: 03: Intro to Probability - Stanford University · Lisa Yan, CS109, 2020 Target revisited Screen size = 800×800 Radius of target: 200 The dart is equally likely to land anywhere on

Lisa Yan, CS109, 2020

What is a probability?

! " = lim!→#'(")'

A = # of total trialsA(") = # trials where " occurs

9

Let " = the set of outcomeswhere you hit the target.

B " ≈ 0.500

Page 10: 03: Intro to Probability - Stanford University · Lisa Yan, CS109, 2020 Target revisited Screen size = 800×800 Radius of target: 200 The dart is equally likely to land anywhere on

Lisa Yan, CS109, 2020

What is a probability?

! " = lim!→#'(")'

A = # of total trialsA(") = # trials where " occurs

10

Let " = the set of outcomeswhere you hit the target.

B " ≈ 0.667

Page 11: 03: Intro to Probability - Stanford University · Lisa Yan, CS109, 2020 Target revisited Screen size = 800×800 Radius of target: 200 The dart is equally likely to land anywhere on

Lisa Yan, CS109, 2020

What is a probability?

! " = lim!→#'(")'

A = # of total trialsA(") = # trials where " occurs

11

Let " = the set of outcomeswhere you hit the target.

B " ≈ 0.458

Page 12: 03: Intro to Probability - Stanford University · Lisa Yan, CS109, 2020 Target revisited Screen size = 800×800 Radius of target: 200 The dart is equally likely to land anywhere on

Lisa Yan, CS109, 2020 12Not just yet…

Page 13: 03: Intro to Probability - Stanford University · Lisa Yan, CS109, 2020 Target revisited Screen size = 800×800 Radius of target: 200 The dart is equally likely to land anywhere on

Axioms of Probability

13

03b_axioms

Page 14: 03: Intro to Probability - Stanford University · Lisa Yan, CS109, 2020 Target revisited Screen size = 800×800 Radius of target: 200 The dart is equally likely to land anywhere on

Lisa Yan, CS109, 2020

Quick review of sets

14

Review of Sets

E F

S " and G are events in !.Experiment:

Die roll! = 1, 2, 3, 4, 5, 6Let " = 1, 2 , and G = 2,3

Page 15: 03: Intro to Probability - Stanford University · Lisa Yan, CS109, 2020 Target revisited Screen size = 800×800 Radius of target: 200 The dart is equally likely to land anywhere on

Lisa Yan, CS109, 2020

Quick review of sets

15

Review of Sets

" and G are events in !.Experiment:

Die roll! = 1, 2, 3, 4, 5, 6Let " = 1, 2 , and G = 2,3

E

S

F

def Union of events, " ∪ GThe event containing all outcomes in " or G.

! ∪ # = {1,2,3}

Page 16: 03: Intro to Probability - Stanford University · Lisa Yan, CS109, 2020 Target revisited Screen size = 800×800 Radius of target: 200 The dart is equally likely to land anywhere on

Lisa Yan, CS109, 2020

Quick review of sets

16

Review of Sets

" and G are events in !.Experiment:

Die roll! = 1, 2, 3, 4, 5, 6Let " = 1, 2 , and G = 2,3

E

S

F

def Intersection of events, " ∩ GThe event containing all outcomes in " and G.

! ∩ # = !# = {2}

def Mutually exclusive events Gand J means that G ∩ J = ∅

G

Page 17: 03: Intro to Probability - Stanford University · Lisa Yan, CS109, 2020 Target revisited Screen size = 800×800 Radius of target: 200 The dart is equally likely to land anywhere on

Lisa Yan, CS109, 2020

Quick review of sets

17

Review of Sets

" and G are events in !.Experiment:

Die roll! = 1, 2, 3, 4, 5, 6Let " = 1, 2 , and G = 2,3

E

S

F

def Complement of event ", "!The event containing all outcomes in that are not in ".

!! = {3, 4, 5, 6}

Page 18: 03: Intro to Probability - Stanford University · Lisa Yan, CS109, 2020 Target revisited Screen size = 800×800 Radius of target: 200 The dart is equally likely to land anywhere on

Lisa Yan, CS109, 2020

3 Axioms of Probability

Definition of probability: B " = lim"→$

"(&)"

Axiom 1: 0 ≤ B " ≤ 1

Axiom 2: B ! = 1

Axiom 3: If " and G are mutually exclusive (" ∩ G = ∅),then B " ∪ G = B " + B G

18

Page 19: 03: Intro to Probability - Stanford University · Lisa Yan, CS109, 2020 Target revisited Screen size = 800×800 Radius of target: 200 The dart is equally likely to land anywhere on

Lisa Yan, CS109, 2020

Axiom 3 is the (analytically) useful Axiom

Axiom 3: If " and G are mutually exclusive (" ∩ G = ∅),then B " ∪ G = B " + B G

More generally, for any sequence ofmutually exclusive events "(, "), … :

19

(like the Sum Rule of Counting, but for probabilities)

B O*+(

$"* =P

*+(

$B "*

!

"! ""

"#

Page 20: 03: Intro to Probability - Stanford University · Lisa Yan, CS109, 2020 Target revisited Screen size = 800×800 Radius of target: 200 The dart is equally likely to land anywhere on

Equally Likely Outcomes

20

03c_elo

Page 21: 03: Intro to Probability - Stanford University · Lisa Yan, CS109, 2020 Target revisited Screen size = 800×800 Radius of target: 200 The dart is equally likely to land anywhere on

Lisa Yan, CS109, 2020

Equally Likely Outcomes

Some sample spaces have equally likely outcomes.• Coin flip: S = {Head, Tails}• Flipping two coins: S = {(H, H), (H, T), (T, H), (T, T)}• Roll of 6-sided die: S = {1, 2, 3, 4, 5, 6}If we have equally likely outcomes, then P(Each outcome)

Therefore

21

(by Axiom 3)

= 1|$|

%(') = # outcomes in E# outcomes in S = |'|

|$|

Page 22: 03: Intro to Probability - Stanford University · Lisa Yan, CS109, 2020 Target revisited Screen size = 800×800 Radius of target: 200 The dart is equally likely to land anywhere on

Lisa Yan, CS109, 2020

Roll two dice

Roll two 6-sided fair dice. What is P(sum = 7)?

! = { (1, 1) , (1, 2), (1, 3), (1, 4), (1, 5), (1, 6),(2, 1) , (2, 2), (2, 3), (2, 4), (2, 5), (2, 6),(3, 1) , (3, 2), (3, 3), (3, 4), (3, 5), (3, 6),(4, 1) , (4, 2), (4, 3), (4, 4), (4, 5), (4, 6),(5, 1) , (5, 2), (5, 3), (5, 4), (5, 5), (5, 6),(6, 1) , (6, 2), (6, 3), (6, 4), (6, 5), (6, 6)}

" =

22

$ % = |%||(|

Equally likely outcomes

Page 23: 03: Intro to Probability - Stanford University · Lisa Yan, CS109, 2020 Target revisited Screen size = 800×800 Radius of target: 200 The dart is equally likely to land anywhere on

Lisa Yan, CS109, 2020

Target revisited

23

Page 24: 03: Intro to Probability - Stanford University · Lisa Yan, CS109, 2020 Target revisited Screen size = 800×800 Radius of target: 200 The dart is equally likely to land anywhere on

Lisa Yan, CS109, 2020

Target revisitedScreen size = 800 ×800Radius of target: 200The dart is equally likely to land anywhere on the screen. What is B " , the probability of hitting the target?

B " = "! ≈ R ⋅ 200)

800) ≈ 0.1963

24

Let " = the set of outcomeswhere you hit the target.

! = 800) " ≈ R ⋅ 200)

$ % = |%||(|

Equally likely outcomes

Page 25: 03: Intro to Probability - Stanford University · Lisa Yan, CS109, 2020 Target revisited Screen size = 800×800 Radius of target: 200 The dart is equally likely to land anywhere on

Lisa Yan, CS109, 2020

Target revisitedScreen size = 800 ×800Radius of target: 200The dart is equally likely to land anywhere on the screen. What is B " , the probability of hitting the target?

B " = "! ≈ R ⋅ 200)

800) ≈ 0.1963

25

Let " = the set of outcomeswhere you hit the target.

! = 800) " ≈ R ⋅ 200)

$ % = |%||(|

Equally likely outcomes

Page 26: 03: Intro to Probability - Stanford University · Lisa Yan, CS109, 2020 Target revisited Screen size = 800×800 Radius of target: 200 The dart is equally likely to land anywhere on

Lisa Yan, CS109, 2020

Play the lottery.What is B win ?

! = {Lose,Win}" = {Win}

B " = |"||!| =

12 = 50%?

26

Not equally likely outcomes $ % = |%||(|

Equally likely outcomes

The hard part: defining outcomes consistently across sample space and events

Page 27: 03: Intro to Probability - Stanford University · Lisa Yan, CS109, 2020 Target revisited Screen size = 800×800 Radius of target: 200 The dart is equally likely to land anywhere on

Lisa Yan, CS109, 2020

Cats and sharks4 cats and 3 sharks in a bag. 3 drawn.What is P(1 cat and 2 sharks drawn)?

27

Note: Do indistinct objects give you an equally likely sample space?

A.\]

B.^_ ⋅

`\

C._]+ 2 ⋅

\a

D.^`\b

E. Zero/other

$ % = |%||(|

Equally likely outcomes

!

(No)

Make indistinct items distinctto get equally likely outcomes.

Page 28: 03: Intro to Probability - Stanford University · Lisa Yan, CS109, 2020 Target revisited Screen size = 800×800 Radius of target: 200 The dart is equally likely to land anywhere on

Lisa Yan, CS109, 2020

Cats and sharks (ordered solution)4 cats and 3 sharks in a bag. 3 drawn.What is P(1 cat and 2 sharks drawn)?

28

Define• ! = Pick 3 distinct

items

•" = 1 distinct cat,2 distinct sharks

$ % = |%||(|

Equally likely outcomes

Make indistinct items distinctto get equally likely outcomes.

Page 29: 03: Intro to Probability - Stanford University · Lisa Yan, CS109, 2020 Target revisited Screen size = 800×800 Radius of target: 200 The dart is equally likely to land anywhere on

Lisa Yan, CS109, 2020

Cats and sharks (unordered solution)4 cats and 3 sharks in a bag. 3 drawn.What is P(1 cat and 2 sharks drawn)?

29

$ % = |%||(|

Equally likely outcomes

Define• ! = Pick 3 distinct

items

•" = 1 distinct cat,2 distinct sharks

Make indistinct items distinctto get equally likely outcomes.

Page 30: 03: Intro to Probability - Stanford University · Lisa Yan, CS109, 2020 Target revisited Screen size = 800×800 Radius of target: 200 The dart is equally likely to land anywhere on

Corollaries of Probability

30

03d_corollaries

Page 31: 03: Intro to Probability - Stanford University · Lisa Yan, CS109, 2020 Target revisited Screen size = 800×800 Radius of target: 200 The dart is equally likely to land anywhere on

Lisa Yan, CS109, 2020

Axioms of Probability

Definition of probability: B " = lim"→$

"(&)"

Axiom 1: 0 ≤ B " ≤ 1

Axiom 2: B ! = 1

Axiom 3: If " and G are mutually exclusive (" ∩ G = ∅),then B " ∪ G = B " + B G

31

Review

Page 32: 03: Intro to Probability - Stanford University · Lisa Yan, CS109, 2020 Target revisited Screen size = 800×800 Radius of target: 200 The dart is equally likely to land anywhere on

Lisa Yan, CS109, 2020

3 Corollaries of Axioms of Probability

Corollary 1: B "! = 1 − B(")

32

Page 33: 03: Intro to Probability - Stanford University · Lisa Yan, CS109, 2020 Target revisited Screen size = 800×800 Radius of target: 200 The dart is equally likely to land anywhere on

Lisa Yan, CS109, 2020

Proof of Corollary 1Corollary 1: " #! = 1 − "(#)

Proof:

#, #! are mutually exclusive Definition of #!

" # ∪ #! = " # + " #! Axiom 3

+ = # ∪ #! Everything must either bein # or #!, by definition

1 = " + = " # + " #! Axiom 2

" #! = 1 − "(#) Rearrange

33

Page 34: 03: Intro to Probability - Stanford University · Lisa Yan, CS109, 2020 Target revisited Screen size = 800×800 Radius of target: 200 The dart is equally likely to land anywhere on

Lisa Yan, CS109, 2020

3 Corollaries of Axioms of Probability

Corollary 1: B "! = 1 − B(")

Corollary 2: If " ⊆ G, then B " ≤ B(G)

Corollary 3: B " ∪ G = B " + B G − B "G(Inclusion-Exclusion Principle for Probability)

34

Page 35: 03: Intro to Probability - Stanford University · Lisa Yan, CS109, 2020 Target revisited Screen size = 800×800 Radius of target: 200 The dart is equally likely to land anywhere on

Lisa Yan, CS109, 2020

Selecting Programmers• P(student programs in Java) = 0.28• P(student programs in Python) = 0.07• P(student programs in Java and Python) = 0.05.

What is P(student does not program in (Java or Python))?

35

1. Define events& state goal

2. Identify knownprobabilities

3. Solve

Page 36: 03: Intro to Probability - Stanford University · Lisa Yan, CS109, 2020 Target revisited Screen size = 800×800 Radius of target: 200 The dart is equally likely to land anywhere on

Lisa Yan, CS109, 2020

Corollary 3: B " ∪ G = B " + B G − B "G(Inclusion-Exclusion Principle for Probability)

General form:

Inclusion-Exclusion Principle (Corollary 3)

B " ∪ G ∪ J =B " + B G + B(J)

− B " ∩ G − B " ∩ J − B G ∩ J+ B " ∩ G ∩ J

36

# ∪)*+! "* =&,+!

)−1 ,-! &

*!.⋯.*"# ∩,0+! "*#

E

FG

r = 1:

r = 2:

r = 3: