Pi estimation:

Actual value of pi:

Standard error:

Points in Square:

Points in Circle:

How does it work?

Consider the image of the circle inscribed in the square shown on the right. The area of the circle is:

\(A^{\circ} = \pi r^2\)

Note that one side of the square is equal to the diameter of the circle, which is \(2r\). Therefore, the area of the square is:

\(A^{\square} = (2r)^2 = 4r^2\)

If we randomly generate points inside the square, the probability of a point being inside the circle is equal to the ratio of the area of the circle to the area of the square:

\(\frac{A^{\circ}}{A^{\square}} = \frac{\pi r^2}{4r^2} = \frac{\pi}{4} \approx \frac{\text{points in circle}}{\text{points in square}}\)

Therefore, we can estimate pi with the following formula:

\(\pi \approx 4 \cdot \frac{\text{points in circle}}{\text{total points}}\)

Why is this important?

This is not about the end result, but rather the process. This is a great example of how we can use randomness to calculate non-random values. This method is called Monte Carlo integration, and it is used in many fields, such as physics, finance, and machine learning. It is so widely used because it generalizes to higher dimensions, meaning that we can use this method to estimate hyper-volumes of higher dimensional shapes. Using traditional methods, this would be very difficult to do.

Speed: