can you guess the value π?

The word “guess” is loosely used here.

Can we determine the value of π by generating random number?

As of 2024 humans have calculated 105 trillion digits of π. It feels like a stretch of imagination to think we could get even a fair approximation using only random numbers.

But consider this: if we generate random points inside a square, and check how many fall inside an inscribed quarter circle, we can estimate π.

Explanation: The probability of such randomly generated points to fall within the blue coloured quarter circle is

P(A) = \frac{\text{Area of Quarter Circle}}{\text{Area of Square}}
P(A) = \frac{\tfrac{1}{4}\pi r^2}{r^2} = \frac{\pi}{4}

So if you have a large enough sample of points

\pi = 4 \cdot P(A)

or

\pi = \lim_{N_{\text{total}} \to \infty} 4 \cdot \frac{N_{\text{inside}}}{N_{\text{total}}}

So next time you see π, remember — even randomness, given patience, knows its way home.

Note
• Using randomness to solve deterministic problems is called the Monte Carlo method.
• Demo created with AI tools — the code could use some polishing.
• The simulation speed is deliberately slowed down for effect. Left to the computer’s clock speed, it would approximate π to practical accuracy within seconds.
• Computers don’t generate true randomness — only pseudo-random numbers.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.