08: Poisson and More - Stanford University · Catching Pokemon 29 1.Define events/ RVs & state goal...

Post on 13-Aug-2020

0 views 0 download

transcript

08: Poisson and MoreLisa Yan and Jerry CainSeptember 30, 2020

1

Lisa Yan and Jerry Cain, CS109, 2020

Quick slide reference

2

3 Poisson 08a_poisson

11 Poisson, continued 08b_poisson_ii

17 Other Discrete RVs 08c_other_discrete

25 Exercises LIVE

33 Poisson approximation LIVE

Poisson RV

3

08a_poisson

Lisa Yan and Jerry Cain, CS109, 2020

Before we start

The natural exponent !:

https://en.wikipedia.org/wiki/E_(mathematical_constant)

4

lim!→#

1 − &'

!= )$%

Jacob Bernoulliwhile studying

compound interest in 1683

Lisa Yan and Jerry Cain, CS109, 2020

Algorithmic ride sharing

5

!

!

"

""

Probability of " requests from this area in the next 1 minute?On average, ! = 5 requests per minuteSuppose we know:

Lisa Yan and Jerry Cain, CS109, 2020

Algorithmic ride sharing, approximately

At each second:• Independent trial• You get a request (1) or you don’t (0).

Let # = # of requests in minute.% # = & = 5

6

Probability of " requests from this area in the next 1 minute?On average, ! = 5 requests per minute

0 0 1 0 1 … 0 0 0 0 1

1 2 3 4 5 60

# ~ Bin ) = 60, - = 5/60

Break a minute down into 60 seconds:

/ # = " =60"

5

60

!1 −

5

60

"#!

But what if there are two requests in the same second?!

Lisa Yan and Jerry Cain, CS109, 2020

Algorithmic ride sharing, approximately

At each millisecond:• Independent trial• You get a request (1) or you don’t (0).

Let # = # of requests in minute.% # = & = 5

7

Probability of " requests from this area in the next 1 minute?On average, ! = 5 requests per minute

Break a minute down into 60,000 milliseconds:

/ # = " =)"

&

)

!1 −

&

)

"#!

1 60,000

# ~ Bin ) = 60000, - = &/)

But what if there are two requests in the same millisecond?!

Lisa Yan and Jerry Cain, CS109, 2020

Algorithmic ride sharing, approximately

For each time bucket:• Independent trial• You get a request (1) or you don’t (0).

Let # = # of requests in minute.% # = & = 5

8

Probability of " requests from this area in the next 1 minute?On average, ! = 5 requests per minute

Break a minute down into infinitely small buckets:

/ # = " = lim"→%

)"

&

)

!1 −

&

)

"#!

Who wants to see some cool math?

OMG so small

1 ∞

# ~ Bin ), - = &/)

Lisa Yan and Jerry Cain, CS109, 2020

Binomial in the limit

9

/ # = " = lim"→%

)"

&

)

!1 −

&

)

"#!= lim"→$

'!)!(' − ))!

!%'%

1 − l'

"

1 − l'

%

lim!→#

1 − +,

!= .$%

= lim"→$'!

'%(' − ))!!%)!

1 − l'

"

1 − l'

%

Expand

Rearrange

= lim"→$'!

'%(' − ))!!%)!

./0

1 − l'

%Def natural

exponent

= lim"→$' ' − 1 ⋯ ' − ) + 1

'%' − ) !' − ) !

!%)!

./0

1 − l'

%Expand

= lim"→$'%'%

!%)!

./01

Limit analysis

+ cancel= !%)! .

/0Simplify

Lisa Yan and Jerry Cain, CS109, 2020

Algorithmic ride sharing

10

!

!

"

""

Probability of " requests from this area in the next 1 minute?On average, ! = 5 requests per minute

* + = , = &&,! )

$% Poisson distribution

Poisson, continued

11

08b_poisson_ii

Lisa Yan and Jerry Cain, CS109, 2020

Consider an experiment that lasts a fixed interval of time.def A Poisson random variable # is the number of successes over the

experiment duration, assuming the time that each success occurs isindependent and the average # of requests over time is constant.

Examples:• # earthquakes per year• # server hits per second• # of emails per day

Poisson Random Variable

12

1 End of interval

the time that each success occurs isindependent

Lisa Yan and Jerry Cain, CS109, 2020

Consider an experiment that lasts a fixed interval of time.def A Poisson random variable # is the number of successes over the

experiment duration, assuming the time that each success occurs isindependent and the average # of requests over time is constant.

Examples:• # earthquakes per year• # server hits per second• # of emails per day

