Advanced Algorithms (III) Shanghai Jiao Tong University Chihao - - PowerPoint PPT Presentation

advanced algorithms iii
SMART_READER_LITE
LIVE PREVIEW

Advanced Algorithms (III) Shanghai Jiao Tong University Chihao - - PowerPoint PPT Presentation

Advanced Algorithms (III) Shanghai Jiao Tong University Chihao Zhang March 16th, 2020 Balls-into-Bins Balls-into-Bins Throw balls into bins uniformly at random m n Balls-into-Bins Throw balls into bins uniformly at random m n


slide-1
SLIDE 1

Advanced Algorithms (III)

Shanghai Jiao Tong University

Chihao Zhang

March 16th, 2020

slide-2
SLIDE 2

Balls-into-Bins

slide-3
SLIDE 3

Balls-into-Bins

Throw balls into bins uniformly at random

m n

slide-4
SLIDE 4

Balls-into-Bins

Throw balls into bins uniformly at random

m n

  • What is the chance that some bin contains more

than one balls? (Birthday paradox)

slide-5
SLIDE 5

Balls-into-Bins

Throw balls into bins uniformly at random

m n

  • What is the chance that some bin contains more

than one balls? (Birthday paradox)

  • How many balls in the fullest bin? (Max load)
slide-6
SLIDE 6

Balls-into-Bins

Throw balls into bins uniformly at random

m n

  • What is the chance that some bin contains more

than one balls? (Birthday paradox)

  • How large is

to hit all bins (Coupon Collector)

m

  • How many balls in the fullest bin? (Max load)
slide-7
SLIDE 7

Birthday Paradox

slide-8
SLIDE 8

Birthday Paradox

In a group of more than 30 people, which very high chances that two of them have the same birthday

slide-9
SLIDE 9

Birthday Paradox

In a group of more than 30 people, which very high chances that two of them have the same birthday Pr[no same birthday] ≤ 1 ⋅ ( n − 1 n ) ⋅ ( n − 2 n )…( n − m + 1 n ) =

m−1

i=1 (1 − i

n ) ≤ exp − ∑m−1

i=1 i

n = exp (− m(m − 1) 2n )

slide-10
SLIDE 10
slide-11
SLIDE 11

Pr[no same birthday] ≤ exp (− m(m − 1) 2n )

slide-12
SLIDE 12

Pr[no same birthday] ≤ exp (− m(m − 1) 2n )

For , , the probability is less than 0.304

m = 30 n = 365

slide-13
SLIDE 13

Pr[no same birthday] ≤ exp (− m(m − 1) 2n )

For , , the probability is less than 0.304

m = 30 n = 365

For , the probability can be arbitrarily close to 0.

m = O ( n)

slide-14
SLIDE 14

Max Load

slide-15
SLIDE 15

Max Load

Let be the number of balls in the -th bin

Xi i

slide-16
SLIDE 16

Max Load

Let be the number of balls in the -th bin

Xi i

What is We analyze this when

X = max

i∈[n] Xi?

m = n

slide-17
SLIDE 17

Max Load

Let be the number of balls in the -th bin

Xi i

What is We analyze this when

X = max

i∈[n] Xi?

m = n

If we can argue that, is less than with probability , then by union bound,

X1 k 1 − O ( 1 n ) Pr[X ≥ k] = O(1)

slide-18
SLIDE 18
slide-19
SLIDE 19

Again by union bound, Pr[X1 ≥ k] ≤ (

n k) n−k ≤ 1 k!

slide-20
SLIDE 20

Again by union bound, Pr[X1 ≥ k] ≤ (

n k) n−k ≤ 1 k!

We apply the Stirling’s formula k! ≈

2πk ( k e )

k

slide-21
SLIDE 21

Again by union bound, Pr[X1 ≥ k] ≤ (

n k) n−k ≤ 1 k!

We apply the Stirling’s formula k! ≈

2πk ( k e )

k

So Pr[X ≥ k] ≤ 1

k! ≤ ( e k)

k

slide-22
SLIDE 22

Again by union bound, Pr[X1 ≥ k] ≤ (

n k) n−k ≤ 1 k!

We apply the Stirling’s formula k! ≈

2πk ( k e )

k

So Pr[X ≥ k] ≤ 1

k! ≤ ( e k)

k

We want . Choose

( e k )

k

= O ( 1 n ) k = O ( log n log log n)

slide-23
SLIDE 23

Concentration Bounds

slide-24
SLIDE 24

Concentration Bounds

We shall develop general tools to obtain “with high probability” results…

slide-25
SLIDE 25

Concentration Bounds

We shall develop general tools to obtain “with high probability” results… These results are critical for analyzing randomized algorithms

slide-26
SLIDE 26

Concentration Bounds

We shall develop general tools to obtain “with high probability” results… This is the main topic in the coming 4-5 weeks These results are critical for analyzing randomized algorithms

slide-27
SLIDE 27

Markov Inequality

slide-28
SLIDE 28

Markov Inequality

Markov Inequality For any nonnegative random variable and ,

X a > 0 Pr[X > a] ≤ E[X] a

slide-29
SLIDE 29

