I'm writing a quick Monte-Carlo simulation for a class in Matlab in order to estimate the value of pi as demonstrated in this gif:
http://en.wikipedia.org/wiki/File:Pi_30K.gif
However, I'm not sure how I should define points that happen to be randomly placed exactly on the boundary (r = 1). Should I count these as inside the circle, thus contributing to its area, or should they be counted as outside? Or should I avoid counting such points altogether and cause the loop to do nothing on those iterations?
I'm curious about whether this is a problem that has reached consensus in the math community; perhaps it's just a limitation of a discrete computation. I also apologize if this has been asked before. I did a lot of searching and found nothing. Thank you.
If you were actually generating random real numbers, the probability of any of those falling exactly on the circle line (a set of measure zero) would be zero and thus by the law of large numbers not alter the outcome of the Monte Carlo simulation as the number of points goes to infinity, independent of whether you count those points as "inside", "outside", or discard them altogether.
With floating point arithmetic, things are much more difficult to formalize as here there might be a positive probability of points landing on the perimeter. Indeed, for a concrete implementation of machine arithmetic, the question has to be asked whether the Monte Carlo method will even converge to $\pi$ almost surely as desired, or instead to $\pi+\delta$ for some $\delta$ imposed by the discretization (the numbers drawn aren't fully uniform, after all, if they have limited precision).
For a practical approach, you can avoid the theoretical problem by imagining that you are really simulating a circle of radius $1+\epsilon$. It is then clear that points at distance $1$ should be taken as having fallen inside the circle, yet you can choose $\epsilon$ as small as you want, including smaller than your machine precision. A rigorous analysis of the question depends on the approximation of the real numbers your computing environment provides, and is likely irrelevant if you are already assuming that in that environment, the Monte Carlo methods works in principle.