randomized algorithms...how many primes less than ๐? 4 ๐ ๐ primes less than ๐ how many...
TRANSCRIPT
Randomized Algorithms CS648
Lecture 4
โข Algebraic Techniques
โข Fingerprinting Techniques โข Frievaldโs Technique
1
Fingerprinting
2 Applications : Cryptography
Reason: The aim is to be able to distinguish two different persons. Theoretically, it is very less likely that two persons picked randomly will have the same fingerprints.
Fingerprints donโt capture the complete information of a person. Still fingerprinting is used and it works well in
practice. What is the reason ?
3
Aim: To determine if File A identical to File B by communicating fewest bits ?
Network
File A File B
size(A) = ๐ bits size(B) = ๐ bits
No. of bits to be sent
Deterministic algorithm
Randomized algorithm
๐
O(log(๐))
How many primes less than ๐ ?
4
๐ Primes less than ๐
๐๐๐ ๐๐
๐๐๐๐ ๐๐๐
๐๐๐๐๐ ๐๐๐๐
๐๐๐๐๐๐ ๐๐๐๐
๐๐๐๐๐๐๐ ๐๐๐๐๐
โฎ โฎ
โฎ โฎ
How many prime factors of ๐ ? < log๐
๐๐๐๐ ๐๐ โ ๐๐ โ ๐ = ๐๐ โ ๐๐ โ ๐
๐ ๐ :
๐ ๐ โ ๐log๐
Huge gap Interestingly this simple fact alone
will be used in devising the algorithm.
Visualize a file as a binary number
File A = ๐0 ๐1 ๐2 โฆ ๐๐โ1
File B = ๐0 ๐1 ๐2 โฆ ๐๐โ1
๐ตA = 2๐ โ ๐๐๐โ1๐=0
๐ตB= 2๐ โ ๐๐๐โ1๐=0
(trivial) Observation: File A = File B if and only if ๐ตA = ๐ต๐ต
Question: How large a number can ๐ตA (or ๐ตB) be ?
Answer: always less than 2๐.
5
6
Network
File A File B
size(A) = ๐ bits size(B) = ๐ bits
What should be ?
RandomEqualityChecking-Protocol(๐จ,๐ฉ)
Processing at the sender computer :
1. Let ๐ be a prime number selected randomly uniformly from [2, ๐ก]
2. ๐ ๐ตA mod ๐;
3. sender sends (๐,๐) to receiver .
Processing at the receiver computer:
1. (๐,๐) is received from sender.
2. ๐ ๐ตB mod ๐;
3. If(๐ = ๐) send โA=Bโ to the sender
else send โAโ Bโ to the sender
Number of Bits transmitted:
๐ ๐ฅ๐จ๐ ๐ก
7
Cases
Error Analysis
Let ๐ = |๐ตA โ ๐ต๐ต|
Observation: If ๐ตA โ ๐ต๐ต, then surely ๐ > ๐.
The protocol makes an error if and only if
๐ตA ๐ฆ๐จ๐ ๐ = ๐ตB ๐ฆ๐จ๐ ๐
๐ตA ๐ฆ๐จ๐ ๐โ ๐ตB ๐ฆ๐จ๐ ๐ = ๐
(๐ตA โ ๐ต๐ต) ๐ฆ๐จ๐ ๐ = ๐
๐ divides ๐
8
?
๐ตA = ๐ตB
๐ตA โ ๐ตB
๐ตA๐ฆ๐จ๐ ๐ = ๐ตB ๐ฆ๐จ๐ ๐
๐ตA๐ฆ๐จ๐ ๐ = ๐ตB ๐ฆ๐จ๐ ๐
with ๐ ๐๐๐ probability
Cases
Error Analysis
9
๐ 1
2๐ 1 ๐
Less than ๐ prime factors
๐ (๐) โ๐
log ๐ prime
numbers
?
๐ตA = ๐ตB
๐ตA โ ๐ตB ๐ตA๐ฆ๐จ๐ ๐ = ๐ตB ๐ฆ๐จ๐ ๐
with ๐ ๐๐๐ probability โค
๐
๐ (๐)
๐ตA๐ฆ๐จ๐ ๐ = ๐ตB ๐ฆ๐จ๐ ๐
Error Analysis
Lemma: The probability RandomEqualityChecking-Protocol makes an error is ๐
๐(๐ก).
Question: How large should ๐ก be in order to achieve error probability < 1
๐ ?
Answer: Pick ๐ก =4 ๐2 log ๐.
๐(๐ก) โ ๐ก
log ๐ก .
โ 4 ๐2 log ๐
2 log ๐+2+log log ๐
> ๐2 for ๐ > 4
Bits transmitted: ๐ ๐ฅ๐จ๐ ๐ก = O(๐ฅ๐จ๐ ๐)
10
๐ (๐) โ๐
log ๐ prime
numbers
FRIEVALDโS TECHNIQUE
Application : Matrix Product verification
11
Frievaldโs Algorithm (Rusins Frievald, 1977)
Problem: Given three ๐-by-๐ matrices ๐จ, ๐ฉ, and ๐ช, determine if ๐ช โ ๐จ โจฏ ๐ฉ.
Best deterministic algorithm: โข ๐ซ ๐จ โจฏ ๐ฉ;
โข Verify if ๐ช = ๐ซ ?
12
โ โจฏ
1 2 โฆ ๐
1 2 โฎ
๐
๐ช ๐จ ๐ฉ
Time complexity: ๐ถ(๐ฯ), current value of ฯ < 2.37
STOC 2012
Frievaldโs Algorithm (Rusins Frievald, 1977)
13
โ
โจฏ
๐ช
๐จ ๐ฉ
โจฏ
1 0 โฎ
1 1
0
1 0 โฎ
1 1
0
โจฏ
๐ ๐
๐ ๐
Frievaldโs Algorithm (Rusins Frievald, 1977)
RandomProductVerify(๐จ,๐ฉ,๐ช)
Let ๐ be a ๐-by-1 matrix (vector) whose elements
are selected randomly uniformly and independently from {0,1}.
๐ ๐ฉ โ ๐ ;
๐ ๐จ โ ๐ ;
๐ ๐ช โ ๐
If(๐ = ๐) output โAB=Cโ
else output โABโ Cโ
Time complexity: ?
14
๐ถ(๐2)
Frievaldโs Algorithm (Analyzing error probability)
Question:
If ๐จ โ ๐ฉ โ ๐ช, what is the probability that the algorithm outputs โAB=Cโ ?
Let ๐ซ = ๐จ โ ๐ฉ โ ๐ช
Observation: If ๐จ โ ๐ฉ โ ๐ช ๐ซ is not a null matrix.
Error Probability of the algorithm = P( ๐จ โ ๐ฉ โ ๐ = ๐ช โ ๐ )
๐จ โ ๐ฉ โ ๐ = ๐ช โ ๐
๐จ โ ๐ฉ โ ๐ โ ๐ช โ ๐ = ๐
(๐จ โ ๐ฉ โ ๐ช) โ ๐ = ๐
๐ซ โ ๐ = ๐
15
๐ซ โ ๐ = ๐
null vector
Frievaldโs Algorithm (Analyzing error probability)
๐(๐ซ โ ๐ = ๐) depends upon ๐ซ.
So what to do ?
Our goal is to get an upper bound on this probability.
So we start with the least information about ๐ซ,
which is:
There is at least one non-zero element in ๐ซ.
Let this element be ๐ซ๐,๐.
โข P(๐ซ โ ๐ = ๐)
โค P(๐ซ๐ โ ๐ = 0)
focus on the product of ๐th row and vector ๐.
16
โจฏ
1 2 โฆ ๐
1 2 โฎ
๐
๐ซ ๐
๐
๐
= P( ๐ซ๐ โ ๐ = 0๐ )
Frievaldโs Algorithm (Analyzing error probability)
P(๐ซ๐ โ ๐ = 0) = P(๐ท๐1 โ ๐ฅ1 + โฆ + ๐ท๐๐ โ ๐ฅ๐ = 0)
The underlying sample space has 2๐ elementary events.
Convince yourself that it is indeed difficult to calculate this probability from standard tools which you know.
Here we shall use a simple but powerful probability toolโฆ
17
โจฏ
1 2 โฆ ๐
1 2 โฎ
๐
๐ซ ๐
๐
๐
Probability tool: Partition of sample space
A set of events ๐1,โฆ, ๐๐defined over a probability space (๐,P) is said to induce a partition of ๐ if
โข ๐๐๐๐=1 = ๐
โข ๐๐ ๐๐ =โ for all๐ โ ๐
Theorem: (Partition theorem)
Given an event ๐, we can express P(๐) in terms of a given partition as:
P(๐) = P(๐๐ โฉ ๐๐) = P(๐๐ |๐๐)โ P(๐๐) using conditional probability
18
ฮฉ ๐ ๐1
๐2 ๐3
๐4
๐5
๐6
Question: When to use the Partition theorem ?
Let be ๐ an event defined over a probability space (๐,P).
Suppose it turns out that it is not easy to calculate or get a good bound on P(๐) directly using the standard tools. In such situation, one may explore the following possibility:
Try to design a partition {๐1,โฆ, ๐๐} of the sample space such that P(๐|๐๐) is easy to calculate. This may be used to calculate P(๐).
IMPORTANT: Most of the times, P(๐|๐๐) turns out to be independent of ๐. In this case, P(๐) can be bounded directly as follows.
If P(๐|๐๐) โค ๐ผ for every possible value of ๐, then
P(๐) = P(๐๐ |๐๐)โ P(๐๐)
โค ๐ผ๐ โ P(๐๐)
= ๐ผ P(๐๐) ๐
= ๐ผ
19
Frievaldโs Algorithm (Analyzing error probability)
P( ๐ท๐1 โ ๐ฅ1 + โฆ + ๐ท๐๐ โ ๐ฅ๐ = 0 ) = ??
Question:
What can be the suitable partition of ๐ ?
the partition defined by the values taken by all the r.v.โs excluding ๐ฅ๐.
20
๐
Think over it carefully ?
Frievaldโs Algorithm (Analyzing error probability)
P( ๐ท๐1 โ ๐ฅ1 + โฆ + ๐ท๐๐ โ ๐ฅ๐ = 0 ) = ??
Question: What is the probability of ๐conditioned on
any arbitrary but fixed values taken by all ๐ฅ๐ , ๐ โ ๐ ?
Answer: Consider any ๐ โ 1 values ๐1,โฆ, ๐๐โ1, ๐๐+1, โฆ , ๐๐ ฯต 0,1 .
We are interested in the probability of event ๐ conditioned on โ๐ฅ1 = ๐1,โฆ,๐ฅ๐โ1 =๐๐โ1, ๐ฅ๐+1 = ๐๐+1, โฆ , ๐ฅ๐ = ๐๐โ. This probability can be expressed as :
P(โฐ | ๐ฅ1 = ๐1,โฆ,๐ฅ๐โ1 = ๐๐โ1, ๐ฅ๐+1 = ๐๐+1, โฆ , ๐ฅ๐ = ๐๐)
= P(๐ท๐,1 โ ๐1 + โฆ + ๐ท๐,๐โ1 โ ๐๐โ1+ ๐ท๐,๐ โ ๐ฅ๐ + ๐ท๐,๐+1 โ ๐๐+1 + โฆ๐ท๐๐โ ๐๐ = 0)
= P(๐ท๐,๐ โ ๐ฅ๐ = โ(๐ท๐,1 โ ๐1 + โฆ + ๐ท๐,๐โ1 โ ๐๐โ1+ + ๐ท๐,๐+1 โ ๐๐+1 + โฆ๐ท๐๐โ ๐๐))
= P(๐ฅ๐ = โ(๐ท๐,1 โ ๐1 + โฆ + ๐ท๐,๐โ1 โ ๐๐โ1+ + ๐ท๐,๐+1 โ ๐๐+1 + โฆ๐ท๐๐ โ ๐๐)/๐ท๐,๐)
โค ยฝ 21
โ 0
โค ยฝ
๐
Could be 0, 1 or some other number
Frievaldโs Algorithm (Analyzing error probability)
Theorem:
Error probability of algorithm RandomProductVerify(๐จ,๐ฉ,๐ช) is at most ยฝ.
Question: How to increase the success probability ?
(think over this answer carefully before proceeding further)
22
Probability ampilification
Repeat the Monte Carlo algorithm ๐ times.
23
Frievaldโs Algorithm (reducing the error probability)
RandomProductVerify(๐จ,๐ฉ,๐ช)
Repeat ๐ times
{ Let ๐ be a ๐-by-1 matrix (vector) whose elements are selected randomly uniformly
and independently from {0,1}.
๐ ๐ฉ โ ๐ ;
๐ ๐จ โ ๐ ;
๐ ๐ช โ ๐
If(๐ โ ๐) { output โAB โ Cโ ; break}
}
output โAB = Cโ
Time complexity: ๐ถ(๐๐2)
Error probability: ?
24
โค (ยฝ)๐
Frievaldโs Algorithm (final result)
Theorem: Given three ๐-by-๐ matrices ๐จ, ๐ฉ, and ๐ช,
there is a Randomized Monte Carlo algorithm which determines ๐ช โ ๐จ โจฏ ๐ฉ.
The running time is ๐ถ(๐2log ๐), and the error probability is less than ๐โ2.
25
Homework
โข Is there anything magical about ยฝ in the error probability ?
โข What is the source of ยฝ in the error probability ?
26
โข Please go through the slides of this lecture carefully and patiently.
โข You are welcome to discuss any doubt in the tomorrowโs class (Thursday, 18th January)
27
Fun with probability
28
With the inspiration from RandApproxMedian algoritm
Design
โข An extremely simple
โข randomized LasVegas algorithm with
โข expected O(๐) running time
for exact median.
29