The sample mean random variable of $N$ IID random variables with $X_i$ ~ $U(0, 1)$ will converge to 1/2. How many random variables need to be averaged before we can assert that the approximate probability of an error of not more than 0.01 in magnitude is 0.99?
I setup the problem by using the weak law of large numbers like so: $$ \sigma = \frac{1}{12} \space \mu=\frac{1}{2} $$ $$ P[|S_N-1/2|<0.01] = 1-\frac{(\frac{1}{12})^2}{N(0.01)^2}=0.99 $$ Solving for $N$, I get $6945$ but apparently the answer is supposed to be $5529$. What am I doing wrong?
The sample mean $$\bar X = \frac{1}{n} \sum_{i=1}^n X_i$$ is approximately normally distributed with mean $\mu = 1/2$, and variance $$\sigma^2 = \frac{\operatorname{Var}[X_i]}{n} = \frac{1}{12n}.$$ Therefore, the criterion we must use is $$0.99 \le \Pr\left[-0.01 \le \bar X - \mu \le 0.01\right].$$ But since $$\frac{\bar X - \mu}{\sigma}$$ is a standard normal random variable with mean $0$ and variance $1$, we have $$0.99 \le \Pr\left[ -\frac{\sqrt{12n}}{100} \le Z \le \frac{\sqrt{12n}}{100}\right] = 1 - 2 \Phi\left(-\frac{\sqrt{12n}}{100}\right)$$ where $\Phi$ is the cumulative distribution function for a standard normal variable. This leads to the equation $$n \ge \frac{2500}{3} \left(\Phi^{-1}(1/200)\right)^2.$$ When we look up the quantile function, we have $$\Phi^{-1}(1/200) \approx -2.57583,$$ which gives us $n \ge 5529.08$.
Bearing in mind that this is an approximation since the exact distribution of $\bar X$ is a Bates distribution, it is important to note that the large sample size $n$ means that the approximation is fairly precise. Usually, we would round up the sample size $n$ even though $5529.08$ is closer to $5529$ than to $5530$. However, an exact calculation yields the following table:
$$\begin{array}{c|c} n & \Pr[|\bar X - 1/2| \le 1/100] \\ \hline 5528 & 0.98999516849251412362\ldots \\ 5529 & 0.99000190666215766225\ldots \\ 5530 & 0.99000864018063913425\ldots \end{array}$$
which shows that $n = 5529$ is the correct answer.
The above calculation may be performed using a computer via the formula
$$\Pr[|\bar X - 1/2| \le 1/100] = 2 F(n, \tfrac{51}{100} n) - 1$$ where $$F(n,x) = \frac{1}{n!} \sum_{k=0}^{\lfloor x \rfloor} (-1)^k \binom{n}{k} (x-k)^n.$$