Monte-Carlo for Integrals

Let be a Random Variable with Uniform Distribution on and a continous function on , then we can calculate the intergral from to of that function using the Arithmetic Mean as a Standard Estimator:

This approach is quite effective for high-dimensional integrals.

x = runif(100000)
mean(sin(x)) - integrate(sin, 0, 1)[1]$value
# 0.00026...