Monte Carlo integration can be used to estimate definite integrals that cannot be easily solved by analytical methods. There are several methods to apply Monte Carlo integration for finding integrals. In this article we will cover the basic or ordinary method.

## Basic Monte Carlo Integration

Let's start with a generic single integral where we want to integrate f(x) from 0 to 3.

With basic Monte Carlo integration, the task is to find the mean value of f(x) over the integration interval. In this case, we need to find the mean of f(x) from 0 to 3. The mean is found using brute force. Random numbers from 0 to 3 are generated and plugged into f(x). This is repeated thousands of times and the mean of all these iterations is calculated.

For our generic function, consider if we randomly picked five values of x and found the mean f(x) for these five points. Would that be a good approximation of the mean? What if we used 10,000 points? We'd get a better approximation, but depending on the function, probably not enough points.

It turns out that the estimation error goes to 0 as iterations goes to infinity. It's not a linear relationship however, and there are diminishing returns with higher iterations. There is a more in-depth discussion of error in the Simulation Master integration tool tutorial.

Now let's assume we've simulated the function, and have an estimate of the mean.

For our generic example, it boils down to simply finding the area of the rectangle that is mean high and interval wide. This can be stated in terms of the integral, where a = 0 and b = 3.

Now let's extend this to a higher dimension integral. Consider the triple integral of f(x,y,z). It's evaluated by multiplying the mean by each variable's interval.

## A Multi-Dimensional Example

We will estimate a triple integral with a known answer to illustrate how to perform a Monte Carlo integration using Simulation Master. We have the following triple integral (the answer determined analytically is 6)*.

A spreadsheet is created to generate uniformly distributed random values in the ranges for each variable. The function value is calculated as the output cell and we simulate this for the desired number of iterations.

With the spreadsheet set up, we can simulate it for 250,000 iterations.

The estimated value of the integral is 6.019 versus 6 for the analytic solution. The software found the mean of f(x,y,z) over the intervals of x, y, and z. It then uses the formula below to calculate the estimate.

The Monte Carlo integration was performed using Simulation Master's integration tool. For more information, visit the Simulation Master product page. To learn more about the integration tool, visit the integration tool tutorial.

*This problem is from Calculus and Analytic Geometry, 1983, Faires and Faires, PWS Publishers, pages 888-889.

Excel is a registered trademark of Microsoft Corporation. Used with permission from Microsoft.