Approximation of a definite integral using random numbers

definite integralsmonte carlo

I've read in my textbook that the Monte Carlo method (or random numbers) can be used to approximate a definite integral. If we select the first $n$ elements $x_1, x_2, \ldots, x_n$ from a random sequence in the interval $(0,1)$, then

$$\int_0^1{f(x)dx}\approx\frac{1}{n}\sum^n_{i=1}f(x_i)$$

Here, the integral is approximated by the average of $n$ numbers $f(x_1), f(x_2), \ldots, f(x_n)$.

However, I don't exactly understand this. What I remember from my Calculus course is that the definite integral of a function is basically the area below the function. On the left-hand side, however, I see we're calculating the average of the evaluations of the function. We're summing up all the evaluations and then divide by $n$. How does this compare to the actual area under the function?

Any hints?

Best Answer

The average of a function on an interval $[a,b]$ is $$\frac{1}{b-a} \int_a^b f(x) \ dx$$

but here $b-a=1$. So $ \int_0^1 f(x) \ dx$ is indeed the average of $f$ on $[0,1]$.

Related Question