randomized algorithms cs648

39
Randomized Algorithms CS648 Lecture 14 Expected duration of a randomized experiment Part II 1

Upload: keziah

Post on 23-Feb-2016

45 views

Category:

Documents


0 download

DESCRIPTION

Randomized Algorithms CS648. Lecture 14 Expected duration of a randomized experiment Part II. Revisiting Some discrete mathematics. Recurrence 1. For any , Question: What is the smallest value of such that for a given ? Answer: ?? For any , for some - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Randomized Algorithms CS648

Randomized AlgorithmsCS648

Lecture 14Expected duration of a randomized experiment

Part II

1

Page 2: Randomized Algorithms CS648

REVISITING SOME DISCRETE MATHEMATICS

2

Page 3: Randomized Algorithms CS648

Recurrence 1

For any , Question: What is the smallest value of such that for a given ?Answer: ??

For any , for some Question: What is the smallest value of such that for a given ?Answer: ??

3

log 2๐’

log 1/๐‘๐’

Page 4: Randomized Algorithms CS648

Recurrence 2

For any , Question: What is the smallest value of such that for a given ?Answer: ??

for some For any , for some Question: What is the smallest value of such that for a given ?Answer: ??

4

log 2lo g2๐’

log๐’„ log1 /๐‘Ž๐’

Page 5: Randomized Algorithms CS648

DISTRIBUTED CLIENT-SERVER PROBLEM

5

Page 6: Randomized Algorithms CS648

Distributed Client-Server Problem

โ€ข There are -clients and -servers.โ€ข Each client knows address of each server.โ€ข Each client has a single job.โ€ข It is a distributed computational environment.โ€ข A server can execute only one job in one round.

Aim: A distributed protocol to finish all jobs as quickly as possible.

6

Page 7: Randomized Algorithms CS648

Distributed Client-Server Problem

Randomized protocol (one round)โ€ข Each client sends a request to a server selected randomly uniformly and

independently.

โ€ข Each server which receives one or more requests, accepts only one request and finishes the corresponding job.

โ€ข Each client, whose job is finished, leaves the system.

โ€ข The remaining clients repeat the same procedure in next round.

Question: what is the expected number of rounds to finish all jobs?

7

Page 8: Randomized Algorithms CS648

Distributed Client-Server problemRandomized protocol

8

1 2 3 4 5 6 7 8Clients

1 2 3 4 5 6 7 8

Servers

It can be framed as our familiar ball-bin problem.

Page 9: Randomized Algorithms CS648

Distributed Client-Server problemRandomized protocol

9

1 2 3 4 5 6 7 8

1 2 3 4 5 6 7 8

Bins

Balls

Page 10: Randomized Algorithms CS648

Distributed Client-Server problemRandomized protocol

10

1 2 3 4 5 6 7 8

1 2 3 4 5 6 7 8

Round 1

Page 11: Randomized Algorithms CS648

Distributed Client-Server problemRandomized protocol

11

3 4 7 8

1 2 3 4 5 6 7 8

Page 12: Randomized Algorithms CS648

Distributed Client-Server problemRandomized protocol

12

3 4 7 8

1 2 3 4 5 6 7 8

Round 2

Page 13: Randomized Algorithms CS648

Distributed Client-Server problemRandomized protocol

13

8

1 2 3 4 5 6 7 8

Round 3

Page 14: Randomized Algorithms CS648

CALCULATING EXPECTED NO. OF ROUNDS FIRST APPROACH

14

Page 15: Randomized Algorithms CS648

Distributed Client-Server problemRandomized protocol

: no. of balls leaving the system at the end of round . E[] = ??

15

1 2 ๐’

1 2 3 โ€ฆ -1

Round 13 ๐’โˆ’๐Ÿ

Not so easy to find

Page 16: Randomized Algorithms CS648

Distributed Client-Server problemRandomized protocol

: no. of balls leaving the system in round . E[] = ?? = = : no. of balls remaining in the system after round . E[] =

16

1 2 ๐’

1 2 3 โ€ฆ -1

3 ๐’โˆ’๐Ÿ

Is there any relation between no. of empty bins and

no. of balls leaving the system in round 1 ?

๐’โˆ’๐ž๐ฑ๐ฉ๐ž๐œ๐ญ๐ž๐๐ง๐จ .๐จ๐Ÿ ๐ž๐ฆ๐ฉ๐ญ๐ฒ ๐›๐ข๐ง๐ฌ

Round 1

Page 17: Randomized Algorithms CS648

Distributed Client-Server problemRandomized protocol

E[] = : no. of balls at the end of round . E[| ] = ??

17

1 2 ๐’Ž

1 2 โ€ฆ -1

Round

โ‰ค๐’Ž๐’†

๐’Ž

Page 18: Randomized Algorithms CS648

Distributed Client-Server problemRandomized protocol

Lemma1 : After round , the expected number of balls left is less than th fraction of the balls after round .

: fraction of balls in the system after round .Lemma 1 implies E[] If everything goes as expected, then

18

Round No. of balls in the system Fraction of balls in the system

0 1

๐’ /๐’† ๐Ÿ/๐’†ยฟ๐’ /๐’†๐Ÿ ยฟ๐Ÿ /๐’†๐Ÿ2

1

This table gives the intuition for the expected no. of rounds but it directly does not help us to calculate the expected no. of rounds ? It also does not directly help to get a high prob. Bound. Convince yourself before proceeding further.

๐Ÿ๐’† ๐’“ ๐’Š

Page 19: Randomized Algorithms CS648

Distributed Client-Server problemRandomized protocol

Lemma: After round , the expected no. of balls is less than th fraction of the balls after round .Definition: round is good if , and bad otherwise.

P(a round is bad) = ?? P(a round is good)

Question: After how many good rounds will there be no ball left ?

Expected no. of rounds = ??

19

โ‰ค๐Ÿ๐’† โ‰ค๐Ÿ‘๐Ÿ’

๐ฅ๐จ๐ ๐Ÿ๐’

โ‰ค๐Ÿ’๐ฅ๐จ๐ ๐Ÿ๐’ Each round is good independent of other rounds.

Use Markovโ€™s Inequality

Use Recurrence 1

Page 20: Randomized Algorithms CS648

Distributed Client-Server problemRandomized protocol

Theorem: The Randomized protocol will terminate in expected O() rounds.

20

This bound is very loose. Can you see why ?

Page 21: Randomized Algorithms CS648

An important insight that we missed

Question: What is the cause of multiple rounds for a ball ?Answer: presence of other competing balls

INSIGHT As the algorithm proceeds:โ€ข The number of these competing balls reduce โ€ข but the number of bins remain unchanged

Chances of a ball to leave the system increases as the algorithm proceeds.

21

Page 22: Randomized Algorithms CS648

CALCULATING EXPECTED NO. OF ROUNDS WITH NEW INSIGHT

22

Page 23: Randomized Algorithms CS648

Distributed Client-Server problemRandomized protocol

Partitioning experiment into stages

Stage 1: The number of balls Stage 2: The number of balls

Expected no. of rounds in Stage 1 : 4.Expected no. of rounds in Stage 2 : ??

23

Stage 1 Stage 2๐ง๐จ .๐จ๐Ÿ ๐›๐š๐ฅ๐ฅ๐ฌโ‰ค๐’๐Ÿ

Page 24: Randomized Algorithms CS648

CALCULATING EXPECTED NO. OF ROUNDS IN STAGE 2

24

Page 25: Randomized Algorithms CS648

Distributed Client-Server problemRandomized protocol

: no. of balls at the end of round . E[| ] = ??

25

1 2 ๐’Ž

1 2 3 โ€ฆ -1

Round

๐’Žโˆ’๐’(๐Ÿโˆ’(๐Ÿโˆ’๐Ÿ๐’ )๐’Ž)

We need a reasonably good upper bound for this expression

โ‰ค๐’Žโˆ’๐’(๐Ÿโˆ’(๐Ÿโˆ’๐’Ž๐’ +(๐’Ž๐Ÿ ) ๐Ÿ๐’๐Ÿ ))ยฟ๐’Žโˆ’๐’((๐’Ž๐’ โˆ’(๐’Ž๐Ÿ ) ๐Ÿ๐’๐Ÿ ))ยฟ (๐’Ž๐Ÿ )๐Ÿ๐’

๐’Žโˆ’๐ง๐จ .๐จ๐Ÿ ๐ง๐จ๐ง๐ž๐ฆ๐ฉ๐ญ๐ฒ ๐›๐ข๐ง๐ฌ

Page 26: Randomized Algorithms CS648

Distributed Client-Server problemRandomized protocol

: no. of balls at the end of round . E[| ] = ??

E = ??: fraction of balls at the end of round . E[] = ??

26

1 2 ๐’Ž