Yes, expectation == variance for Poisson RV! More later.

Poisson Random Variable

13

* + = , = )$% &&

,!!~Poi($)Support: {0,1, 2, … }

PMF

% # = &Var # = &Variance

Expectation

Lisa Yan and Jerry Cain, CS109, 2020

Simeon-Denis Poisson

French mathematician (1781 – 1840)• Published his first paper at age 18• Professor at age 21• Published over 300 papers“Life is only good for two things: doing mathematics and teaching it.”

14

Lisa Yan and Jerry Cain, CS109, 2020

EarthquakesThere are an average of 2.79 major earthquakes in the world each year, and major earthquakes occur independently.What is the probability of 3 major earthquakes happening next year?

15

& ' = )!" *#

'!

1. Define RVs

2. Solve

0

0.05

0.1

0.15

0.2

0.25

0.3

0 1 2 3 4 5 6 7 8 9 10

1(2

= 3)

Number of earthquakes, 3

,~Poi(*)0 , = *

Lisa Yan and Jerry Cain, CS109, 2020

Are earthquakes really Poissonian?

16

Other Discrete RVs

17

08c_other_discrete

Lisa Yan and Jerry Cain, CS109, 2020

Grid of random variables

18

Number of successes

Ber(/)One trial

Severaltrials

Intervalof time

Bin(', /)

Poi(&) (tomorrow)

One success

Severalsuccesses

Interval of time tofirst success

Time until success

1 = 1

Lisa Yan and Jerry Cain, CS109, 2020

Consider an experiment: independent trials of Ber(-) random variables.def A Geometric random variable # is the # of trials until the first success.

Examples:• Flipping a coin (7 heads = 8) until first heads appears• Generate bits with 7 bit = 1 = 8 until first 1 generated

Geometric RV

19

* + = , = 1 − / &$'/!~Geo(&)Support: {1, 2, … }

PMF

% # =34

Var # =3#44!

Variance

Expectation

Lisa Yan and Jerry Cain, CS109, 2020

Consider an experiment: independent trials of Ber(-) random variables.def A Negative Binomial random variable # is the # of trials until

7 successes.

Examples:• Flipping a coin until 945 heads appears• # of strings to hash into table until bucket 1 has 9 entries

Negative Binomial RV

20

/ # = " =" − 17 − 1

1 − - !#5-5!~NegBin(', &)Support: {9, 9 + 1,… }

PMF

% # =54

Var # =5 3#44!

VarianceExpectation

Geo 8 = NegBin(1, 8)

Lisa Yan and Jerry Cain, CS109, 2020

Grid of random variables

21

Number of successes

Ber(/)One trial

Severaltrials

Intervalof time

Bin(', /)

Poi(&)

Geo(/)

NegBin(2, /)

(tomorrow)

One success

Severalsuccesses

Interval of time tofirst success

Time until success

1 = 1 6 = 1

Lisa Yan and Jerry Cain, CS109, 2020

Catching PokemonWild Pokemon are captured by throwing Pokeballs at them.• Each ball has probability p = 0.1 of capturing the Pokemon.• Each ball is an independent trial.

What is the probability that you catch the Pokemon on the 5th try?

22

1. Define events/ RVs & state goal

A. #~Bin 5, 0.1B. #~Poi 0.5C. #~NegBin 5, 0.1D. #~NegBin 1, 0.1E. #~Geo 0.1F. None/other

2. Solve

#~some distribution

Want: 7 : = 5

!

Lisa Yan and Jerry Cain, CS109, 2020

Wild Pokemon are captured by throwing Pokeballs at them.• Each ball has probability p = 0.1 of capturing the Pokemon.• Each ball is an independent trial.

What is the probability that you catch the Pokemon on the 5th try?

A. #~Bin 5, 0.1B. #~Poi 0.5C. #~NegBin 5, 0.1D. #~NegBin 1, 0.1E. #~Geo 0.1F. None/other

Catching Pokemon

23

1. Define events/ RVs & state goal

2. Solve

#~some distribution

Want: 7 : = 5

Lisa Yan and Jerry Cain, CS109, 2020

2. Solve

Catching PokemonWild Pokemon are captured by throwing Pokeballs at them.• Each ball has probability p = 0.1 of capturing the Pokemon.• Each ball is an independent trial.

What is the probability that you catch the Pokemon on the 5th try?

24

1. Define events/ RVs & state goal

2. Solve

#~Geo 0.1

Want: 7 : = 5

,~Geo(&) & ' = 1 − & #!$&