Probabilistic Algorithms Objectives Probabilistic Algorithms

advertisement
Objectives
Probabilistic Algorithms
Lecture 32
CS 312
Probabilistic Algorithms
• Same algorithm may have several
behaviors on the same problem
instance.
• Compare Las Vegas and Monte Carlo
algorithms.
• Justify the use of probabilistic
algorithms.
Numerical Prob. Algs.
• Have a confidence interval
– 90% sure the answer lies between x and y.
• Gets better if run longer
Monte Carlo Prob. Algs.
Monte Carlo Gradebook
• High probability of a correct answer
• Low probability of incorrect answer
• No warning when an incorrect answer is
given.
• Suppose your grade is a 95%.
• If you repeatedly ask a 3/4-correct Monte
Carlo algorithm
– “What’s my grade?”
• You’ll (probably) get
– 95, 95, 90, 95, 70, 95, 95, 95, 95, 100, 95 ...
1
Las Vegas Prob. Algs.
• Never gives incorrect answers
• Sometimes gives no answer
Las Vegas Gradebook
• Suppose your grade is a 95%.
• If you repeatedly ask a 3/4-correct Las
Vegas algorithm
– “What’s my grade?”
• You’ll (probably) get
– 95, don’t know, 95, 95, don’t know, 95, 95,
95, 95, 95, don’t know, 95…
Why?
• Suppose you really need to solve a
problem.
– fate of the free world rests on your shoulders.
• Suppose the problem is really hard.
– random neutron diffusion in fissile material
Buffon’s Needle
• 1707-1788, French
• Invented binomial theorem
• Noted natural historian
• Most famous for throwing needles
over his shoulder to estimate Pi.
• Suppose you don’t have enough computing
resources to solve the problem.
– ENIAC is all you’ve got.
http://www.mste.uiuc.edu/reese/buffon/bufjava.html
Buffon’s Needle
• A needle of length m thrown onto a floor
with lines every 2*m has a 1/pi chance
of landing on a line.
• So if n needles are thrown, and k hit a
line, then n/k is an estimate for pi.
• Numerical probabilistic algorithm
– more needles give better estimate.
• 100x more needles for another digit of
precision.
2
Download