Without any fancy formulas, it is possible to estimate Pi using random numbers.
We can use the Monte Carlo method to estimate Pi. The idea is to generate random X and Y coordinates and see how many of them fall inside the unit circle.
The probability of a point falling inside the unit circle is equal to the area of the circle divided by the area of the square. The area of the circle is Pi * r^2, and the area of the square is (2r)^2. So the probability is Pi/4.
After generating a bunch of random points, we can estimate Pi by dividing the number of points that fall inside the circle by the total number of points multiplied by 4.
Here’s a demonstration of the Monte Carlo method in action:
See, eventually, the points will start to form a circle. The more points you generate, the more accurate the estimate of Pi will be.
Citation
If you find this work useful, please cite it as:
@article{yaltirakliwikiestimatingpiwithrandomnumbers,
title = "Estimating Pi with Random Numbers",
author = "Yaltirakli, Gokberk",
journal = "gkbrk.com",
year = "2024",
url = "https://www.gkbrk.com/wiki/estimating-pi-with-random-numbers/"
}
Not using BibTeX? Click here for more citation styles.
IEEE Citation Gokberk Yaltirakli, "Estimating Pi with Random Numbers", October, 2024. [Online]. Available: https://www.gkbrk.com/wiki/estimating-pi-with-random-numbers/. [Accessed Oct. 10, 2024].
APA Style Yaltirakli, G. (2024, October 10). Estimating Pi with Random Numbers. https://www.gkbrk.com/wiki/estimating-pi-with-random-numbers/
Bluebook Style Gokberk Yaltirakli, Estimating Pi with Random Numbers, GKBRK.COM (Oct. 10, 2024), https://www.gkbrk.com/wiki/estimating-pi-with-random-numbers/