probabilistic algorithms - cs 6

13
PROBABILISTIC ALGORITHMS Pages 368 - 375 1

Upload: others

Post on 03-Feb-2022

8 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: PROBABILISTIC ALGORITHMS - cs 6

PROBABILISTIC ALGORITHMS

Pages 368 - 375

1

Page 2: PROBABILISTIC ALGORITHMS - cs 6

2

Page 3: PROBABILISTIC ALGORITHMS - cs 6

PROBABILISTIC ALGORITHMS

• A probabilistic algorithm is an algorithmdesigned to use the outcome of a randomprocess.

• Example: flip a coin.

• How can making a decision by flipping a coin everbe better than actually calculating, or evenestimating, the best choice in a particularsituation?

3

Page 4: PROBABILISTIC ALGORITHMS - cs 6

THE CLASS BPP

• We begin our formal discussion ofprobabilistic computation by defining amodel of a probabilistic Turing machine.

4

Page 5: PROBABILISTIC ALGORITHMS - cs 6

5

Page 6: PROBABILISTIC ALGORITHMS - cs 6

Definition 10.3 (cont.)

• When a probabilistic Turing machinerecognizes a language = it must accept allstrings in the language and reject all stringsout of the language as usual.

• Except that now we allow the machine a smallprobability of error.For say that M recognizeslanguage A with error probability .

6

Page 7: PROBABILISTIC ALGORITHMS - cs 6

• We also consider error probability bounds thatdepend on the input length n. For example,error probability = 2-n indicates anexponentially small probability of error.

Definition 10.3 (cont.)

worst case computation branch on each input

7

Page 8: PROBABILISTIC ALGORITHMS - cs 6

= amplification lemma.

• Amplification lemma gives a simple way ofmaking the error probability exponentiallysmall.

• LEMMA 10.5 and proof IDEA. (self stady)PROOF.

8

Page 9: PROBABILISTIC ALGORITHMS - cs 6

PRIMALITY• A prime number is an integer greater than 1that is not divisible by positive integers otherthan 1 and itself.

• A nonprime number greater than 1 is calledcomposite.

• One way to determine whether a number isprime is to try all possible integers less thanthat number and see whether any are divisors,also called factors.

• exponential time complexity

9

Page 10: PROBABILISTIC ALGORITHMS - cs 6

• For example, if p = 7 and a = 2, the theoremsays that 2 (7-1)mod 7 should be 1 because 7 isprime.

• The simple calculation 2(7-1) = 26 = 64 and 64mod 7 = 1 confirms this result.

• Suppose that we try p = 6 instead.Then 2(6-1) = 25 = 32 and 32 mod 6 = 2

10

Fermat's little theorem

Page 11: PROBABILISTIC ALGORITHMS - cs 6

Algorithm Fermat test

11

Page 12: PROBABILISTIC ALGORITHMS - cs 6

Self study

12

Page 13: PROBABILISTIC ALGORITHMS - cs 6

Note

The probabilistic primality algorithm has one-sidederror.

When the algorithm outputs reject, we know thatthe input must be composite.

When the output is accept, we know only that theinput could be prime or composite.

Thus an incorrect answer can only occur when theinput is a composite number.

The one-sided error feature is common to manyprobabilistic algorithms, so the special complexityclass RP is designated for it.

13