This module illustrates the Monte Carlo method for approximating the
integral of a function of one variable over a given interval. In the
Monte Carlo method for approximating an integral, the integrand
function is evaluated at n points randomly distributed in the
domain of integration. The average of the resulting function values
provides an estimate of the mean of the function, which is then
multiplied by the size of the domain (e.g., the length of the interval
of integration in one dimension) to estimate the integral. Because the
error in this approximation of the integral converges to zero rather
slowly, proportional to
The user first selects from a menu of integrand functions provided. The number of points at a time for which the integrand function will be evaluated can also be selected, if desired (1 is the default). The user then clicks Sample Function repeatedly to sample the integrand at an additional set of randomly chosen points. The sample points and corresponding sample function values are indicated in the graph, with the most recent samples drawn in a darker shade. Numerical values are printed below for the correct integral I, the cumulative number of samples N, and the current estimate of the integral Q along with its error. The error can be seen to converge very slowly to zero as the number of samples increases.
Reference: Michael T. Heath, Scientific Computing, An Introductory Survey, 2nd edition, McGraw-Hill, New York, 2002. See Section 8.4.4 and Chapter 13.
Developers: Evan VanderZee and Michael Heath