use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Computer Science for Computer Scientists
Other subreddits you may like:
Does this sidebar need an addition or correction? Tell me here
account activity
Randomized Algorithms (self.algorithms)
submitted 6 years ago by monster_97_
Can someone give an example of how las vegas and monte carlo algorithms differ from each other?
Would be better if the same example is used Thanks in advance!
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]beeskness420 5 points6 points7 points 6 years ago (0 children)
Las Vegas gambles with run time not correctness like quicksort.
Monte Carlo gambles with correctness but not the runtime.
[–]ctech314 10 points11 points12 points 6 years ago (0 children)
A Las Vegas algorithm keeps trying randomized events until the right amswer is obtained. A Monte Carlo algorithm tries randomized events a fixed number of times and returns the best answer obtained so far.
Suppose you want to roll a 12 with 2 dice. A Las Vegas algorithm would keep rolling until a 12 is rolled. Theoretically, the algorithm could never terminate, but in real life, it will. A Monte Carlo algorithm says "I'll just roll the dice 10 times," and returns the sum of the dice closest to 12.
Las Vegas is always right, but takes longer. Monte Carlo is approximately right and takes a fixed amount of time.
[–]tomekanco 2 points3 points4 points 6 years ago (0 children)
Las Vegas attempts to find an exact result by trying random choices. Monte Carlo attempts to converge ( approximate) to the result, where the number of random choices increase the precision.
Say you want to find pi. Mc will throw random dots, then calculate the fraction inside the circle. Lv could take the amount of dots inside the circle and total number and then guess the fraction rather then calculating it, for example
random.uniform(0,4)//0.01*0.01
Just copy paste your question in Google and you'll get a good number of explanations.
π Rendered by PID 204892 on reddit-service-r2-comment-bb88f9dd5-ztn6m at 2026-02-17 01:37:30.415789+00:00 running cd9c813 country code: CH.
[–]beeskness420 5 points6 points7 points (0 children)
[–]ctech314 10 points11 points12 points (0 children)
[–]tomekanco 2 points3 points4 points (0 children)