Algorithm Monte Carlo Integration Given a sample , we gan approximate the theoretical mean by the sample mean to give:

Thrm By Monte Carlo Integration, we can derive the following approximation formulas: e.g. , thus we can estimate the integral by the following R code:

u=runif(5000)
mean(2*exp(4*u^2))