Search code examples
algorithmmontecarlopi

Monte Carlo Estimation of $\pi$


When using the Monte Carlo method to estimate $\pi$, we would fit a unit circle into a square, such as: enter image description here

I am very confused with the following description for the above circle, which is extracted from https://www.geeksforgeeks.org/estimating-value-pi-using-monte-carlo/: enter image description here

Shouldn't the area of the square be $2^2$ since 0 to -1 is 1 and 0 to 1 is another 1? The same goes to the radius of the circle - isn't it $1$ instead of $\frac{1}{2}$?


Solution

  • It seems to be a mistake of the author. I am guessing that they hastily interpreted the image as a plot with the bottom left corner as (0,0) instead of (-1, -1). Another possibility is that the image changed without changing the description.

    But as Robert pointed out, you are right, but keep in mind that their calculation for the area of the square is also wrong.