Expectation Continued: Tail Sum, Coupon Collector, and Functions of - - PowerPoint PPT Presentation

expectation continued tail sum coupon collector and
SMART_READER_LITE
LIVE PREVIEW

Expectation Continued: Tail Sum, Coupon Collector, and Functions of - - PowerPoint PPT Presentation

Expectation Continued: Tail Sum, Coupon Collector, and Functions of RVs CS 70, Summer 2019 Lecture 20, 7/29/19 1 / 26 Last Time... I Expectation describes the weighted average of a RV. I For more complicated RVs, use linearity Today: I Proof


slide-1
SLIDE 1

Expectation Continued: Tail Sum, Coupon Collector, and Functions of RVs

CS 70, Summer 2019 Lecture 20, 7/29/19

1 / 26
slide-2
SLIDE 2

Last Time...

I Expectation describes the weighted

average of a RV.

I For more complicated RVs, use linearity

Today:

I Proof of linearity of expectation I The tail sum formula I Expectations of Geometric and Poisson I Expectation of a function of an RV

2 / 26
slide-3
SLIDE 3

Sanity Check

Let X be a RV that takes on values in A. Let Y be a RV that takes on values in B. Let c ∈ R be a constant. Both c · X and X + Y are also RVs!

3 / 26

Xty

Values

a

,

a

Values :{

atb

, AEA,bEB}

Probe

:

probs

:

IPCC X

= ca ]=p[X=a ]

ipfxty

  • Atb ]=P[X=a,7=b ]
slide-4
SLIDE 4

Proof of Linearity of Expectation I

Recall linearity of expectation: E[X1 + . . . + Xn] = E[X1] + . . . + E[Xn] For constant c, E[cXi] = c · E[Xi] First, we show E[cXi] = c · E[Xi]:

4 / 26

Xi

values in A

.

Efc Xi )

=

I

¢

a) IPCX

=

a ]

A E A =

c ÷ ,

a . IPEX
  • a ]
= c IE [ X i]
  • EC Xi ]
slide-5
SLIDE 5

Proof of Linearity of Expectation II

Next, we show E[X + Y ] = E[X] + E[Y ]. Two variables to n variables?

5 / 26

X

has

values

MA

,

y

has

values

in

B

.

Efxty

]=

I

(

at b) p[X=a , Y
  • b ]
AEA , BEB

rewrite

" 4*94 . b)

ate ,£⇒b

.

PCx=aY=b ]

AFAFEB

  • #
  • f
= ¥aaq⇒pCx=a , 't b) tfepbff.PK/--a.Y--b]

EE

¥=b]

BEBAEA

=

qfaa.ipcx-ay-qf.gg

b

  • PLY
  • b ]

TEXT TEE

Induction

.
slide-6
SLIDE 6

The Tail Sum Formula

Let X be a RV with values in {0, 1, 2, . . . , n}. We use “tail” to describe P[X ≥ i]. What does P∞

i=1 P[X ≥ i] look like?

Small example: X only takes values {0, 1, 2}:

6 / 26 A non
  • neg

integers

team

€7

PEX

Z i ] =

PEX

21 ]

t

PEX

22 ] /

\ =

p Cx

  • I

]

t

PIX

= 2) t

¥

EX

= 2 ]

Or PEX

+1

.

IPCX

  • I ]
  • 12
. PCX
  • 2 ]

EF

slide-7
SLIDE 7

The Tail Sum Formula

The tail sum formula states that: E[X] =

X

i=1

P[X ≥ i] Proof: Let pi = P[X = i].

7 / 26

x Ronning

ers =

€,9P[ x

Z

i ]

=

PEX Z IT

t

P EX Z 2)

t PEX 233? =

( p , t¥pz

t . . . ) t (

¥713

t

Pat

. . .) ! +

I p ,

t

Pg

t . . . )

O

' P

I

. p ,

t

2

' p a t

3

. Pz t .
  • =

E EXT

slide-8
SLIDE 8

Expectation of a Geometric I

Let X ∼ Geometric(p). P[X ≥ i] = Apply the tail sum formula:

8 / 26

i

  • I

H

  • p )

÷

,
  • pfxzi

]

=

It

( I

  • p ) th
  • pit
. . .
  • Geometric

series

first

Esma =L

,

r

  • H
  • P )
  • Fr
  • Ifpi
slide-9
SLIDE 9

Expectation of a Geometric II

Use memorylessness: the fact that the geometric RV “resets” after each trial. Two Cases:

9 / 26

X

  • aeomcp)

ft

art

trials

failed

P

first

trial

.

succeed

fall 1st trial

. " win in

2day

. " "

win

in 1€E[X

]

days

" "

reset

, "

day

2

looks

identical

to

day

I .

ECX ]

=p

(1)

t

( I

  • p ) f

ITEM

]

Solve

for

ECX ]

.

PIECX I

'

Http

Efxtipt

slide-10
SLIDE 10

Expectation of a Geometric III

Lastly, an intuitive but non-rigorous idea. Let Xi be an indicator variable for success in a single trial. Recall trials are i.i.d. Xi ∼ E[X1 + X2 + . . . + Xk] =

10 / 26

X

  • Geom

Cp) Ber ( p )

use

linearity

  • f

expectation

Efx

, It

ECX.IT

. . .tECXn ] =

KEEX

, ] =

Kp

Need

K

= pt in
  • rder

for

ECX

, t . . . t

Xx )

=

I

  • #
  • f
successes .
slide-11
SLIDE 11

Coupon Collector I

(Note 19.) I’m out collecting trading cards. There are n types total. I get a random trading card every time I buy a cereal box. What is the expected number of boxes I need to buy in order to get all n trading cards? High level picture:

