Monte Carlo Approximation of Pi

Speed (iterations per frame): 1 10 100 1000 10000

Iterations (total dots): 0

Dots in Circle: 0

Approximation of Pi: 0

What is this?

This approxmiates π using a Monte Carlo method, which is an approach to computing things by statistics and random sampling.

How would we find π using statistics? Well, we can start from formulas using π. In this demo, we happen to use a circle, which has the simplest area formula involving π. Our plan is to drop dots in random positions on a square with an inscribed circle.

Somehow, we have to leverage the count of dots inside the circle compared to the number outside circle. We know this has something to do with probability, so let just use these three symbols to start with:

Now, rearranging the \( P(circle) \) formula in terms of π gives us \[ \pi = 4 P(circle) = 4 \lim_{total \to \infty} \frac{in \, circle}{total} \] This is exactly what this demo does, except we stop at 10,000,000 iterations.
Created by Jason Zhao on February 24, 2018.