Mathematics for Computer Science

(avery) #1

18.5. Linearity of Expectation 767


Let’s partition the sequence into 5 segments:


blue
„ƒ‚...
X 0

green
„ƒ‚...
X 1

green red
„ ƒ‚ ...
X 2

blue orange
„ ƒ‚ ...
X 3

blue orange gray
„ ƒ‚ ...
X 4

:


The rule is that a segment ends whenever we get a new kind of car. For example, the
middle segment ends when we get a red car for the first time. In this way, we can
break the problem of collecting every type of car into stages. Then we can analyze
each stage individually and assemble the results using linearity of expectation.
In the general case there arencolors of Racin’ Rockets that we’re collecting.
LetXkbe the length of thekth segment. The total number of kid’s meals we must
purchase to get allnRacin’ Rockets is the sum of the lengths of all these segments:


T DX 0 CX 1 CCXn 1 :

Now let’s focus our attention onXk, the length of thekth segment. At the
beginning of segmentk, we havekdifferent types of car, and the segment ends
when we acquire a new type. When we ownktypes, each kid’s meal contains a
type that we already have with probabilityk=n. Therefore, each meal contains a
new type of car with probability 1 k=nD.nk/=n. Thus, the expected number
of meals until we get a new kind of car isn=.nk/by the Mean Time to Failure
rule. This means that
ExŒXkçD


n
nk

:


Linearity of expectation, together with this observation, solves the coupon col-

lector problem:


ExŒTçDExŒX 0 CX 1 CCXn 1 ç
DExŒX 0 çCExŒX 1 çCCExŒXn 1 ç

D

n
n 0

C


n
n 1

CC


n
3

C


n
2

C


n
1

Dn




1


n

C


1


n 1

CC


1


3


C


1


2


C


1


1





Dn




1


1


C


1


2


C


1


3


CC


1


n 1

C


1


n




DnHn (18.14)
nlnn:

Cool! It’s those Harmonic Numbers again.
Free download pdf