Lecture 12: Randomized Algorithms
- 1 Linearity of Expectation
- 2 Markov and Chebyshev inequalities
- 2.1 Markov’s inequality (Nonnegative random variable X X X)
- 2.2 E ( X Y ) = E ( X ) E ( Y ) E(XY)=E(X)E(Y) E(XY)=E(X)E(Y) if X X X and Y Y Y are ***independent***
- 2.3 V a r ( x ) = E ( X 2 ) − E ( X ) 2 Var(x)=E(X^2)-E(X)^2 Var(x)=E(X2)−E(X)2
- 2.4 Variance of a sum of independent random variables V a r ( X + Y ) = V a r ( X ) + V a r ( Y ) Var(X+Y)=Var(X)+Var(Y) Var(X+Y)=Var(X)+Var(Y)
- 2.5 Chebyshev’s inequality (any random variable X X X)
- 3 Chernoff bounds
- 4 Balls and bins
1 Linearity of Expectation
1.1 Expectation E ( x ) = ∑ x x P ( x ) E(x)=\sum_x xP(x) E(x)=∑xxP(x)
1.2 E ( X + Y ) = E ( X ) + E ( Y ) E(X+Y)=E(X)+E(Y) E(X+Y)=E(X)+E(Y) for all X , Y X, Y X,Y
1.3 Ex 1, Expected waiting time for heads
- Let the random variable X X X denote the number of flips of a p-biased coin until we get the first “heads”.
- Indicator variable X i = 1 X_i=1 Xi=1 if the number of flips is at least i i i, 0 0 0 otherwise. E ( X i ) = ( 1 − p ) i − 1 E(X_i)=(1-p)^{i-1} E(Xi)=(1−p)i−1, X i X_i Xis are dependent.
- X = ∑ i X i X=\sum_{i}X_i X=∑iXi
- E ( X ) = ∑ i ( 1 − p i ) i − 1 = 1 p E(X)=\sum_i (1-p_i)^{i-1}=\frac{1}{p} E(X)=∑i(1−pi)i−1=p1
1.4 Ex 2, A coupon collector process
- Suppose we repeatedly draw a uniformly random number from { 1 , … , n } \{1,\dots,n\} {1,…,n} until we have drawn each number at least once.
- What is the expected number of draws?
- Partition into
n
n
n phases,
- Phase i i i begins once i − 1 i-1 i−1 distinct integers have been drawn.
- X i X_i Xi denote the number of draws in Phase i i i.
- X X X denotes ∑ 1 ≤ i ≤ n X i \sum_{1\leq i\leq n}X_i ∑1≤i≤nXi, X i X_i Xi like flip a n − ( i − 1 ) n \frac{n-(i-1)}{n} nn−(i−1) biased coin, E ( X i ) = n n − ( i − 1 ) E(X_i)=\frac{n}{n-(i-1)} E(Xi)=n−(i−1)n
- E ( X ) = ∑ i ≤ i ≤ n E ( X i ) = ∑ 1 ≤ i ≤ n 1 i = n H n ≈ n ln n E(X)=\sum_{i\leq i\leq n}E(X_i)=\sum_{1\leq i \leq n}\frac{1}{i}=nH_n\approx n\ln n E(X)=∑i≤i≤nE(Xi)=∑1≤i≤ni1=nHn≈nlnn
2 Markov and Chebyshev inequalities
2.1 Markov’s inequality (Nonnegative random variable X X X)
For any nonnegative random variable
X
X
X and any
a
>
0
a>0
a>0.
P
r
(
X
≥
a
)
≤
E
(
x
)
a
P_r(X\geq a)\leq \frac{E(x)}{a}
Pr(X≥a)≤aE(x)
2.2 E ( X Y ) = E ( X ) E ( Y ) E(XY)=E(X)E(Y) E(XY)=E(X)E(Y) if X X X and Y Y Y are independent
2.3 V a r ( x ) = E ( X 2 ) − E ( X ) 2 Var(x)=E(X^2)-E(X)^2 Var(x)=E(X2)−E(X)2
Ex, variance of a p-biased coin flip, V a r ( X ) = p − p 2 Var(X)=p-p^2 Var(X)=p−p2
2.4 Variance of a sum of independent random variables V a r ( X + Y ) = V a r ( X ) + V a r ( Y ) Var(X+Y)=Var(X)+Var(Y) Var(X+Y)=Var(X)+Var(Y)
Ex, variance of a series of p-biased coin flips, V a r ( ∑ X i ) = n p ( 1 − p ) Var(\sum X_i)=np(1-p) Var(∑Xi)=np(1−p)
2.5 Chebyshev’s inequality (any random variable X X X)
P r ( ∣ X − E ( X ) ∣ ≥ a ) ≤ V a r ( x ) a 2 P_r(|X-E(X)|\geq a)\leq \frac{Var(x)}{a^2} Pr(∣X−E(X)∣≥a)≤a2Var(x)
3 Chernoff bounds
3.1 Binomial distribution
For 1 ≤ i ≤ n 1\leq i\leq n 1≤i≤n, let p i ∈ [ 0 , 1 ] p_i\in [0,1] pi∈[0,1], let X i X_i Xi be a 0-1 random variable such that P r ( X i = 1 ) = p i P_r(X_i=1)=p_i Pr(Xi=1)=pi, denote p = 1 n ∑ 1 ≤ i ≤ n p i p=\frac{1}{n} \sum_{1\leq i\leq n}p_i p=n1∑1≤i≤npi, X = ∑ X i X=\sum X_i X=∑Xi, thus E ( X ) = n p E(X)=np E(X)=np.
3.2 Lower bound
P
r
(
X
≤
(
1
−
δ
)
n
p
)
≤
e
−
δ
2
n
p
/
2
P_r(X\leq (1-\delta)np)\leq e^{-\delta^2np/2}
Pr(X≤(1−δ)np)≤e−δ2np/2
δ
∈
[
0
,
1
)
\delta \in [0,1)
δ∈[0,1)
3.3 Upper bound
P
r
(
X
≥
(
1
+
δ
)
n
p
)
≤
e
−
δ
2
n
p
/
3
P_r(X\geq (1+\delta)np)\leq e^{-\delta^2np/3}
Pr(X≥(1+δ)np)≤e−δ2np/3
δ
∈
[
0
,
1
)
\delta \in [0,1)
δ∈[0,1)
3.4 When p = 1 2 p=\frac{1}{2} p=21
P
r
(
X
≤
(
1
−
δ
)
n
/
2
)
≤
e
−
δ
2
n
/
2
P_r(X\leq (1-\delta)n/2)\leq e^{-\delta^2n/2}
Pr(X≤(1−δ)n/2)≤e−δ2n/2
P
r
(
X
≥
(
1
+
δ
)
n
/
2
)
≤
e
−
δ
2
n
/
2
P_r(X\geq (1+\delta)n/2)\leq e^{-\delta^2n/2}
Pr(X≥(1+δ)n/2)≤e−δ2n/2
δ
∈
[
0
,
1
)
\delta \in [0,1)
δ∈[0,1)
4 Balls and bins
4.1 Balls and bins problems
Suppose we throw a series of balls independently and uniformly at random into n n n bins.
4.2 Upper bounding the load of a specific bin
Assume n n n balls into n n n bins uniformly and independently. X i X_i Xi denotes indicator variable that = 1 =1 =1 when ball i i i land into bin 1. X = ∑ i X i X=\sum_i X_i X=∑iXi denotes the load of bin 1 X ∼ B ( n , 1 / n ) X \sim B(n,1/n) X∼B(n,1/n).
P r ( X ≥ c ′ ln n ln ln n ) ≤ n − c P_r(X\geq c'\frac{\ln n}{\ln \ln n})\leq n^{-c} Pr(X≥c′lnlnnlnn)≤n−c
4.3 Upper bounding maximum bin load
E i E_i Ei denotes bin i i i exceeds c ′ f ( n ) c'f(n) c′f(n), where f ( n ) = ln n ln ln n f(n)=\frac{\ln n}{\ln \ln n} f(n)=lnlnnlnn, we see P r ( E i ) ≤ n − c P_r(E_i)\leq n^{-c} Pr(Ei)≤n−c, by union bound, the probability of bad events is ≤ n 1 − c \leq n^{1-c} ≤n1−c, the maximum load of any bin is O ( f ( n ) ) O(f(n)) O(f(n)) with high probability.
4.4 Lower bounding the load of a specific bin
P r ( X ≥ ε ′ f ( n ) ) ≥ n − ε P_r(X\geq \varepsilon'f(n) )\geq n^{-\varepsilon} Pr(X≥ε′f(n))≥n−ε
4.5 Lower bounding the minimum bin load
Minimum less than ε ′ f ( n ) \varepsilon'f(n) ε′f(n) balls, ( 1 − n − ε ) n (1-n^{-\varepsilon})^n (1−n−ε)n