Estimating π by throwing needles
Buffon's needle #
Discussion on X
The Buffon's Needle experiment is a cool Monte Carlo method to approximate π! 🪡
When you throw a needle of length onto a piece of ruled paper, it intersects the lines if , where 𝑥 is the distance from the bottom of the needle to the closest line above it.
Assuming that 𝑥 and 𝜃 are uniformly distributed, for an intersection, we require and . The probability of this is given by the integral:
We can estimate the probability of intersection via repeated random trials (needles intersecting line / needles thrown) and rearrange the equation to get a Monte Carlo approximation of π:
I've made a colab notebook where you can mess around with this simulation in an interactive way. Play with it here! => Interactive simulation