Suppose we have two arbitrary regions, and , with contained within . Since the number of randomly chosen points within a region is approximately proportional to its area, select at random points within , and let represents the number of points that fall inside , we have
This expression suggests that the ratio of points falling in to the total points in approximates the ratio of their areas.
Let be a unit square and a quarter of the unit circle:
Fig. 1
By (1),
Therefore,
We have implemented a program to compute an estimate of (see Fig. 2). The program generates a series of pairs where each pair represents a point within the unit square. We count the number of points for which , corresponding to points that fall within the quarter of circle. By varying the sample size , we estimate according to (2). Notably, as the sample size increases, the accuracy of the estimate improves.
Fig. 2