Markov Inequality

Markov Inequality For any nonnegative random variable and ,

X a > 0 Pr[X > a] ≤ E[X] a

E[X] = E[X ∣ X > a] ⋅ Pr[X > a] + E[X|X ≤ a] ⋅ Pr[X ≤ a] ≥ a ⋅ Pr[X > a] Proof.

slide-30
SLIDE 30

Applications

slide-31
SLIDE 31

Applications

  • A Las-Vegas randomized algorithm with expected

running time terminates in time with probability

O(n) O(n2) 1 − O ( 1 n )

slide-32
SLIDE 32

Applications

  • A Las-Vegas randomized algorithm with expected

running time terminates in time with probability

O(n) O(n2) 1 − O ( 1 n )

  • In -balls-into- -bins problem,

. So

n n E[Xi] = 1

Pr [X1 > log n log log n ] ≤ log log n log n

slide-33
SLIDE 33

Applications

  • A Las-Vegas randomized algorithm with expected

running time terminates in time with probability

O(n) O(n2) 1 − O ( 1 n )

  • In -balls-into- -bins problem,

. So

n n E[Xi] = 1

Pr [X1 > log n log log n ] ≤ log log n log n This is far from the truth…

slide-34
SLIDE 34

Chebyshev’s Inequality

slide-35
SLIDE 35

Chebyshev’s Inequality

A common trick to improve concentration is to consider instead of for some non- decreasing

E[f(X)] E[X] f : ℝ → ℝ

slide-36
SLIDE 36

Chebyshev’s Inequality

A common trick to improve concentration is to consider instead of for some non- decreasing

E[f(X)] E[X] f : ℝ → ℝ

Pr [X ≥ a] = Pr [f(X) ≥ f(a)] ≤ E [f(X)] f(a)

slide-37
SLIDE 37

Chebyshev’s Inequality

A common trick to improve concentration is to consider instead of for some non- decreasing

E[f(X)] E[X] f : ℝ → ℝ

Pr [X ≥ a] = Pr [f(X) ≥ f(a)] ≤ E [f(X)] f(a) gives the Chebyshev’s inequality

f(x) = x2

slide-38
SLIDE 38

Chebyshev’s Inequality

A common trick to improve concentration is to consider instead of for some non- decreasing

E[f(X)] E[X] f : ℝ → ℝ

Pr [X ≥ a] = Pr [f(X) ≥ f(a)] ≤ E [f(X)] f(a) gives the Chebyshev’s inequality

f(x) = x2

Pr[X ≥ a] ≤ E[X2] a2

  • r Pr [|X − E[X]| ≥ a] ≤ Var[X]

a2

slide-39
SLIDE 39

Coupon Collector

slide-40
SLIDE 40

Coupon Collector

Recall the coupon collector problem is to ask

slide-41
SLIDE 41

Coupon Collector

Recall the coupon collector problem is to ask “How many ball one needs to throw so that none

  • f the bins is empty?”

n

slide-42
SLIDE 42

Coupon Collector

Recall the coupon collector problem is to ask “How many ball one needs to throw so that none

  • f the bins is empty?”

n

We already established that E[X] = nHn ≈ n(log n + γ)

slide-43
SLIDE 43

Coupon Collector

Recall the coupon collector problem is to ask “How many ball one needs to throw so that none

  • f the bins is empty?”

n

We already established that E[X] = nHn ≈ n(log n + γ) The Markov inequality only provides a very weak concentration…

slide-44
SLIDE 44
slide-45
SLIDE 45

In order to apply Chebyshev’s inequality, we need to compute

Var[X] = E[X2] − (E[X])2

slide-46
SLIDE 46

In order to apply Chebyshev’s inequality, we need to compute

Var[X] = E[X2] − (E[X])2

Recall that where each follows geometric distribution with parameter

X =

n−1

i=0

Xi Xi n − i n

slide-47
SLIDE 47

In order to apply Chebyshev’s inequality, we need to compute

Var[X] = E[X2] − (E[X])2

Recall that where each follows geometric distribution with parameter

X =

n−1

i=0

Xi Xi n − i n

are independent, so

X0, …, Xn−1

slide-48
SLIDE 48

In order to apply Chebyshev’s inequality, we need to compute

Var[X] = E[X2] − (E[X])2

Recall that where each follows geometric distribution with parameter

X =

n−1

i=0

Xi Xi n − i n

are independent, so

X0, …, Xn−1

Var [

n−1

i=0

Xi] =

n−1

i=0

Var[Xi]

slide-49
SLIDE 49

Variance of Geometric Variables

Assume follow geometric distribution with parameter

Y p

E[Y2] =

i=1

i2(1 − p)i−1p = 2 − p p2 Var[Y] = E[Y2] − (E[Y])2 = 1 − p p2

slide-50
SLIDE 50
slide-51
SLIDE 51

Var[X] =

n−1

i=0

Var[Xi] =

n−1

i=0

n ⋅ i (n − i)2 ≤ n2

n−1

i=0

1 (n − i)2 = n2 ( 1 12 + 1 22 + 1 32 + … + 1 n2 ) = π2n2 6 .

slide-52
SLIDE 52

