# Monte Carlo choice of sample size

If I have $U_1,U_2,... \sim i.i.d~~ \text{Uniform}(0,1)$, and $f(x) = \sqrt{1-x^2}$. Then, by the Strong Law of Large Numbers:

$$P \left( \bigg{\lvert} \frac{1}{n}\sum_{k=1}^nf(U_k)-\int_0^1f(x)dx \bigg{\rvert} \ge \epsilon \right)\le \frac{c^2}{n \epsilon^2}\\ \implies P \left( \bigg{\lvert} \frac{1}{n}\sum_{k=1}^n \sqrt{1-U_k^2}-\frac{\pi}{4} \bigg{\rvert} \ge \epsilon \right) \le \frac{1}{ \epsilon^2 n}$$

I am trying to solve the following question: How large must I choose n such that the error probability in the above equation does not exceed 0.001?

Does this mean I should set $\epsilon = 0.001$? I'm trying to solve this using R, I've coded the sum in the expression:

# 500 Samples from the U(0,1) Distribution
U<-runif(500,0,1)

# Cumulative Sum Vector
S <- cumsum(sqrt(1 - U^2))

# Averaging Each Element of S to get I
I<-S/(seq_along(S))


Not sure how to solve for n though.

• The natural interpretation is $\epsilon=10^{-3}$ with a "small" value for $1/\epsilon^2n$, e.g., $0.05$. Commented May 24, 2015 at 16:06
• @Xi'an $P \left( \bigg{\lvert} \frac{1}{n}\sum_{k=1}^n \sqrt{1-U_k^2}-\frac{\pi}{4} \bigg{\rvert} \ge 0.001 \right) \le \frac{1}{ (0.001)^2 n}$. How can I do this? Commented May 24, 2015 at 16:13
• By solving $10^6/n=0.05$... Commented May 24, 2015 at 16:16
• @Xi'an I'm not sure where the 0.05 comes from?.. Commented May 24, 2015 at 16:17
• @Xi'an or are you implying that the question is incomplete? Commented May 24, 2015 at 16:32