randomized algorithms randomized algorithms cs648 lecture 14 expected duration of a randomized...

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

Upload: jesse-greene

Post on 15-Jan-2016

240 views

Category:

Documents


0 download

TRANSCRIPT

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

Randomized AlgorithmsCS648

Lecture 14Expected duration of a randomized experiment

Part II

1

Page 2: Randomized Algorithms Randomized Algorithms CS648 Lecture 14 Expected duration of a randomized experiment Part II Lecture 14 Expected duration of a randomized

REVISITING SOME DISCRETE MATHEMATICS

2

Page 3: Randomized Algorithms Randomized Algorithms CS648 Lecture 14 Expected duration of a randomized experiment Part II Lecture 14 Expected duration of a randomized

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 Randomized Algorithms CS648 Lecture 14 Expected duration of a randomized experiment Part II Lecture 14 Expected duration of a randomized

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 Randomized Algorithms CS648 Lecture 14 Expected duration of a randomized experiment Part II Lecture 14 Expected duration of a randomized

DISTRIBUTED CLIENT-SERVER PROBLEM

5

Page 6: Randomized Algorithms Randomized Algorithms CS648 Lecture 14 Expected duration of a randomized experiment Part II Lecture 14 Expected duration of a randomized

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 Randomized Algorithms CS648 Lecture 14 Expected duration of a randomized experiment Part II Lecture 14 Expected duration of a randomized

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 Randomized Algorithms CS648 Lecture 14 Expected duration of a randomized experiment Part II Lecture 14 Expected duration of a randomized

Distributed Client-Server problemRandomized protocol

8

1 2 3 4 5 6 7 8

Clients

1 2 3 4 5 6 7 8

Servers

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

Page 9: Randomized Algorithms Randomized Algorithms CS648 Lecture 14 Expected duration of a randomized experiment Part II Lecture 14 Expected duration of a randomized

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 Randomized Algorithms CS648 Lecture 14 Expected duration of a randomized experiment Part II Lecture 14 Expected duration of a randomized

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 Randomized Algorithms CS648 Lecture 14 Expected duration of a randomized experiment Part II Lecture 14 Expected duration of a randomized

Distributed Client-Server problemRandomized protocol

11

3 4 7 8

1 2 3 4 5 6 7 8

Page 12: Randomized Algorithms Randomized Algorithms CS648 Lecture 14 Expected duration of a randomized experiment Part II Lecture 14 Expected duration of a randomized

Distributed Client-Server problemRandomized protocol

12

3 4 7 8

1 2 3 4 5 6 7 8

Round 2

Page 13: Randomized Algorithms Randomized Algorithms CS648 Lecture 14 Expected duration of a randomized experiment Part II Lecture 14 Expected duration of a randomized

Distributed Client-Server problemRandomized protocol

13

8

1 2 3 4 5 6 7 8

Round 3

Page 14: Randomized Algorithms Randomized Algorithms CS648 Lecture 14 Expected duration of a randomized experiment Part II Lecture 14 Expected duration of a randomized

CALCULATING EXPECTED NO. OF ROUNDS FIRST APPROACH

14

Page 15: Randomized Algorithms Randomized Algorithms CS648 Lecture 14 Expected duration of a randomized experiment Part II Lecture 14 Expected duration of a randomized

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 Randomized Algorithms CS648 Lecture 14 Expected duration of a randomized experiment Part II Lecture 14 Expected duration of a randomized

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 Randomized Algorithms CS648 Lecture 14 Expected duration of a randomized experiment Part II Lecture 14 Expected duration of a randomized

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 Randomized Algorithms CS648 Lecture 14 Expected duration of a randomized experiment Part II Lecture 14 Expected duration of a randomized

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 Randomized Algorithms CS648 Lecture 14 Expected duration of a randomized experiment Part II Lecture 14 Expected duration of a randomized

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 Randomized Algorithms CS648 Lecture 14 Expected duration of a randomized experiment Part II Lecture 14 Expected duration of a randomized

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 Randomized Algorithms CS648 Lecture 14 Expected duration of a randomized experiment Part II Lecture 14 Expected duration of a randomized

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 Randomized Algorithms CS648 Lecture 14 Expected duration of a randomized experiment Part II Lecture 14 Expected duration of a randomized

CALCULATING EXPECTED NO. OF ROUNDS WITH NEW INSIGHT

22

Page 23: Randomized Algorithms Randomized Algorithms CS648 Lecture 14 Expected duration of a randomized experiment Part II Lecture 14 Expected duration of a randomized

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 Randomized Algorithms CS648 Lecture 14 Expected duration of a randomized experiment Part II Lecture 14 Expected duration of a randomized

CALCULATING EXPECTED NO. OF ROUNDS IN STAGE 2

24

Page 25: Randomized Algorithms Randomized Algorithms CS648 Lecture 14 Expected duration of a randomized experiment Part II Lecture 14 Expected duration of a randomized

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 Randomized Algorithms CS648 Lecture 14 Expected duration of a randomized experiment Part II Lecture 14 Expected duration of a randomized

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 Randomized Algorithms CS648 Lecture 14 Expected duration of a randomized experiment Part II Lecture 14 Expected duration of a randomized

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 Randomized Algorithms CS648 Lecture 14 Expected duration of a randomized experiment Part II Lecture 14 Expected duration of a randomized

Distributed Client-Server problemRandomized protocol

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

28

Page 29: Randomized Algorithms Randomized Algorithms CS648 Lecture 14 Expected duration of a randomized experiment Part II Lecture 14 Expected duration of a randomized

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 Randomized Algorithms CS648 Lecture 14 Expected duration of a randomized experiment Part II Lecture 14 Expected duration of a randomized

RUMOR SPREADING

30

Page 31: Randomized Algorithms Randomized Algorithms CS648 Lecture 14 Expected duration of a randomized experiment Part II Lecture 14 Expected duration of a randomized

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 Randomized Algorithms CS648 Lecture 14 Expected duration of a randomized experiment Part II Lecture 14 Expected duration of a randomized

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 Randomized Algorithms CS648 Lecture 14 Expected duration of a randomized experiment Part II Lecture 14 Expected duration of a randomized

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 Randomized Algorithms CS648 Lecture 14 Expected duration of a randomized experiment Part II Lecture 14 Expected duration of a randomized

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 Randomized Algorithms CS648 Lecture 14 Expected duration of a randomized experiment Part II Lecture 14 Expected duration of a randomized

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 Randomized Algorithms CS648 Lecture 14 Expected duration of a randomized experiment Part II Lecture 14 Expected duration of a randomized

EXPECTED NO. OF DAYS IN STAGE 2

36

Page 37: Randomized Algorithms Randomized Algorithms CS648 Lecture 14 Expected duration of a randomized experiment Part II Lecture 14 Expected duration of a randomized

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 Randomized Algorithms CS648 Lecture 14 Expected duration of a randomized experiment Part II Lecture 14 Expected duration of a randomized

EXPECTED NO. OF DAYS IN STAGE 1

38

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

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.