1 2 3 โ€ฆ -1

Round

โ‰ค(๐’Ž๐Ÿ ) ๐Ÿ๐’โ‰ค๐’Ž๐Ÿ

๐Ÿ๐’

โ‰ค๐Ÿ๐Ÿ (๐’Ž๐’ )๐Ÿ

โ‰ค ๐Ÿ๐Ÿ (๐’“ ๐’Š )๐Ÿ

Page 27: Randomized Algorithms CS648

Distributed Client-Server problemRandomized protocol

Lemma: If is the fraction of balls at end of round in stage 2, the expected fraction of balls at the end of round will be at most .

Definition: round is good if , and bad otherwise.

P(a round is bad) = ?? P(a round is good) Question: After how many good rounds will there be no ball left ?

Expected no. of rounds = ??

27

โ‰ค ๐ฅ๐จ๐ ๐Ÿ๐ฅ๐จ๐ ๐Ÿ๐’โ‰ค๐Ÿ๐ฅ๐จ๐ ๐Ÿ ๐ฅ๐จ๐ ๐Ÿ๐’

Use Markovโ€™s Inequality

Use Recurrence 2

Page 28: Randomized Algorithms CS648

Distributed Client-Server problemRandomized protocol

Theorem: The expected number of rounds taken by the Randomized protocol is at most .

28

Page 29: Randomized Algorithms CS648

Distributed Client-Server problemRandomized protocol

Points to Ponder :

โ€ข Why did we analyze the random variable and not ?

โ€ข Why did we introduce the two stages ?

โ€ข Do you find any similarity in the analysis with that of of Quick sort concentration?

โ€ข Can you also achieve lower bound of on the expected number of rounds ? (this question is only for those whose aim is more than just grade A )

โ€ข Can you achieve high probability bound on the number of rounds ?

29

Page 30: Randomized Algorithms CS648

RUMOR SPREADING

30

Page 31: Randomized Algorithms CS648

Rumor Spreading

There are persons in a city.On day , a person comes to know a rumor.

The following protocol is repeated from day :โ€ข Each person knowing the rumor does the following - Picks phone number of a randomly selected person - Calls him/her and communicate the rumor.

Question: What is the expected number of days until everyone knows the rumor?

31

Page 32: Randomized Algorithms CS648

Rumor Spreading

Question: What is the minimum number of days until everyone knows the rumor?Answer:

32

Number of people knowing the rumor can only double

in a day.

Page 33: Randomized Algorithms CS648

Rumor Spreading

Theorem (it should surprise you): 1. The entire city comes to know the rumor in O() expected days. 2. The entire city comes to know the rumor in O() days with high

probability.

33

Page 34: Randomized Algorithms CS648

Rumor Spreading

Intuition 1:In the beginning, there are few persons who know the rumor. As a resultโ€ข The chances of selecting a person who does not know the rumor is more.โ€ข The chances of collisions are also few.As long as the no. of people knowing the rumor is less than , for some suitable , the no. of people knowing the rumor should increase by a factor every day.

Intuition 2:Once there are more than persons knowing the rumor, the probability of a person unaware of rumor to get a phone call about rumor should be high.

Can you use these two intuitions to partition the algorithm into stages ?

34

Page 35: Randomized Algorithms CS648

Rumor Spreading

Partition the experiment into stages

Select some suitably.

Stage 1: the number of people knowing the rumor is less than

Stage 2: the number of people knowing the rumor is more than

35

Stage 1 Stage 2๐ง๐จ .๐จ๐Ÿ ๐ฉ๐ž๐จ๐ฉ๐ฅ๐ž๐ค๐ง๐จ๐ฐ๐ข๐ง๐ ๐ซ๐ฎ๐ฆ๐จ๐ซ >c๐’

Page 36: Randomized Algorithms CS648

EXPECTED NO. OF DAYS IN STAGE 2

36

Page 37: Randomized Algorithms CS648

Rumor Spreading

In the beginning of Stage 2: the no. of people knowing the rumor .

โ€ข Pick any person not knowing the rumor.

โ€ข Show that he/she will know the rumor in days with high probability.

โ€ข Use Union theorem to conclude that the number of days in Stage 2 is with high probability.

37

Page 38: Randomized Algorithms CS648

EXPECTED NO. OF DAYS IN STAGE 1

38

Page 39: Randomized Algorithms CS648

39

It is left as a home work to be discussed in some future class.I shall be happy to see a correct

solution by some of you in the next class.