So I'm reading about monte carlo simulation and stumbled upon a way to simulate $\int_0^{\pi}\sin(x)dx$: Generate independent standard uniforms $U^1$ and $U^2$ and find the proportion of pairs such that $\sin(\pi U^1)>U^2$ and multiply by $\pi$. It is then stated that it will converge to $\int_0^{\pi}\sin(x)dx=2$. However how would one prove that? Do we want to show that $N^{-1} \pi\sum_{i=1}^N1_{(\sin(\pi U^1_i)>U_i^2)}\to 2$ almost surely? If so I guess we can say that $1_{(\sin(\pi U^1_i)>U^2_i)}$ is Bernoulli with success probability $p=\mathbb{P}(\sin(\pi U^1_i)>U^2_i)$. However I'm not sure how to continue.
2026-03-30 12:57:06.1774875426
On
Estimate $\int_0^{\pi}\sin(x)dx$ using monte carlo
363 Views Asked by user927220 https://math.techqa.club/user/user927220/detail At
2
There are 2 best solutions below
0
On
As you pointed out, the result follows from the law of large numbers. For $p$ (in the OP's notation), suppose $U$ and $V$ are independent uniform $0-1$ distributed random variables. An application of Fubini's theorem gives $$\begin{align} \pi\mathbb{P}[\sin(\pi U)>V]&=\pi\int_{[0,1\times[0,1]}\mathbb{1}_{\sin(\pi u)>v}(u,v)\,dudv\\ &=\pi\int^1_0\Big(\int^{\sin \pi u}_0\,dv\Big)\,du\\ &=\pi\int^1_0\sin\pi u\,du=\int^\pi_0\sin x\,dx \end{align}$$
Hint: Let $X_i$ be the indicator variable of the event that the point falls inside the region. Let $Z_i = \frac{\pi}{N} \sum_i X_i$. Compute the expectation and variance of $Z_i$ and use the law of large numbers.