Var[X] =

n−1

i=0

Var[Xi] =

n−1

i=0

n ⋅ i (n − i)2 ≤ n2

n−1

i=0

1 (n − i)2 = n2 ( 1 12 + 1 22 + 1 32 + … + 1 n2 ) = π2n2 6 . By Chebyshev’s inequality, Pr[X ≥ nHn + cn] ≤ π2 6c2

slide-53
SLIDE 53

Var[X] =

n−1

i=0

Var[Xi] =

n−1

i=0

n ⋅ i (n − i)2 ≤ n2

n−1

i=0

1 (n − i)2 = n2 ( 1 12 + 1 22 + 1 32 + … + 1 n2 ) = π2n2 6 . By Chebyshev’s inequality, Pr[X ≥ nHn + cn] ≤ π2 6c2 The use of Chebyshev’s inequality is often referred to as the “second-moment method”

slide-54
SLIDE 54

Random Graph

slide-55
SLIDE 55

Random Graph

Erdős–Rényi random graph G(n, p)

slide-56
SLIDE 56

Random Graph

Erdős–Rényi random graph G(n, p) vertices, each edge appears with probability independently

n p

slide-57
SLIDE 57

Random Graph

Erdős–Rényi random graph G(n, p) Given a graph property , define its threshold function as:

P r(n)

vertices, each edge appears with probability independently

n p

slide-58
SLIDE 58

Random Graph

Erdős–Rényi random graph G(n, p) Given a graph property , define its threshold function as:

P r(n)

vertices, each edge appears with probability independently

n p

  • if

, does not satisfy whp;

  • if

, satisfies P whp.

p ≪ r(n) G ∼ G(n, p) P p ≫ r(n) G ∼ G(n, p)

slide-59
SLIDE 59
slide-60
SLIDE 60

We will show that the property “ contains a -clique” has threshold function

P = G 4 n−2/3

slide-61
SLIDE 61

We will show that the property “ contains a -clique” has threshold function

P = G 4 n−2/3

For every , let be the indicator that “ is a clique”.

S ∈ ( [n] 4 ) XS G[S]

slide-62
SLIDE 62

We will show that the property “ contains a -clique” has threshold function

P = G 4 n−2/3

For every , let be the indicator that “ is a clique”.

S ∈ ( [n] 4 ) XS G[S]

Let , then satisfies iff .

X = ∑

S∈(

[n] 4 )

XS G P X > 0

slide-63
SLIDE 63
slide-64
SLIDE 64

Then E[X] =

S∈(

[n] 4 )

E[XS] ≈ n4p6 24 .

slide-65
SLIDE 65

Then E[X] =

S∈(

[n] 4 )

E[XS] ≈ n4p6 24 .

If , . So by Markov inequality

p ≪ n− 2

3 E[X] = o(1)

slide-66
SLIDE 66

Then E[X] =

S∈(

[n] 4 )

E[XS] ≈ n4p6 24 .

If , . So by Markov inequality

p ≪ n− 2

3 E[X] = o(1)

Pr[X ≥ 1] ≤ E[X] = o(1)

slide-67
SLIDE 67
slide-68
SLIDE 68

It is not necessary that implies . (Why?)

E[X] = Ω(1) Pr[X > 0] = 1 − o(1)

slide-69
SLIDE 69

It is not necessary that implies . (Why?)

E[X] = Ω(1) Pr[X > 0] = 1 − o(1)

We require some control over Var[X]

slide-70
SLIDE 70

It is not necessary that implies . (Why?)

E[X] = Ω(1) Pr[X > 0] = 1 − o(1)

We require some control over Var[X] By Chebyshev’s inequality,

slide-71
SLIDE 71

It is not necessary that implies . (Why?)

E[X] = Ω(1) Pr[X > 0] = 1 − o(1)

We require some control over Var[X] By Chebyshev’s inequality,

Pr[X = 0] ≤ Pr[|X − E[X]| ≥ E[X]] ≤ Var[X] E[X]2 = E[X2] E[X]2 − 1

slide-72
SLIDE 72

It is not necessary that implies . (Why?)

E[X] = Ω(1) Pr[X > 0] = 1 − o(1)

We require some control over Var[X] By Chebyshev’s inequality,

Pr[X = 0] ≤ Pr[|X − E[X]| ≥ E[X]] ≤ Var[X] E[X]2 = E[X2] E[X]2 − 1

A sufficient condition is E[X2] = (1 + o(1)) ⋅ E[X]2

slide-73
SLIDE 73
slide-74
SLIDE 74

E[X2] − E[X]2 = E[( ∑

S∈(

[n] 4 )

XS)

2

] − (E[ ∑

S∈(

[n] 4 )

XS])

2

= ∑

S,T∈(

[n] 4 ):|S∩T|=2

(E[XS ⋅ XT] − E[X]E[XT])+ ∑

S,T∈(

[n] 4 ):|S∩T|=3

(E[XS ⋅ XT] − E[XS]E[XT])+ ∑

S∈(

[n] 4 )

(E[X2

S] − E[XS]2)

≤ n6p11 + n5p9 + n4p6 = o(E[X]2)