Monte Carlo

Monte Carlo example: Compute $\pi$

One fourth of the unit circle (radius $r=1$) is $\mu = \pi r^2/4 = \pi/4$. $$ \pi = 4 \mu = \int_{[0,1]^2} \mathbf{1}_{x^2 + y^2 \leq 1}\mathrm{d} x\mathrm{d} y $$ Estimator is then $$ \hat{\pi} = \dfrac{4}{N} \sum_{i=1}^N \mathbf{1}_{U_x^2 + U_y^2 \leq 1} $$ with $U_x,U_y\sim \mathcal{U}([0,1])$