Randomized Algorithms Course Info yitong.yin@gmail.com - - PowerPoint PPT Presentation

randomized algorithms
SMART_READER_LITE
LIVE PREVIEW

Randomized Algorithms Course Info yitong.yin@gmail.com - - PowerPoint PPT Presentation

Randomized Algorithms Course Info yitong.yin@gmail.com yinyt@nju.edu.cn office hour: 804, Thursday 2-4pm course homepage: http://tcs.nju.edu.cn/wiki Textbooks Rajeev Motwani and Prabhakar


slide-1
SLIDE 1

Randomized Algorithms

南京大学 尹一通

slide-2
SLIDE 2

Course Info

  • 尹一通

yitong.yin@gmail.com yinyt@nju.edu.cn

  • office hour:

804, Thursday 2-4pm

  • course homepage: http://tcs.nju.edu.cn/wiki
slide-3
SLIDE 3

Textbooks

Rajeev Motwani and Prabhakar Raghavan. Randomized Algorithms. Cambridge University Press, 1995. Michael Mitzenmacher and Eli Upfal. Probability and Computing:

Randomized Algorithms and Probabilistic Analysis.

Cambridge University Press, 2005.

slide-4
SLIDE 4

References

CLRS

Feller

An Introduction to Probability Theory and Its Applications

Aldous and Fill

Reversible Markov Chains and Random Walks on Graphs

Alon and Spencer

The Probabilistic Method

slide-5
SLIDE 5

“algorithms which use randomness in computation”

Randomized Algorithms

Why?

  • Simpler.
  • Faster.
  • Can do impossibles.
  • Can give us clever deterministic algorithms.
  • Random input.
  • Deterministic problem with random nature.
  • ... ...

Turing Machine random coin

slide-6
SLIDE 6

Checking Matrix Multiplication

A B C

×

=

?

three n×n matrices A, B, C: best matrix multiplication algorithm:

O(n2.373)

slide-7
SLIDE 7

Checking Matrix Multiplication

A B C

×

=

?

three n×n matrices A, B, C: best matrix multiplication algorithm:

O(nω) O(n2.373)

slide-8
SLIDE 8

best matrix multiplication algorithm:

Checking Matrix Multiplication

A B C

×

=

?

three n×n matrices A, B, C:

Freivald’s Algorithm pick a uniform random r ∈{0,1}n; check whether A(Br) = Cr ;

time: O(n2) if AB = C, always correct

O(n2.373)

slide-9
SLIDE 9

Freivald’s Algorithm pick a uniform random r ∈{0,1}n; check whether A(Br) = Cr ;

if AB = C, always correct if AB ≠ C,

Pr[ABr = Cr] = Pr[Dr = 0] D = AB C = 0n×n

let

D r

i

(Dr)i =

n

  • k=1

Dikrk =0 rj = − 1 Dij

n

  • k=j

Dikrk 2n 2n−1 = 1 2 Dij = 0

say

slide-10
SLIDE 10

Freivald’s Algorithm pick a uniform random r ∈{0,1}n; check whether A(Br) = Cr ;

if AB = C, always correct

If AB ⇥= C, for a uniformly random r {0, 1}n, Pr[ABr = Cr] ≤ 1 2. Theorem (Freivald, 1979)

repeat independently for 100 times time: O(n2)

if AB ≠ C, error probability ≤

2−100

slide-11
SLIDE 11

Monte Carlo vs Las Vegas

Monte Carlo Las Vegas running time is fixed correctness is random always correct running time is random Two types of randomized algorithms:

slide-12
SLIDE 12

Polynomial Identity Testing

(PIT)

Input: two polynomials f, g ∈ F[x] of degree d Output:

f ≡ g?

Input: a polynomial

  • f degree d

Output:

f ∈ F[x] f ≡ 0?

f is given as black-box

f ∈ F[x] f(x) =

d

X

i=0

aixi

  • f degree d :

ai ∈ F

for

slide-13
SLIDE 13

simple deterministic algorithm: check whether f(x)=0 for all x ∈ {1, 2, . . . , d + 1} A degree d polynomial has at most d roots.

Fundamental Theorem of Algebra:

Randomized Algorithm pick a uniform random r ; check whether f(r) = 0 ;

∈S

S ⊆ F

Input: a polynomial

  • f degree d

Output:

f ∈ F[x] f ≡ 0?

slide-14
SLIDE 14

A degree d polynomial has at most d roots.

Fundamental Theorem of Algebra:

Randomized Algorithm pick a uniform random r ; check whether f(r) = 0 ;

∈S

S ⊆ F f 0

if

Pr[f(r) = 0] ≤ |S| d |S| = 2d = 1 2

slide-15
SLIDE 15

Checking Identity

database 1 database 2 Are they identical? 北京 南京

slide-16
SLIDE 16

Communication Complexity

(Yao 1979)

Li Lei Han Meimei

EQ : {0, 1}n × {0, 1}n → {0, 1}

# of bits communicated

a b

f(a, b)

EQ(a, b) =

  • 1

a = b a ̸= b

There is no deterministic communication protocol solving EQ with less than n bits in the worst-case.

Theorem (Yao, 1979)

slide-17
SLIDE 17

Communication Complexity

Li Lei Han Meimei

a b ∈{0, 1}n ∈{0, 1}n

f =

n−1

  • i=0

aixi

pick uniform random r ∈[2n]

r, g(r) f(r)=g(r) ?

  • ne-sided error ≤ 1

2

by PIT: # of bit communicated: too large!

g =

n−1

X

i=0

bixi

slide-18
SLIDE 18

Communication Complexity

Li Lei Han Meimei

a b ∈{0, 1}n ∈{0, 1}n

f =

n−1

  • i=0

aixi

pick uniform random r ∈[p]

r, g(r) f(r)=g(r) ?

k = log2(2n)

p ∈ [2k, 2k+1]

choose a prime

f, g ∈ Zp[x]

let

g =

n−1

X

i=0

bixi

O(log n) bits

slide-19
SLIDE 19

Polynomial Identity Testing

(PIT)

Input:

  • f degree d

Output:

f ≡ g?

f, g ∈ F[x1, x2, . . . , xn] F[x1, x2, . . . , xn] : ring of n-variate polynomials over field F f(x1, x2, . . . , xn) = X

i1,i2,...,in≥0

ai1,i2,...,inxi1

1 xi2 2 · · · xin n

degree of f : maximum i1 + i2 + · · · + in ai1,i2,...,in 6= 0 with f ∈ F[x1, x2, . . . , xn] :

slide-20
SLIDE 20

Input:

  • f degree d

Output:

f ≡ g?

f, g ∈ F[x1, x2, . . . , xn] f(x1, x2, . . . , xn) = X

i1,i2,...,in≥0 i1+i2+···+in≤d

ai1,i2,...,inxi1

1 xi2 2 · · · xin n

Input:

  • f degree d

Output:

f ≡ 0?

f ∈ F[x1, x2, . . . , xn]

equivalently:

slide-21
SLIDE 21

Input:

  • f degree d

Output:

f ≡ g?

f, g ∈ F[x1, x2, . . . , xn]

Input:

  • f degree d

Output:

f ≡ 0?

f ∈ F[x1, x2, . . . , xn]

equivalently:

f is given as block-box: given any ~ x = (x1, x2, . . . , xn) returns f(~ x)

  • r as product from:

Vandermonde determinant

M =      1 x1 x2

1

. . . xn−1

1

1 x2 x2

2

. . . xn−1

2

. . . . . . . . . ... . . . 1 xn x2

n

. . . xn−1

n

    

f(~ x) = det(M) = Y

j<i

(xi − xj)

e.g.

slide-22
SLIDE 22

Input:

  • f degree d

Output:

f ≡ 0?

f ∈ F[x1, x2, . . . , xn] f is given as block-box or product from

PIT: Polynomial Identity Testing

if ∃ a poly-time deterministic algorithm for PIT: either: NEXP ≠ P/poly

  • r: #P ≠ FP
slide-23
SLIDE 23

Input:

  • f degree d

Output:

f ≡ 0?

f ∈ F[x1, x2, . . . , xn] pick random r1, r2, ... , rn ∈S

uniformly and independently at random;

check whether f(r1, r2, ... , rn) = 0 ;

fix an arbitrary S ⊆ F

f ≡ 0 f(r1, r2, . . . , rn) = 0

slide-24
SLIDE 24

A degree d polynomial has at most d roots.

Fundamental Theorem of Algebra:

pick a uniform random r ∈S; check whether f(r) = 0 ;

Input: a polynomial

  • f degree d

Output:

f ∈ F[x] f ≡ 0?

