php-estimatepi
This example shows how to estimate pi, using generated random numbers that uniformly distributed.
Every pair of numbers produced will be in the red area below.
Some of them will be outside the circle and some of them will be inside the circle.
Area of Circle: πr^2
Area of Square: 2r^2
So;
πr^2 / (2r)^2 = number of point in the circle / number of point in total
after mathematical simplifications;