Monte Carlo Estimation of Pi
A classic illustration of the Monte Carlo method is estimating the value of \(\pi\). By inscribing a circle of radius \(r\) within a square of side length \(2r\), the ratio of their areas is \(\frac{\pi r^2}{(2r)^2} = \frac{\pi}{4}\). Randomly scattering points within the square and counting the fraction \(p\) that fall inside the circle provides an estimate: \(\pi \approx 4p\).
The procedure for estimating \(\pi\) is straightforward and highlights the core Monte Carlo principle. Consider a unit square in the Cartesian plane with vertices at (0,0), (1,0), (1,1), and (0,1). A quarter circle of radius 1 is inscribed within this square, centered at the origin. The area of the square is 1, and the area of the quarter circle is \(\frac{\pi(1)^2}{4} = \frac{\pi}{4}\). The ratio of the quarter circle’s area to the square’s area is therefore \(\frac{\pi}{4}\).
To estimate this ratio, we generate a large number, \(N\), of random points \((x, y)\) where both \(x\) and \(y\) are uniformly distributed between 0 and 1. Each point has an equal chance of landing anywhere within the square. A point \((x, y)\) falls inside the quarter circle if its distance from the origin is less than or equal to 1, which is determined by the condition \(x^2 + y^2 \le 1\). We count the number of points, \(M\), that satisfy this condition. The ratio \(\frac{M}{N}\) is an estimate of the ratio of the areas, \(\frac{\pi}{4}\). Therefore, we can approximate \(\pi\) as \(\pi \approx 4 \frac{M}{N}\). According to the law of large numbers, as \(N\) approaches infinity, this approximation converges to the true value of \(\pi\). However, the convergence is slow, with the error decreasing proportionally to \(\frac{1}{\sqrt{N}}\), making it a very inefficient method for calculating \(\pi\) to high precision compared to deterministic algorithms.
UNESCO Nomenclature: 1202
– Computer sciences
Precursors
- concept of pi as the ratio of a circle’s circumference to its diameter
- cartesian coordinate system
- pythagorean theorem
- uniform probability distribution
- development of pseudo-random number generators
Applications
- pedagogical tool for teaching probability and simulation
- simple benchmark for random number generators
- introductory problem in computational science courses
Potential Innovations Ideas
Due to scrapping bot traffic, currently more than 40k per day, this content is reserved to community members.
> Login < or > Register < (100% free) to access this, so as all other restricted content and tools.
Related to: pi, estimation, Monte Carlo, simulation, random numbers, area, probability, numerical integration, circle, square.