CSCE 411 Lecture 22

From Notes
Jump to navigation Jump to search
Lecture Slides

« previous | Wednesday, October 17, 2012 | next »


Randomized Algorithms

Algorithm maxes random choices during its execution.

  • Steps taken might differ between executions, even if input remains the same.
  • can be simple and easy to implement
  • can be very efficient implementations

Running time is now a random variable that must be determined with probability theory

Motivation

Company has several datacenters, and company wants to verify that copies of the databases are still consistent. Transmission of data is not feasible, so how can we test whether the content is the same?

Suppose we have implemented an extremely fast algorithm to multiply very large matrices (n=100,000). How do we check that the algorithm is correct.

In the RSA key exchange, we need to form the product of two very large primes (each having 1000 digits or more). How can we efficiently check whether a number is prime?

Basic Probability Theory

Sample spaces

possible outcomes of an experiment

represented by symbol Ω

e.g. for coin flip Ω={heads,tails}

σ-Algebra

represented by symbol F

A collection of subsets of a sample space Ω such that

  • the empty set is contained in F
  • if EF, then its complement EC=Ω EF
  • A countable union of sets in F is contained in F

Example:

  • Ω={1,2,3,4,5,6}
  • D={1,2}
  • E={3,4,5,6}
  • the smallest F containing D and E is {,D,E,Ω}.
  • The empty set is called the "impossible" event

Probability Measure

Let F be a σ-algebra over a sample space Ω. A probability measure on F is a function Pr:F[0,1] such that:

  • The centain event satisfies Pr(Ω)=1
  • Pr(i=1Ei)=i=1Pr(Ei)

Properties

  • Let DE be events. Then Pr[D]Pr[E]
  • Let F and G be any events, then Pr[FG]=Pr[F]+Pr[G]Pr[FG].

Uniform Probability Distribution

Probability of any singleton event E={s} happening is Pr[E]=1|Ω|

Continuous Probability Distribution

Continuous uniform distribution over interval [a,b] associates to each subinterval [c,d] of [a,b]

σ-algebra breaks down since one cannot choose F=𝒫(Ω). Use Borel measure instead:

Pr[[c,d]]=dcba


Union Bound

Let I. Let Ei with iI be a set of events. These events do not need to be disjoint:

Pr[iIEi]iIPr[Ei]

This bound is useful because it is easy to compute

Conditional Probabilities

Let D and E be events such that Pr[E]>0. The conditional probability Pr[D|E] is defined as

Pr[D|E]=Pr[DE]Pr[E]Pr[DE]=Pr[D|E]Pr[E]

Interpret as the probability that D occurs, assuming that event E occurs.

Independent Events

Two events are called independent iff

P[DE]=P[D]P[E]

If D and E are independent, then Pr[D|E]=Pr[D]


Verifying Polynomial Identities

Suppose we want to check whether two polynomials in x with integer coefficients are the same.

For example, is (x+1)(x2)(x+3)(x4)(x+5)(x6) the same as x67x3+25?

Doing this the old-fashioned expansion way is slow (Θ(d2))

Randomized Algorithm

def verify_polynomial_identity f, g
  d = [f.degree, g.degree].max
  r = (1..100*d).to_a.sample
  f(r) == g(r)
end

It's Fast (O(d))! (but it can be wrong)

We can reduce the probability that the algorithm will be wrong by repeating it several times. (how many? next time...)