I am currently playing around with the Monte Carlo method of finding $\pi$. The idea is pretty simple, I work with a unit square of length one on each side, with the coordinates of

$(0,0) , (1,0), (0,1), (1,1)$.

Then, I draw on a quarter-circle of radius 1 onto the unit square. It looks something like:

enter image description here

Now all there is to do is to generate a ton of random points within this area and then count the number of points hitting the violet region and divide by total number of points we threw. This will lead us to get closer and closer to $\pi/4$, and so all we have to do to find $\pi$ is to multiply by 4.

Now this is done very nicely on the computer and by increasing the number of random points, one can see the estimate for $\pi$ get tighter and closer to the real value for $\pi$.

However, is there a way we can mathematically prove that the values and variance of the estimate of $\pi$ does indeed get closer and smaller? I have tried but cannot exactly figure out what is wrong below:

I first say that I will be working with $n$ such samples and that we will random and uniformly take a value from the x-axis, and then one from the y-axis. Then, we define a random variable for each random point that adds one for hitting the violet region, and 0 from hitting the white area:

$ b_k = \left\{ \begin{array}{l l} 1 & \quad \text{if} \sqrt{x_{k}^2 + y_{k}^2} \leq 1\\ 0 & \quad \text{otherwise} \end{array} \right.$

Then, I have the expected value of the sum of $n$ of these random variables as:

$E(\sum\limits_{i=1}^n b_k) = \sum\limits_{i=1}^n E(b_k) = n \times \frac{\pi}{4}$

Now, as I try to find the variance, this is where things get tricky for me:

$Var(\sum\limits_{i=1}^n b_k) = \sum\limits_{i=1}^n Var(b_k) = n \times p \times (1-p)$.

This is because each can be thought of as a Bernoulli random variable.

Now, this is very weird because I expected the variance to decrease with $n$ but here it increases. Is there something wrong here? Thanks!

  • 1
    $\begingroup$ usually you look at average of points to find estimate, $\frac{1}{n}\sum_{i=1}^n b_k$ with this the variance $\left(\frac{p(1-p)}{n}\right)$ decreases as you sample size increases $\endgroup$
    – Kamster
    Commented Oct 8, 2014 at 5:09
  • 1
    $\begingroup$ and no you did calculate variance correctly for $\sum_{i=1}^n b_k$ $\endgroup$
    – Kamster
    Commented Oct 8, 2014 at 5:11
  • 1
    $\begingroup$ Try using mean instead of sum. $\endgroup$ Commented Oct 8, 2014 at 5:13
  • $\begingroup$ I’m voting to close this question because OP has abandoned it $\endgroup$
    – Snoop
    Commented Oct 14, 2022 at 22:41

1 Answer 1


The answer is given in the comments but let me write it more clearly.

What you are interested in is in fact $\hat{b}_n \triangleq \frac1{n} \sum_{i=1}^n b_i$ instead of $ \sum_{i=1}^n b_i$. (there is a typo in your notation, it shouldn't be $b_k$).

With this definition, we have the following: \begin{align} \mathbb{E}[\hat{b}_n] = \frac1{n} \sum_{i=1}^n \mathbb{E}[ b_i] = \frac{\pi}{4}. \end{align} Then, we consider the variance of $\hat{b}_n$: \begin{align} \mathbb{V}[\hat{b}_n] = \frac1{n^2} \sum_{i=1}^n \mathbb{V}[b_i] = \frac1{n} \mathbb{V}[b_1] . \end{align} Let's now denote $\sigma^2 \triangleq \mathbb{V}[b_1] < \infty$ (I didn't check your derivation, but we know that it's finite anyways). We finally have \begin{align} \lim_{n \rightarrow \infty}\mathbb{V}[\hat{b}_n] = 0. \end{align}
This should be the answer that you are looking for.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .