Estimating the value of $\pi$ with a Monte Carlo dartboard: $<$ or $\leq$?
I'm trying to figure out which is the proper way to estimate $\pi$ using the Monte Carlo method randomly distributing points in a square that also contains an inscribed circle.
Some sources say to use the comparison of $\sqrt{x^2+y^2}\le 1$, while others use $\sqrt{x^2+y^2}1$.
Here's some example code from a wikipedia article:
def monte_carlo_pi(nsamples):
acc = 0
for i in range(nsamples):
x = random.random()
y = random.random()
if (x**2 + y**2) 1.0:
acc += 1
return 4.0 * acc / nsamples
Instead of posting a long list of websites that use $\le 1$ or $ 1$, I've made the list and stored it on the following websites:
See either: socrates.io or markdown.press or markdownshare for examples using less than
and less than or equal to
.
Topic mathematics monte-carlo simulation
Category Data Science