next up previous
Next: Integration by Sampling the Up: monte Previous: monte

Integration by Sampling an Area

To simplify the discussion, consider integrating over a single variable. Suppose we want to integrate a function $y = f(x)$ over a finite interval $x \in [a,b]$.

\begin{displaymath}
I = \int_{a}^{b} f(x) dx
\end{displaymath} (1)

We can think of the problem as one of determining the area under a curve, as illustrated in Fig. 1. (If the function takes on negative values and it is bounded by $-C$ below, we integrate $f(x) + C$ and then subtract $C(b-a)$ from the result.)

One way to determine the area is simply to throw darts at the rectangle that bounds the area. If the darts are uniformly distributed across the bounding rectangle, the area is just the total area times the fraction of darts hitting the target. Suppose the function is bounded by $h$ above and 0 below. Then if a fraction $<p>$ of the darts hits the area in question, the integral is just

\begin{displaymath}
I = <p>A
\end{displaymath} (2)

where $A = h(b-a)$ is the area of the sampling region.

What is the error in this result? The process can be thought of a sampling problem with the objective of determining the probability $p$ of hitting the target. The sampling process produces a series of random values $p_{i}$ equal to zero if the target is missed and one if the target is hit. Thus with $N$ random samples we are estimating the mean value

\begin{displaymath}
<p> = \sum_{i=1}^{N} p_{i}/N.
\end{displaymath} (3)

For a large sample, the error in this estimate is approximately
\begin{displaymath}
\sigma_{p} = \sqrt{(<p^{2}> - <p>^{2})/N}
\end{displaymath} (4)

where
\begin{displaymath}
<p^{2}> = \sum_{i=1}^{N}p_{i}^{2} = \sum_{i=1}^{N}p_{i} = <p>.
\end{displaymath} (5)

(Here $p_{i}^{2} = p_{i}$ because $p_{i}$ is only zero or one.) Thus we have
\begin{displaymath}
I = A<p> \pm A\sqrt{<p>(1-<p>)/N}
\end{displaymath} (6)

and the error decreases as the square root of the sample size.
next up previous
Next: Integration by Sampling the Up: monte Previous: monte
Carleton DeTar
2002-04-03