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 (). 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

σ-Algebra

represented by symbol

A collection of subsets of a sample space such that

  • the empty set is contained in
  • if , then its complement
  • A countable union of sets in is contained in

Example:

  • the smallest containing and is .
  • The empty set is called the "impossible" event

Probability Measure

Let be a σ-algebra over a sample space . A probability measure on is a function such that:

  • The centain event satisfies

Properties

  • Let be events. Then
  • Let and be any events, then .

Uniform Probability Distribution

Probability of any singleton event happening is

Continuous Probability Distribution

Continuous uniform distribution over interval associates to each subinterval of

σ-algebra breaks down since one cannot choose . Use Borel measure instead:


Union Bound

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

This bound is useful because it is easy to compute

Conditional Probabilities

Let and be events such that . The conditional probability is defined as

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

Independent Events

Two events are called independent iff

If and are independent, then


Verifying Polynomial Identities

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

For example, is the same as ?

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

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 ()! (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...)