News for hackers. Stuff that matters.
Re:Pi from High School Maths by schoen on Tuesday February 09, 2021 @08:24PM (#26084788)
Another Monte Carlo angle:

  import random
  n=1000000
  print(4.*sum(random.random()**2 + random.random()**2 < 1 for i in range(n))/n)
Both this version and the Buffon's Needle version are a lot less efficient than the version in this article, because the article's version is making educated guesses about where the boundary is, while the randomized versions are making uneducated guesses. :-)

There are no comments on this comment yet.