I have the following problem:
For the classical technique for estimating $\pi$ by using the Monte Carlo method, find the minimum number of points $n$, such that (being $\hat{p}$ our estimator) we get $\dfrac{|\hat{p} - \pi|}{\pi} < 0.0005$.
I have already made some simulations, trying to estimate the value of the minimum value of $n$ by estimating the standard deviation of $\hat{p}$. But actually the right method is by proving mathematicaly, so I tried the following. Considering $\pi/4$ as being approximately a proportion, lets call it $p$. I will try to find the $n$ that gives me $\dfrac{|\hat{p} - \pi|}{\pi} < 0.0005$ with a $95\%$ probability: $$ P\left( \frac{|\hat{p} - p|}{p} < 0.0005 \right) = 0.95 \Leftrightarrow P\left( \frac{-0.0005p}{\sqrt{\frac{p(1-p)}{n}}} < \frac{\hat{p} - p}{\sqrt{\frac{p(1-p)}{n}}} < \frac{0.0005p}{\sqrt{\frac{p(1-p)}{n}}} \right) = 0.95 \Leftrightarrow\ \Leftrightarrow P\left( \frac{-0.0005p}{\sqrt{\frac{p(1-p)}{n}}} < Z < \frac{0.0005p}{\sqrt{\frac{p(1-p)}{n}}} \right) = 0.95 $$ By the fact that $Z \sim N(0,1)$, I get: $$ \frac{0.0005p}{\sqrt{\frac{p(1-p)}{n}}} = 1.96 \Leftrightarrow n = \frac{1.96^2\frac{1-p}{p}} {0.0005^2} $$ Considering that I did not missed anything or calculated something wrong in the step above, I could find $n$ by a iterative method, using $p = \hat{p}_0$, were $\hat{p}_0$ is the estimate proportion for a first given $n = n_0$, and then compute $n_k$ with: $$ n_k = \frac{1.96^2\frac{1-\hat{p}_{k-1}}{\hat{p}_{k-1}} }{0.0005^2} $$ Where $\hat{p}_{k-1}$ is calculated using $n = n_{k-1}$. But I don't know... Is this a sufficient demonstration? Am I in the wrong direction?
NOTES:
- I the division I've done in the inequality is to normalize $\hat{p}$, considering it as an esimator for $\pi/4$, since $E[\hat{p}] = p$ and $sd(\hat{p}) = \sqrt{p(1-p)/n}$.
- The Monte Carlo method for estimating $\pi$ can be found, pretty straight forward, in this link.
- I can't use the real value of $\pi$, it is considered "cheating".
I don't understand why you resort to an iterative approach when you already defined $p = \pi/4$. This immediately gives you $$n \ge \frac{1.96^2 \frac{1 - \pi/4}{\pi/4}}{0.0005^2} \approx 4.19855 \times 10^6.$$