Claire
Claire

Reputation: 167

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}$?

Upvotes: 0

Views: 251

Answers (2)

Alireza Azimi
Alireza Azimi

Reputation: 152

Objectively speaking you are right. The radius of the circle is of length 1 and each side of the square is of length 2. I think the image is not scaled properly. The moral of the story is having this relationship between the areas:

Area_of_circle/Area_of_square = pi/4

Also I'd recommend taking a look at the on policy monte carlo control, found in Rich Sutton's Reinforcement Learning book:

enter image description here

this nicely generalized the algorithm for estimating the optimal policy using an epsilon soft policy to select the greedy action.

Upvotes: 1

Alex Rouault
Alex Rouault

Reputation: 36

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.

Upvotes: 2

Related Questions