Randomized Algorithms CS648 Lecture 13 Expected duration of a randomized experiment Part I 1 COUPON COLLECTOR PROBLEM 2 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 bag Until every coupon has appeared at least once πΏ: the number of iterations of the loop (number of coupons drawn). Question: What is E[πΏ] ? 3 Example π=5 1 4 5 3 2 3 1 3 3 1 2 2 1 5 1 3 5 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 4 Done in 14 samplings Done in 12 samplings 3 2 2 5 4 Coupon Collector Problem πΏ: the number of iterations of the loop (number of coupons drawn). Question: What is E[πΏ] ? Standard method: E[πΏ] = πβ₯π π β π(πΏ = π) ? No easy way !! 5 Coupon Collector Problem 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 ? 6 Coupon Collector Problem no coupon seen 1 2 3 4 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 ? 7 Reviewing Example π=5 1 4 5 3 2 0 5 3 1 3 3 1 2 2 1 5 1 3 5 3 4 8 Reviewing Example Each instance of coupon collector problem has to pass through these stages. Does it give you some inspiration to calculate E[X] ? π=5 1 4 5 3 2 1 0 3 2 1 3 3 2 1 0 5 0 5 1 3 3 1 1 2 4 2 3 2 5 3 3 5 1 2 5 4 3 3 1 3 4 3 2 5 4 3 2 1 4 2 2 1 5 1 2 3 1 3 5 4 1 5 2 5 9 Coupon Collector Problem πΏ: the number of iterations of the loop (number of coupons drawn). Question: What is E[πΏ] ? πΏ= πΏπ πβ€π<π th distinct coupon was selected πΏπ = no. of coupons sampled from the moment π?? to the moment π ?? + π th distinct coupon was selected 10 Reviewing Example π=5 1 4 5 3 2 πΏπ =1 0 πΏπ =1 1 3 πΏπ =4 πΏπ =3 2 1 πΏπ =5 3 3 3 1 2 5 4 2 1 5 1 3 5 3 4 This picture validates the equality πΏ = πβ€π<π πΏπ 11 Coupon Collector Problem πΏ: the number of iterations of the loop (number of coupons drawn). πΏ= πΏπ πβ€π<π ο¨ π[π] = π[π π ] πβ€π<π Question: What is π[π π ] ? 12 Calculating E[ππ ] π Experiment (in (π + 1)th stage): Repeat 1. Select a coupon randomly uniformly from the bag 2. Note down its label 3. Place the coupon back into the bag Until (π + 1)th distinct coupon appears. 13 Calculating E[ππ ] π π Experiment (in (π + 1)th stage): Repeat 1. Select a coupon randomly uniformly from the bag 2. Note down its label 3. Place the coupon back into the bag Until (π + 1)th distinct coupon appears. π =Probability an iteration is successful (π β π)/π Question: What is π ? E[ππ ] = π>0 ππ(ππ = π) = π>0 π 1 β π πβ1 π = 1/π = π/(π β π) 14 Coupon Collector Problem πΏ: the number of iterations of the loop (number of coupons drawn). πΏ = πβ€π<π πΏπ ο¨ π[π] = πβ€π<π π[π π ] = = π πβ€π<π πβπ 1 π πβ€π<π πβπ = ππ»π = πΆ(π log π) Theorem: Expected duration of coupon collector experiment is πΆ(π log π) . 15 DISCRETE RANDOM WALK ON A LINE 16 Discrete Random Walk 0 1 2 3 4 5 6 7 8 β¦ n n+1 β’ 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 An example 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. 18 Formalism ππβπ : No. of steps of a random walk which starts at π and terminates on reaching π for the first time. Aim: To calculate E[π0βπ ] 19 Careful look at the example 0 1 2 3 4 5 6 7 8 β¦ Can you break the walk 0ο 8 into stages ? Think carefully β¦ 20 Careful look at the example 0 1 2 3 4 5 6 7 8 β¦ Walk starting from 0 and terminating at 5 21 Careful look at the example 0 1 2 3 4 5 6 7 8 β¦ Walk starting from 0 and terminating at 5 Walk starting from 5 and terminating at 8 22 Relation among πΏπβπ βs For any π < π < π ππβπ = ππβπ + ππβπ Breaking π0βπ down to the limits, we get π0βπ = 0β€π<π ππβπ+1 Hence using linearity of expectation E[π0βπ ] = 0β€π<π E[ππβπ+1 ] 23 Relation among πΏπβπ βs 0 1 2 3 4 5 6 7 8 β¦ π0β1 1 π1β2 1 π2β3 3 π3β4 1 π4β5 5 π5β6 1 π6β7 π7β8 5 11 π0β8 28 24 HOW TO CALCULATE E[πΏπβπ+π ] ? 25 Conditional Expectation Given any event Ξ΅ and a random variable π defined over a probability space (π,P). E[π| Ξ΅] E[π| Ξ΅] Ξ΅ Ξ΅ Ξ© E[π] = E[π| Ξ΅] β P(Ξ΅) + E[π| Ξ΅] βP(Ξ΅) A useful tool to calculate expected value of a random variable 26 Calculating E[ππβπ+1 ] 0 1 π β¦ π+1 E[ππβπ+1 ] = ?? ½ βE[ππβπ+1 | first move is L] + ½ βE[ππβπ+1 | first move is R] = ½ βE[ππβπ+1 | first move is L] + ½ . 1 = ½ βE[ππβπ+1 | first move is L] + ½ ? 27 Calculating E[ππβπ+1 | first move is L] 0 1 β¦ π π+1 E[ππβπ+1 | first move is L] = ?? 1 + E[ππβ1βπ+1 ] = 1 + E[ππβ1βπ ] + E[ππβπ+1 ] //by linearity of expectation 28 Calculating E[ππβπ+1 ] 0 1 β¦ π π+1 E[ππβπ+1 ] = ½ βE[ππβπ+1 | first move is L] + ½ . 1 = ½ β 1 + E[ππβ1βπ ] + E[ππβπ+1 ] + ½ . 1 = 1 + ½ β E[ππβ1βπ ] + E[ππβπ+1 ] ο¨ 2 E[ππβπ+1 ] = 2 + E[ππβ1βπ ] + E[ππβπ+1 ] ο¨ E[ππβπ+1 ] = 2 + E[ππβ1βπ ] Question: What is E[π0β1 ] ? 1 Question: What is E[π1β2 ] ? 3 Question: What is E[ππβπ+1 ] ? Answer: ?? 2π + 1 29 CALCULATING E[πΏπβπ ] 30 Calculating E[π0βπ ] 0 1 2 3 4 5 6 7 β¦ π π+1 Lemma (just proved): E[ππβπ+1 ] = 2π + 1 E[π0βπ ] = 0β€π<π E[ππβπ+1 ] = 0β€π<π(2π + 1) = 2 0β€π<π π + 0β€π<π 1 =π πβ1 + π = π2 31 Theorem: Expected number of steps of a random walk starting from 0 and terminating on reaching π is π2 . 32 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
© Copyright 2026 Paperzz