11 / 26

Time

T ,

Tz

  • 13

=L

xz Xz

X4

get

get

get

1St 2nd

3rd card !

card ! card

.
slide-12
SLIDE 12

Coupon Collector II

Let Xi = What is the dist. of X1? What is the dist. of X2? What is the dist. of X3? In general, what is the dist. of Xi?

12 / 26

time /

" #

boxes

"

between

Ci

  • Dth

card and

the

ith

Geom

CL)

X ,

=L

always

.

Xz

~

Geom

( ht )

Xz

~

Geom

( MT ) Xi

  • Geom ( nifty
slide-13
SLIDE 13

Coupon Collector III

Let X = X = E[X] =

13 / 26

total

# boxes

to

get

all

n

cards

X ,

t

Xzt

.
  • t Xn

IE [ Xitxzt

. . .

txn ]

linearity

=

Efx

, ]

HECK )

t .
  • TECXN]

d

Xi

n

Geom I

n-ci

,

It

IT

t

#

t

. . . thy

%

= nEi e-

? ?

slide-14
SLIDE 14

Aside: (Partial) Harmonic Series

Harmonic Series: P∞

k=1 1 k

Approximation for Pn

k=1 1 k in terms of n?

14 / 26

Diverges

E.it#fIdx=lnx/7--lnn-In1/

"

x

inn

.

coupon collector

:

E EXT

F

N

log N

.

¥¥IE¥

.

EE

slide-15
SLIDE 15

Break

A Bad Harmonic Series Joke... A countably infinite number of mathematicians walk into a bar. The first one orders a pint of beer, the second one orders a half pint, the third

  • ne orders a third of a pint, the fourth one orders

a fourth of a pint, and so on. The bartender says ...

15 / 26
slide-16
SLIDE 16

Expectation of a Poisson I

Recall the Poisson distribution: values 0, 1, 2, . . . , P[X = i] = λi i! e−λ We can use the definition to find E[X]!

16 / 26

X

  • poi CX )

ECXI

  • Eto if

¥1

e-

a)

touswrwiesfor

te

. = =

Het

  • DD
slide-17
SLIDE 17

Expectation of a Poisson II

Optional but intuitive / non-rigorous approach: Think of a Poisson(λ) as a Bin(n, λ

n) distribution,

taken as n → ∞. Let X ∼ Bin(n, λ

n).

X =

17 / 26

* I 71¥

slide-18
SLIDE 18

Rest of Today: Functions of RVs!

Recall X from Lecture 19: X = 8 > < > : 1 wp 0.4

1 2

wp 0.25 −1

2

wp 0.35 Refresh your memory: What is X 2?

18 / 26

XI

ft

Wp

.

0.4

  • 4

Wp

0.25

¥

Wp

0.35

= { ¥

WP 0.4 Wp

0.6

slide-19
SLIDE 19

Example: Functions of RVs

X 2 = ( 1 wp 0.4

1 4

wp 0.6 What is E[X 2]? What is E[3X 2 − 5]?

19 / 26

Efx 21

  • I
. PC XIII t 4 PIX '
  • I ]
=

I

. 0.4

t

t

.

0.6=0.55

linearity

  • f

exp

.

IE [3×2]

  • ECS )

3EHF

  • 5

310.55

)

  • 5
slide-20
SLIDE 20

In General: Functions of RVs

Let X be a RV with values in A. Distribution of f (X): E[f (X)] =

20 / 26

f Cx )

= {

f !

!

)

wppxf-ajac.CA

Ha )

pfX=a ]

slide-21
SLIDE 21

Square of a Bernoulli

Let X ∼ Bernoulli(p). Write out the distribution of X. What is X 2? E[X 2]?

21 / 26

X

  • { f

wpp

Wp tp

X

'
  • { to

If Ip

ECM =p

.
slide-22
SLIDE 22

Product of RVs

Let X be a RV with values in A. Let Y be a RV with values in B. XY is also a RV! What is its distribution? (Use the joint distribution!)

22 / 26

Exercise

slide-23
SLIDE 23

Product of Two Bernoullis

Let X ∼ Bernoulli(p1), and Y ∼ Bernoulli(p2). X and Y are independent. What is the distribution of XY ? What is E[XY ]?

23 / 26

Exercise

slide-24
SLIDE 24

Square of a Binomial I

Let X ∼ Bin(n, p). Decompose into Xi ∼ Bernoulli(p). X = E[X] =

24 / 26

X ,

t X z t

. . . t X n

IE [ X ,

t

X at

. . . t X n ] =

Efx

. I t IEC X a It . . .

t Ef X n ]

=

n p

.
slide-25
SLIDE 25

Square of a Binomial II

Recall, E[X 2

i ] = 1, and E[XiXj] = p2.

25 / 26

P

ECXZ ]=Ef(

X

,tXzt

. .

.tt/n)2J=tEfCXi2tXz2t...tXn4t(XiXztXiXst

. . . ))
  • square
terms cross terms n
  • f
them

MIN

  • 1)
  • f
= Ef square

terms ]

TEAMS

terms ] them .

I

:

:* : :*

:

"

"

:i÷i

:*

.

ECXIZ ]

  • P

Efx ,Xz3=PZ

> =

nptnln

  • 1) P2
slide-26
SLIDE 26

Summary

Today:

I Proof of linearity of expectation: did not use

independence, but did use joint distribution

I Tail sum for non-negative int.-valued RVs! I Coupon Collector: break problem down into a

sum of geometrics.

I Expectation of a function of an RV: can

apply definition and linearity of expectation (after expanding) as well!!

26 / 26