What is this?
This is a simple estimator for π using randomness! It is possible to approximate π with random number generation and simple shapes, to accuracy scaling with the amount of pointsn
set.
How does this work?
Consider a box with sides of length 2 (unitless), and a unit circle (radius of 1) inside of the box such that the edges of the circle touch the inside edges of the box. We then randomly placen
points inside of this box, and count the amount of points inside of the circle. We do this
using the condition x**2 + y**2 < 1
as our circle has radius 1. The points that satisfy this condition
will, as n->inf
, draw out our circle.
If we think about the areas of our two shapes we have
(2r)**2
for the box, and π r**2
for the circle. Taking the ratio of these leaves us with π / 4
; we can treat each random point as area-like (we are taking ratio
so any consequences are lost), and do this ratio as such: n_circle / n_total
giving us π / 4
.