fix an arbitrary S ⊆ F

f ≡ 0 f(r) = 0 f 6⌘ 0 Pr[f(r) = 0] ≤ d |S|

slide-25
SLIDE 25

Input:

  • f degree d

Output:

f ≡ 0?

f ∈ F[x1, x2, . . . , xn] pick random r1, r2, ... , rn ∈S

uniformly and independently at random;

check whether f(r1, r2, ... , rn) = 0 ;

fix an arbitrary S ⊆ F

Schwartz-Zippel Theorem

Pr[f(r1, r2, . . . , rn) = 0] ≤ d |S| f 6⌘ 0 f ≡ 0 f(r1, r2, . . . , rn) = 0

slide-26
SLIDE 26

Schwartz-Zippel Theorem

Pr[f(r1, r2, . . . , rn) = 0] ≤ d |S| f 6⌘ 0 f(x1, x2, . . . , xn) =

d

X

i=0

xi

nfi(x1, x2, . . . , xn−1)

= gx1,x2,...,xn−1(xn) f can be treated as a single-variate polynomial of xn:

done?

Pr[f(r1, r2, . . . , rn) = 0] = Pr[gr1,r2,...,rn−1(rn) = 0] gr1,r2,...,rn−1 6⌘ 0? f(x1, x2, . . . , xn) = X

i1,i2,...,in≥0 i1+i2+···+in≤d

ai1,i2,...,inxi1

1 xi2 2 · · · xin n

slide-27
SLIDE 27

Schwartz-Zippel Theorem

Pr[f(r1, r2, . . . , rn) = 0] ≤ d |S| f 6⌘ 0

induction on n : basis: n=1

single-variate case, proved by the fundamental Theorem of algebra

I.H.:

Schwartz-Zippel Thm is true for all smaller n

slide-28
SLIDE 28

f(x1, x2, . . . , xn) =

k

X

i=0

xi

nfi(x1, x2, . . . , xn−1)

k: highest power of xn in f

fk 6⌘ 0

degree of fk ≤ d − k

n = xk

nfk(x1, x2, . . . , xn−1) + ¯

f(x1, x2, . . . , xn) ¯ f(x1, x2, . . . , xn) =

k−1

X

i=0

xi

nfi(x1, x2, . . . , xn−1)

where highest power of xn in ¯ f < k

Schwartz-Zippel Theorem

Pr[f(r1, r2, . . . , rn) = 0] ≤ d |S| f 6⌘ 0

induction step:

slide-29
SLIDE 29

highest power of xn in ¯ f < k fk 6⌘ 0

degree of fk ≤ d − k

= xk

nfk(x1, x2, . . . , xn−1) + ¯

f(x1, x2, . . . , xn)

Schwartz-Zippel Theorem

Pr[f(r1, r2, . . . , rn) = 0] ≤ d |S| f 6⌘ 0

f(x1, x2, . . . , xn)

n law of total probability: Pr[f(r1, r2, . . . , rn) = 0]

= Pr[f(~ r) = 0 | fk(r1, . . . , rn−1) = 0] · Pr[fk(r1, . . . , rn−1) = 0] + Pr[f(~ r) = 0 | fk(r1, . . . , rn−1) 6= 0] · Pr[fk(r1, . . . , rn−1) 6= 0]

I.H.

≤ d − k |S|

≤ k |S|

gx1,...,xn−1(xn) = f(x1, . . . , xn)

where

= Pr[gr1,...,rn−1(rn) = 0 | fk(r1, . . . , rn−1) 6= 0]

slide-30
SLIDE 30

Schwartz-Zippel Theorem

Pr[f(r1, r2, . . . , rn) = 0] ≤ d |S| f 6⌘ 0 Pr[f(r1, r2, . . . , rn) = 0] ≤ d − k |S| + k |S| = d |S|

slide-31
SLIDE 31

Input:

  • f degree d

Output:

f ≡ 0?

f ∈ F[x1, x2, . . . , xn] pick random r1, r2, ... , rn ∈S

uniformly and independently at random;

check whether f(r1, r2, ... , rn) = 0 ;

fix an arbitrary S ⊆ F

Schwartz-Zippel Theorem

Pr[f(r1, r2, . . . , rn) = 0] ≤ d |S| f 6⌘ 0 f ≡ 0 f(r1, r2, . . . , rn) = 0

slide-32
SLIDE 32