Example (Buffon's needle)

Question: drop a needle with length $l$ on a floor ruled with parallel lines with distance $L\geq l$ apart. What is the probability $p$ that the needle crosses one of the lines?

Model a needle by the distance $Y$ from the lowest point to the closest line above, and the angle $\Theta$ that the needle makes with a parallel line. Then it's reasonable to assume $Y\sim U[0,L]$ and $\Theta \sim U[0, \pi]$ are independent.

The needle cuts the line above iff $l\sin\Theta\geq Y$. $$ \begin{align*} p &= \int_{0}^{\pi} \int_{0}^{L} \frac{1}{\pi L} 1_{\set{l\sin \theta \geq y}}\, dy \, d\theta \\ &= \frac{1}{\pi L} \int_{0}^{\pi} l\sin\theta\, d\theta \\ &= \frac{2l}{\pi L} \end{align*} $$ This gives us a way to determine empiraclly $\pi = 2l/pL \equiv f(p)$.

Sample error

We acquire the proportion of $N$ needles that hits lines $\hat p_N \sim (1/N)B(N, p)$ to get $\hat \pi_N = f(\hat p_N)$.

For large $N$ we expect $\hat p_N$ to be close to $p$, so we approximate $$ \begin{align*} \hat \pi_N = f(\hat p_N) \approx f(p) + (\hat p_N - p)f'(p). \end{align*} $$ Then we get $$ \begin{align*} \var(\hat \pi_N) &\approx (f'(p))^2 \var(\hat p_N) \\ &= \left(-\frac{2l}{p^2 L}\right)^2 \frac{1}{N^2}Np(1-p) \\ &= \frac{\pi^2}{p^2}\frac{p(1-p)}{N} \\ &= \frac{\pi^2}{N} \frac{1-p}{p}. \end{align*} $$ To minimise the error, we want to minimise $\var(\hat \pi_N)$, so take $l$ to be maximum $l=L$. Then $$ \begin{align*} \var(\hat \pi_N) =\frac{\pi^2}{N}\left(\frac{\pi}{2} - 1\right). \end{align*} $$

Using Sample error via central limit theorem, to have 1/1000 accuracy of $\pi$ with probability 99%, $$ \begin{align*} N = \Phi\inv(0.995)(1000)^2 \pi^2\left(\frac{\pi}{2}-1\right) = 3.75\times 10^7. \end{align*} $$