Derandomization.
- Theory:
is P=RP?
- practice:
avoid chance of error, chance of slow.
Conditional Expectation. Max-Cut
- Imagine
placing one vertex at a time.
- xi = 0 or 1 for left or right side
- E[C] = (1/2)E[C| x1 = 0] + (1/2)E[C| x1 = 1]
- Thus,
either E[C| x1 = 0] or E[C| X1 = 1]
E[C]
- Pick
that one, continue
- More
general, whole tree of element settings.
- Let C(a) = E[C | a].
- For
node a with children b, c, C(b) or C(c)
C(a).
- By
induction, get to leaf with expected value at least E[C]
- But no
randomness left, so that is actual cut value.
- Problem:
how compute node values? Easy.
Conditional Probabilities. Set balancing. (works for wires too)
- Review
set-balancing Chernoff bound
- Think
of setting item at a time
- Let Q be bad event (unbalanced set)
- We
know Pr[Q] < 1/n.
- Pr[Q] = 1/2 Pr[Q | xi0] + 1/2 Pr[Q | xi1]
- Follows
that one of conditional probs. less than Pr[Q] < 1/n.
- More
general, whole tree of element settings.
- Let P(a) = Pr[Q | a].
- For
node a with children b, c, P(b) or P(c) < P(a).
- P(r) < 1 sufficient at root r.
- at
leaf l, P(l )= 0 or 1.
- One
big problem: need to compute these probabilities!
- Alternative
to computing probabilities
- three
neceessary conditions:
(r)
< 1
- min{
(b),
(c)}
<
(a)
computable
Imply can use
instead of actual.
- Let Qi =
Pr[unbalanced set i]
- Let
(a)
=
Pr[Qb | a] at tree
node a
- Claim
3 conditions.
- Result:
deterministic O(
) bias.
- more
sophisticated pessimistic estimator for wiring.
- recall:
choose random routing. Only 1/N chance of
failure
- Choose
N3
random routines.
- whp,
for every permutation, at most 2N2 bad routes.
- given
the N3
routes, pick one at random.
- so for
any permutation, prob 2/N of being bad.
Basic idea: compare two things from a big universe U
- generally
takes log U, could be huge.
- Better:
randomly map U to smaller V,
compare elements of V.
- Probability(same)= 1/| V|
- intuition:
log V bits to compare, error prob. 1/| V|
We work with fields
- add,
subtract, mult, divide
- 0 and
1 elements
- eg
reals, rats, (not ints)
- talk
about Zp
- which
field often won't matter.
Verifying matrix multiplications:
- Claim
AB = C
- check
by mul: n3,
or n2.376
with deep math
- Freivald's
O(n2).
- Good
to apply at end of complex algorithm (check answer)
Freivald's technique:
- choose
random r
{0, 1}n
- check
ABr = Cr
- time
O(n2)
- if AB = C, fine.
- What
if AB
C?
- trouble
if (AB - C)r = 0 but D = AB - C
0
- find
some nonzero row (d1,..., dn)
- wlog
d1
0
- trouble
if
diri = 0
- ie
r1 = (
diri)/d1
- principle
of deferred decisions: choose all i
2 first
- then
have exactly one error value for r1
- prob.
pick it is at most 1/2
How improve detection prob?
- k trials makes 1/2k
failure.
- Or
choosing r
[1, s]
makes 1/s.
- Doesn't
just do matrix mul.
- check
any matrix identity claim
- useful
when matrices are ``implicit'' (e.g. AB)
- We
are mapping matrices (n2
entries) to vectors (n entries).
Checksums:
- Alice
and Bob have bit strings of length n
- Think
of n bit integers a,
b
- take
a prime number p, compare a mod p and b mod p with log p
bits.
- trouble
if a = b(mod p). How avoid? How
likely?
- c = a - b is n-bit
integer.
- so
at most n prime factors.
- How
many prime factors less than k?
(k/ln k)
- so
take 2n2log n
limit
- number
of primes about n2
- So
on random one, 1/n error prob.
- O(log n) bits to send.
- implement
by add/sub, no mul or div!
How find prime?
- Well,
a randomly chosen number is prime with prob. 1/ln n,
- so
just try a few.
- How
know its prime? Simple randomized test (later)
Pattern matching in strings
- m-bit pattern
- n-bit string
- work
mod prime p of size at most t
- prob.
error at particular point most m/(t/log t)
- so
pick big t, union bound
- implement
by add/sub, no mul or div!