+ All Categories
Home > Documents > Tutorial 2 Solution for homework 1 - National Tsing Hua ...

Tutorial 2 Solution for homework 1 - National Tsing Hua ...

Date post: 25-Oct-2021
Category:
Upload: others
View: 5 times
Download: 0 times
Share this document with a friend
39
Randomized algorithm Tutorial 2 Solution for homework 1
Transcript
Page 1: Tutorial 2 Solution for homework 1 - National Tsing Hua ...

Randomized algorithm

Tutorial 2Solution for homework 1

Page 2: Tutorial 2 Solution for homework 1 - National Tsing Hua ...

Outline

Solutions for homework 1Negative binomial random variablePaintball gameRope puzzle

Page 3: Tutorial 2 Solution for homework 1 - National Tsing Hua ...

Solutions for homework 1

Page 4: Tutorial 2 Solution for homework 1 - National Tsing Hua ...

Homework 1-1

:a

:b

:c

:dBox 1 Box 2

step 1

babB

baaW

+=

+=

)Pr(

)Pr(

Page 5: Tutorial 2 Solution for homework 1 - National Tsing Hua ...

Homework 1-1

Draw a white ball from Box 2 : event APr(A) = Pr(A∩ (W∪B))= Pr((A∩ W)∪(A∩ B))= Pr(A∩ W) + Pr(B∩ W) = Pr(A|W)Pr(W) + Pr(A|B)Pr(B)

Page 6: Tutorial 2 Solution for homework 1 - National Tsing Hua ...

Homework 1-1

It is easy to see that

1)db)(c(aabcac

B)Pr(B)|Pr(A W)Pr(W)|Pr(A Pr(A)

1dccB)|Pr(A

11W)|Pr(A

+++++

=

+=

++=

+++

=dc

c

Page 7: Tutorial 2 Solution for homework 1 - National Tsing Hua ...

Homework 1-2

Wi = pick a white ball at the i-th time

31

11

PrPrPr

112

21

=

−+−

=

=∩

baa

baa

)(W)|W(W)W(W

Page 8: Tutorial 2 Solution for homework 1 - National Tsing Hua ...

Homework 1-2

22

22

31

1-ba1-a

1-ba

1-a1-ba

1-a

1-ba1-a

⎟⎠⎞

⎜⎝⎛

+<<⎟

⎠⎞

⎜⎝⎛

+⇒

⎟⎠⎞

⎜⎝⎛

+<

+<⎟

⎠⎞

⎜⎝⎛

+⇒

+<

+

baa

baa

baa

baa

Page 9: Tutorial 2 Solution for homework 1 - National Tsing Hua ...

Homework 1-2

2)13(1

1313

31)13(

1)1(3

)1()1(3 22

ba

ba

ba

baa

baa

++<⇒

−−+

<⇒

+−<−⇒

−+<−⇒

−+<−

Page 10: Tutorial 2 Solution for homework 1 - National Tsing Hua ...

Homework 1-2

ab

abab

aba

aba

<+

<−

−<⇒

<+⇒

<+

2)13(

13

)13(

3

3)( 22

2)13(1

2)13( bab +

+<<+

Page 11: Tutorial 2 Solution for homework 1 - National Tsing Hua ...

Homework 1-2

1 b maps 1 a onlyFor b=1, 1.36<a<2.36 means a=2

Pr(W1∩W2) = 2/3 * 1/2= 1/3

Then we may tryb=2 →a=3 →oddb=4 →a=6 →even

Page 12: Tutorial 2 Solution for homework 1 - National Tsing Hua ...

Homework 1-3

By the hintX = sum is even.Y = the number of first die is evenZ = the number of second die is oddPr(X∩Y) = ¼ = ½ * ½Pr(X∩Z) = ¼ = ½ * ½Pr(Y∩Z) = ¼ = ½ * ½Pr(X∩Y∩Z) =0

Page 13: Tutorial 2 Solution for homework 1 - National Tsing Hua ...

Homework 1-4

Let C1, C2, …, Ck be all possible min-cut sets.

2)1(

1)1(

2

1) returns algorithmPr(

)1(2) returns algorithmPr(

1

−≤⇒

≤−

≤⇒

−=

∑=

nnk

nnk

C

nnC

k

ii

i

Page 14: Tutorial 2 Solution for homework 1 - National Tsing Hua ...

Homework 1-5

i-th pair

Page 15: Tutorial 2 Solution for homework 1 - National Tsing Hua ...

Homework 1-5

Indicator variablePr(Xi) = 1 if the i-th pair are couple.Pr(Xi) = 0 Otherwise

Linearity of expectationX= Σi=1 to 20Xi

E[X] = Σi=1 to 20E[Xi] = Σi=1 to 201/20 = 1

Page 16: Tutorial 2 Solution for homework 1 - National Tsing Hua ...

Homework 1-6

pqqppq

pqqppq

qqpp

kYkYkXYX

k

kk

kkk

−+=

+−−=

−−=

====

=

−−

1

11

)1(

)1()1(

)Pr()|Pr()Pr(

Page 17: Tutorial 2 Solution for homework 1 - National Tsing Hua ...

Homework 1-6

)1)(1(1111

)],[min(E][E][E)],[max(E)1)(1(1

1)],[min(E

1][E

1][E

qpqp

YXYXYXqp

YX

qY

pX

−−−−+=

−+=−−−

=

=

=

Page 18: Tutorial 2 Solution for homework 1 - National Tsing Hua ...

Homework 1-7

To choose the i-th candidate, we needi>mi-th candidate is the best [Event B]The best of the first i-1 candidates should be in 1 to m. [Event Y]

Page 19: Tutorial 2 Solution for homework 1 - National Tsing Hua ...

Homework 1-7

Therefore, the probability that i is the best candidate is

The probability of selecting the best one is

11)|Pr()Pr()Pr(

−×==

im

nBYBE iiii

∑∑+=+= −

==n

mi

n

mii in

mEE11 1

1)Pr()Pr(

Page 20: Tutorial 2 Solution for homework 1 - National Tsing Hua ...

Homework 1-7

Consider the curve f(x)=1/x. The area under the curve from x = j-1 to x = j is less than 1/(j-1), but the area from x = j-2 to x = j-1 is larger than 1/(j-1).

Page 21: Tutorial 2 Solution for homework 1 - National Tsing Hua ...

Homework 1-7

mndxxfj ee

n

m

n

mjloglog)(

11

1−=≥

− ∫∑+=

)1(log)1(log)(1

1 1

11

−−−=≤− ∫∑

−+=

mndxxfj ee

n

m

n

mj

Page 22: Tutorial 2 Solution for homework 1 - National Tsing Hua ...

Homework 1-7

mnmg

nnmnmg

mnnmmg

ee

ee

1)(''

1loglog)('

)log(log)(

−=

−−

=

−=

→g’(m)=0 when m=n/e

→g’’(m)<0 , g(m) is max when m=n/e

Page 23: Tutorial 2 Solution for homework 1 - National Tsing Hua ...

Homework 1-7

e

neen

neennn

nmnm

E

e

ee

ee

1

)(log

))/(loglog(

)loglog()Pr(

=

=

−=

−≥

Page 24: Tutorial 2 Solution for homework 1 - National Tsing Hua ...

Homework 1-8 (bonus)

S={±1, ±2, ±3, ±4, ±5, ±6}X={1,-2,3,-4,5,-6}Y={-1,2,-3,4,-5,6}E[X]=-0.5E[Y]=0.5E[Z] = -3.5

Page 25: Tutorial 2 Solution for homework 1 - National Tsing Hua ...

Negative binomial random variable

Page 26: Tutorial 2 Solution for homework 1 - National Tsing Hua ...

Negative binomial random variable

Definitiony is said to be negative binomial random variable with parameter r and p if

For example, we want r heads when flipping a coin.

rkr pprk

ky −−⎟⎟⎠

⎞⎜⎜⎝

⎛−−

== )1(11

)Pr(

Page 27: Tutorial 2 Solution for homework 1 - National Tsing Hua ...

Negative binomial random variable

Let z=y-r

kr

kr

ppkkr

ppr

krrky

kz

)1(1

)1(1

1)Pr(

)Pr(

−⎟⎟⎠

⎞⎜⎜⎝

⎛ −+=

−⎟⎟⎠

⎞⎜⎜⎝

⎛−−+

=

+===

Page 28: Tutorial 2 Solution for homework 1 - National Tsing Hua ...

Negative binomial random variable

Let r=1

Isn’t it familiar?

k

kr

pp

ppkkrkz

)1(

)1(1

)Pr(

−=

−⎟⎟⎠

⎞⎜⎜⎝

⎛ −+=

=

Page 29: Tutorial 2 Solution for homework 1 - National Tsing Hua ...

Negative binomial random variable

Suppose the rule of meichu game has been changed. The one who win three games first would be the champion. Let p be the probability for NTHU to win each game, 0<p<1.

Page 30: Tutorial 2 Solution for homework 1 - National Tsing Hua ...

Negative binomial random variable

Let the event

We know

∑==

==5

3

5

3

)()Pr() winsNTHUPr(k

kk

k APAU

5,4,3 }gameth - on the winsNTHU{ == kkAk

Page 31: Tutorial 2 Solution for homework 1 - National Tsing Hua ...

Negative binomial random variable

where

Hence33

5

3)1(

21

) winsNTHUPr( −

=

−⎟⎟⎠

⎞⎜⎜⎝

⎛ −=∑ k

k

ppk

33 )1(2

1)gameth on success rd3()Pr( −−⎟⎟

⎞⎜⎜⎝

⎛ −== k

k ppk

kPA

Page 32: Tutorial 2 Solution for homework 1 - National Tsing Hua ...

Negative binomial random variable

Given that NTHU has already won the first game. What is the probability of NTHU being the champion?

1611

163

82

41

21

21

11 224

2=⎟

⎠⎞

⎜⎝⎛ ++=⎟

⎠⎞

⎜⎝⎛

⎟⎠⎞

⎜⎝⎛⎟⎟⎠

⎞⎜⎜⎝

⎛ − −

=∑

k

k

k

Page 33: Tutorial 2 Solution for homework 1 - National Tsing Hua ...

Paintball game

Page 34: Tutorial 2 Solution for homework 1 - National Tsing Hua ...

Paintball game

You James Bond, and Robin Hood decide to play a paintball game. The rules are as follows

Everyone attack another in an order.Anyone who get “hit” should quit.The survival is the winner.You can choose shoot into air.

Page 35: Tutorial 2 Solution for homework 1 - National Tsing Hua ...

Paintball game

James Bond is good at using gun, he can hit with probability 100%.Robin Hood is a bowman, he can hit with probability 60%.You are an ordinary person, can only hit with probability 30%. The order of shot is you, Robin Hood then James Bonds.

Page 36: Tutorial 2 Solution for homework 1 - National Tsing Hua ...

Paintball game

What is your best strategy of first shoot?Please calculate each player’s probability of winning.

Page 37: Tutorial 2 Solution for homework 1 - National Tsing Hua ...

Rope puzzle

Page 38: Tutorial 2 Solution for homework 1 - National Tsing Hua ...

Rope puzzle

We have three ropes with equal length (Obviously, there are 6 endpoint).Now we randomly choose 2 endpoints and tied them together. Repeat it until every endpoint are tied.

Page 39: Tutorial 2 Solution for homework 1 - National Tsing Hua ...

Rope puzzle

There can be three cases1.

2.

3.

Which case has higher probability?


Recommended