Lecture 13-cs648
-
Upload
rajiv-omar -
Category
Technology
-
view
73 -
download
0
Transcript of Lecture 13-cs648
![Page 1: Lecture 13-cs648](https://reader036.fdocuments.in/reader036/viewer/2022062308/558c7853d8b42a806c8b4758/html5/thumbnails/1.jpg)
Randomized AlgorithmsCS648
Lecture 13Expected duration of a randomized experiment
Part I
1
![Page 2: Lecture 13-cs648](https://reader036.fdocuments.in/reader036/viewer/2022062308/558c7853d8b42a806c8b4758/html5/thumbnails/2.jpg)
COUPON COLLECTOR PROBLEM
2
![Page 3: Lecture 13-cs648](https://reader036.fdocuments.in/reader036/viewer/2022062308/558c7853d8b42a806c8b4758/html5/thumbnails/3.jpg)
Coupon Collector Problem
• There is a bag containing distinct coupons. • Each coupon has a unique label from [].
Experiment:Repeat 1. Select a coupon randomly uniformly from the bag 2. Note down its label 3. Place the coupon back into the bagUntil every coupon has appeared at least once
: the number of iterations of the loop (number of coupons drawn).
Question: What is E[] ?
3
![Page 4: Lecture 13-cs648](https://reader036.fdocuments.in/reader036/viewer/2022062308/558c7853d8b42a806c8b4758/html5/thumbnails/4.jpg)
Example
=5
4
3 1 3 3 1 2 2 1 5 1 3 5 3 4
5 5 1 2 1 2 5 4 4 1 2 3
3 2 2 3 3 3 1 1 5 1 3 5 3 2 2 5
1 42
53
Done in 14 samplings
Done in 12 samplings
![Page 5: Lecture 13-cs648](https://reader036.fdocuments.in/reader036/viewer/2022062308/558c7853d8b42a806c8b4758/html5/thumbnails/5.jpg)
Coupon Collector Problem
: the number of iterations of the loop (number of coupons drawn).Question: What is E[] ?
Standard method:
E[] =
5
No easy way !!
?
![Page 6: Lecture 13-cs648](https://reader036.fdocuments.in/reader036/viewer/2022062308/558c7853d8b42a806c8b4758/html5/thumbnails/6.jpg)
Coupon Collector Problem
6
no coupon
seen
all coupons
seen
This transition is not sudden. In fact it is a gradual transition through various discrete stages. Can you
see these discrete stages ?
![Page 7: Lecture 13-cs648](https://reader036.fdocuments.in/reader036/viewer/2022062308/558c7853d8b42a806c8b4758/html5/thumbnails/7.jpg)
Coupon Collector Problem
7
no coupon
seen
all coupons
seen1 2 3 4
This transition is not sudden. In fact it is a gradual transition through various discrete stages. Can you
see these discrete stages ?
![Page 8: Lecture 13-cs648](https://reader036.fdocuments.in/reader036/viewer/2022062308/558c7853d8b42a806c8b4758/html5/thumbnails/8.jpg)
Reviewing Example
=5
8
3 1 3 3 1 2 2 1 5 1 3 5 3 4
1 42
53
50
![Page 9: Lecture 13-cs648](https://reader036.fdocuments.in/reader036/viewer/2022062308/558c7853d8b42a806c8b4758/html5/thumbnails/9.jpg)
Reviewing Example
=5
9
3 2 2 3 3 3 1 1 5 1 3 5 3 2 2 5
1 42
53
1 2 3 4 50
5 5 1 2 1 2 5 4 4 1 2 3
1 2 3 4 50
1 32 40
3 1 3 3 1 2 2 1 5 1 3 5 3 4
Each instance of coupon collector problem has to
pass through these stages. Does it give you
some inspiration to calculate E[X] ?
![Page 10: Lecture 13-cs648](https://reader036.fdocuments.in/reader036/viewer/2022062308/558c7853d8b42a806c8b4758/html5/thumbnails/10.jpg)
Coupon Collector Problem
: the number of iterations of the loop (number of coupons drawn).Question: What is E[] ?
no. of coupons sampled from the moment ?? to the moment ??
10
th distinct coupon was selected
th distinct coupon was selected
![Page 11: Lecture 13-cs648](https://reader036.fdocuments.in/reader036/viewer/2022062308/558c7853d8b42a806c8b4758/html5/thumbnails/11.jpg)
Reviewing Example
=5
11
1 42
53
1 2 3 45
0
3 1 3 3 1 2 2 1 5 1 3 5 3 4
=1 =1 =4 =3 =5
This picture validates the equality
![Page 12: Lecture 13-cs648](https://reader036.fdocuments.in/reader036/viewer/2022062308/558c7853d8b42a806c8b4758/html5/thumbnails/12.jpg)
Coupon Collector Problem
: the number of iterations of the loop (number of coupons drawn).
Question: What is ] ?
12
![Page 13: Lecture 13-cs648](https://reader036.fdocuments.in/reader036/viewer/2022062308/558c7853d8b42a806c8b4758/html5/thumbnails/13.jpg)
Calculating E[]
Experiment (in th stage):Repeat 1. Select a coupon randomly uniformly from the bag 2. Note down its label 3. Place the coupon back into the bagUntil th distinct coupon appears.
13
𝑛
![Page 14: Lecture 13-cs648](https://reader036.fdocuments.in/reader036/viewer/2022062308/558c7853d8b42a806c8b4758/html5/thumbnails/14.jpg)
Calculating E[]
Experiment (in th stage):Repeat 1. Select a coupon randomly uniformly from the bag 2. Note down its label 3. Place the coupon back into the bagUntil th distinct coupon appears.
=Probability an iteration is successfulQuestion: What is ?E[] = = = =
14
𝑛
𝑖
(𝑛−𝑖)/𝑛
![Page 15: Lecture 13-cs648](https://reader036.fdocuments.in/reader036/viewer/2022062308/558c7853d8b42a806c8b4758/html5/thumbnails/15.jpg)
Coupon Collector Problem
: the number of iterations of the loop (number of coupons drawn).
Theorem: Expected duration of coupon collector experiment is .
15
![Page 16: Lecture 13-cs648](https://reader036.fdocuments.in/reader036/viewer/2022062308/558c7853d8b42a806c8b4758/html5/thumbnails/16.jpg)
DISCRETE RANDOM WALK ON A LINE
16
![Page 17: Lecture 13-cs648](https://reader036.fdocuments.in/reader036/viewer/2022062308/558c7853d8b42a806c8b4758/html5/thumbnails/17.jpg)
Discrete Random Walk
• Particle starts from origin• In each second, particle moves 1 unit to the left or to the right with equal
probability.• While at origin, the particle moves to 1 always.
Question: What is the expected number of steps of the random walk to reach milestone n ?
17
0 1 2 3 4 5 6 7 8 … n n+1
![Page 18: Lecture 13-cs648](https://reader036.fdocuments.in/reader036/viewer/2022062308/558c7853d8b42a806c8b4758/html5/thumbnails/18.jpg)
An example
18
0 1 2 3 4 5 6 7 8 …
I, and perhaps you too,
could not notice the walk. So let
us trace the walk slowly.
![Page 19: Lecture 13-cs648](https://reader036.fdocuments.in/reader036/viewer/2022062308/558c7853d8b42a806c8b4758/html5/thumbnails/19.jpg)
Formalism
: No. of steps of a random walk which starts at and terminates on reaching for the first time.
Aim: To calculate E[]
19
![Page 20: Lecture 13-cs648](https://reader036.fdocuments.in/reader036/viewer/2022062308/558c7853d8b42a806c8b4758/html5/thumbnails/20.jpg)
Careful look at the example
20
0 1 2 3 4 5 6 7 8 …
Can you break the walk 08 into stages ? Think
carefully …
![Page 21: Lecture 13-cs648](https://reader036.fdocuments.in/reader036/viewer/2022062308/558c7853d8b42a806c8b4758/html5/thumbnails/21.jpg)
Careful look at the example
21
0 1 2 3 4 5 6 7 8 …
Walk starting from 0 and terminating at 5
![Page 22: Lecture 13-cs648](https://reader036.fdocuments.in/reader036/viewer/2022062308/558c7853d8b42a806c8b4758/html5/thumbnails/22.jpg)
Careful look at the example
22
0 1 2 3 4 5 6 7 8 …
Walk starting from 5 and terminating at 8
Walk starting from 0 and terminating at 5
![Page 23: Lecture 13-cs648](https://reader036.fdocuments.in/reader036/viewer/2022062308/558c7853d8b42a806c8b4758/html5/thumbnails/23.jpg)
Relation among ’s
For any = +
Breaking down to the limits, we get =
Hence using linearity of expectation E[] = ]
23
![Page 24: Lecture 13-cs648](https://reader036.fdocuments.in/reader036/viewer/2022062308/558c7853d8b42a806c8b4758/html5/thumbnails/24.jpg)
Relation among ’s
24
0 1 2 3 4 5 6 7 8 …
28
1
1
3
1
5
1
511
![Page 25: Lecture 13-cs648](https://reader036.fdocuments.in/reader036/viewer/2022062308/558c7853d8b42a806c8b4758/html5/thumbnails/25.jpg)
HOW TO CALCULATE E[] ?
25
![Page 26: Lecture 13-cs648](https://reader036.fdocuments.in/reader036/viewer/2022062308/558c7853d8b42a806c8b4758/html5/thumbnails/26.jpg)
Conditional Expectation
Given any event and a random variable defined over a probability space (,P).
E[] = E[| ] P() + E[| ] P()
26
ε Ωε
A useful tool to calculate expected value of a random variable
E[| ]
E[| ]
![Page 27: Lecture 13-cs648](https://reader036.fdocuments.in/reader036/viewer/2022062308/558c7853d8b42a806c8b4758/html5/thumbnails/27.jpg)
Calculating E[]
E[] = ??
= ½ E[| first move is L] + ½ . 1
= ½ E[| first move is L] + ½
27
0 1 … 𝑖 +1
½ E[| first move is L] + ½ E[| first move is R]
?
![Page 28: Lecture 13-cs648](https://reader036.fdocuments.in/reader036/viewer/2022062308/558c7853d8b42a806c8b4758/html5/thumbnails/28.jpg)
Calculating E[| first move is L]
E[| first move is L] = ?? = 1 + E[] + E[] //by linearity of expectation
28
0 1 … 𝑖 +1
1 + E[]
![Page 29: Lecture 13-cs648](https://reader036.fdocuments.in/reader036/viewer/2022062308/558c7853d8b42a806c8b4758/html5/thumbnails/29.jpg)
Calculating E[]
E[] = ½ E[| first move is L] + ½ . 1 = ½ + ½ . 1 = 1 + ½ 2 E[] = 2 + ] E[] = 2 + Question: What is E[] ?Question: What is E[] ?Question: What is E[] ?Answer: ??
29
0 1 … 𝑖 +1
13
2 𝑖+1
![Page 30: Lecture 13-cs648](https://reader036.fdocuments.in/reader036/viewer/2022062308/558c7853d8b42a806c8b4758/html5/thumbnails/30.jpg)
CALCULATING E[]
30
![Page 31: Lecture 13-cs648](https://reader036.fdocuments.in/reader036/viewer/2022062308/558c7853d8b42a806c8b4758/html5/thumbnails/31.jpg)
Calculating E[]
Lemma (just proved): E[] =
E[] = = = = =
31
0 1 2 3 4 5 6 7 … 𝑛 +1
![Page 32: Lecture 13-cs648](https://reader036.fdocuments.in/reader036/viewer/2022062308/558c7853d8b42a806c8b4758/html5/thumbnails/32.jpg)
Theorem: Expected number of steps of a random walk starting from 0 and terminating on reaching is .
32
![Page 33: Lecture 13-cs648](https://reader036.fdocuments.in/reader036/viewer/2022062308/558c7853d8b42a806c8b4758/html5/thumbnails/33.jpg)
Expected duration of a random experiment
Let X denote the random variable for the duration of a randomized experiment.
To calculate E[X], the following approach is sometimes useful:
• Partition the experiment into stages carefully.
• Calculate expected duration of each stage.
• Using linearity of expectation, calculate E[X].
In the next class, we shall discuss more non-trivial randomized algorithms which are analyzed using this method.
33