How to find pi in randomness around you


Celebrate Pi Day and read all about how this number appears across maths and science our special Pi Day page.

Grab something circular, like a cup, measure the distance around the circle, and divide it by the distance across the widest part. What you get is a pretty good estimate of the irrational number pi (3.14159…). But you can also find pi in a series of random coin flips or a collection of needles thrown on a wooden floor. Sometimes the reason pi appears in randomly generated values ​​is obvious – if there are circles or angles involved, pi is your guy. But sometimes the circle is cleverly hidden, and sometimes the reason pi appears is a mathematical mystery!

To celebrate Pi Day this year, here are three ways to estimate pi using random chance that you can try at home. The last one, featuring coin flips, is brand new – published just in time for Pi Day.


On supporting science journalism

If you like this article, please consider supporting our award-winning journalism by subscribes. By purchasing a subscription, you help secure the future of impactful stories about the discoveries and ideas that shape our world today.


1. Circle in a square

Perhaps the simplest way to randomly estimate pi works like this: take a square with side length 2 and place a circle of radius 1 inside so that it just touches the edges of the square. Then generate random points in the grid. As you add more and more random points, the proportion of points that end up in the circle will approach π4— the ratio between the area of ​​the circle (pi) and the area of ​​the square (4).

The occurrence of pi here is not surprising—it comes directly from the formula for the area of ​​a circle—but the method is a classic example of a Monte Carlo simulation, where random data is used to approximate an exact calculation.

Graphic shows how a unit circle with a radius of 1 inside a 2 x 2 square containing 500 randomly generated points can be used to estimate the value of pi.

2. Buffon’s Noodle

Suppose I drop a bunch of needles on a wooden floor with lines one needle length apart. What proportion of the needles can I expect to cross the lines? This question was first asked by Georges-Louis Leclerc, Comte de Buffon (or Count of Buffon) in 1733, and the answer is 2π (approx 23).

To figure out why, we need to think about a more general question: What if our needle isn’t a straight line, but a ripple, a square, or some other line-drawn shape?

This extended version of the problem is sometimes called “Buffon’s noodles” because noodles come in many more shapes than needles. It turns out that no matter what shape the needle is bent to, we can still expect it to cross the same number of lines on average. The expected value of the number of lines crossed is proportional to the length of the needle. In other words, we can expect a collection of needles of length n (of any form) to cross n times as many lines as the same number of needles of length 1.

So to find the answer to Buffon’s question, all you have to do is choose a smart shape for your needles. This is where the circles come in. If you have lines one unit apart and a needle bent into a circle whose diameter is 1, it will always cross the lines exactly twice. The length of the needle making up the circle is pi, and so the probability of a needle of length 1 crossing a line will be the expected value of the number of times the circle crosses – 2 – divided by the length of the circular needle, which gives us 2π.

Graphic shows how a square overlaid with evenly spaced horizontal lines and 500 randomly spaced pins of the same length as the distance between the lines can be used to estimate the value of pi.

3. Flipping coins

Pick up a coin and flip it. Record heads or tails. Repeat until you have got one more head than tails, and record the proportion of heads in relation to total flips. For example, if your first flip was heads, stop right away and record 1. If you flip tails, heads, tails, heads, heads, stop and record ⅗. The expected value of the result, or the average of all your trials if you did infinitely many, is π4. The more trials you average, the closer you get π4.

This new method of estimating pi using coin flippers was introduced by James Propp, a mathematician at the University of Massachusetts Lowell, in a preprint posted online at ArXiv.org last month—just in time for Pi Day! While the math behind the method is nothing new, the idea of ​​using it to estimate pi with a coin flip is.

So why do we get π4? The unsatisfactory answer is that somewhere in the calculus of probability there is an infinite sum that happens to correspond to the values ​​of the arcsin function—a trigonometric function closely related to pi. But mathematicians have not found a meaningful connection between flipping coins and pi. “Sometimes something that is very fundamental has relevance to two totally disconnected branches of mathematics,” says Propp. “That’s one of the joys of mathematics, but in many ways it’s a mystery.”

Graphic shows how five sequences of coin flips can be used to estimate the value of pi.

Mathematician Stefan Gerhold of the Technical University of Vienna observed a very similar result, which he published as a preprint on arXiv.org in 2025. Instead of flipping a coin until you have more heads than tails, Gerhold and his co-author thought that families had children and stopped when they had one boy than one girl. “It’s very mysterious,” says Gerhold. “I don’t think that’s a good way to understand that (in this scenario) the expectation would involve pi.”

None of these methods are particularly practical for estimating pi’s value. To get pi to an accuracy of 3.14, Propp estimates it could take up to one trillion coin flips. This is partly because sequences of coin flips can become very long before heads overtake tails, so much so that the expected value of a sequence’s length is infinite! On top of that, you can’t flip all the coins at once the same way you can drop pins – the order of heads and tails matters. Therefore, Propp suggests trying it in a classroom, where many students can flip sequences of coins at the same time.

Jennifer Wilson, a mathematician at the New School who uses similar probability models to analyze voting methods, finds the result gratifying. “It’s nice because it’s certainly something you can try with any group of students, and all you need is a background in calculus to understand it.”

On your own, you may have been flipping coins for quite some time to get an accurate reading on pi. And even the other two methods may require around a million random points or pin drops to get 3.14 – but you may be luckier. This Pi Day, consider joining the tradition of finding the value of pi in wildly inefficient ways.

Add Comment