Turn integration into averaging
Monte Carlo methods replace a difficult deterministic calculation by a random experiment. The key principle is simple: if $U_1,\dots,U_n$ are independent Uniform$(0,1)$ random variables, then
Approximate an integral on $[0,1]$
Estimator and standard error
Here $s_g$ is the sample standard deviation of $g(U_1),\dots,g(U_n)$.
Running estimate
The green horizontal line is the high-accuracy reference value computed by a deterministic grid.
Estimate $\pi$ from random points
Throw points uniformly in the unit square. The quarter circle $x^2+y^2\le1$ has area $\pi/4$.
Unit square experiment
Tail probability by simulation
Estimate $P(Z>a)$ for $Z\sim N(0,1)$. This is easy for moderate tails but inefficient for rare tails.
Indicator estimates
Each plotted point is a block estimate using a subset of the simulation.
Generate exponential samples from uniforms
If $U\sim\mathrm{Unif}(0,1)$, then $X=-\theta\log(1-U)$ has Exponential mean $\theta$.
Histogram and density
Rare normal tail $P(Z>a)$
Instead of sampling $Z\sim N(0,1)$ directly, sample $Y\sim N(a,1)$ and reweight.
Why the weight appears
Here $f$ is the $N(0,1)$ density and $q$ is the $N(a,1)$ proposal density.
Estimator comparison
Lower variability means a more stable estimate for the same sample size.
Self-check questions
Q1
Why does Monte Carlo integration work?
Q2
What happens to Monte Carlo standard error when $n$ is multiplied by 100?
Q3
What is the purpose of importance sampling?