Suppose that darts are thrown at a rectangle containing the graph of a function. Some
of the darts will hit inside the area under the graph and some will hit in the area above
the graph. Count the number that hit inside the area under the graph, then calculate
the percentage that hit the area under the graph vs the total number of darts thrown.
Multiplying this percentage times the area of the rectangle yields an estimate of the
area under the graph and thus an estimate of the value of the integral.
Throwing darts at a rectangular area can be simulated using random numbers from
a uniform distribution
1
to generate the random x and y values for a point inside the
rectangle. The x, y values for points inside the rectangle with width w and height h are
generated as follows:
Given r1 and r2, uniformly distributed random numbers between 0 and 1, and a equal
to the left-hand x coordinate of the rectangle, x = a + r1 × w and y = r2 × h.
2.1 ”Hit or Miss” Monte Carlo Integration with TI-Nspire
Key observations for performing ”hit or miss” integration with TI-Nspire are:
1. The TI-Nspire function rand() generates uniformly distributed random num-
bers between 0 and 1.
2. The width of the rectangle is b − a, where a,b are the lower and upper bounds of
the integral.
3. The height of the rectangle is the maximum value of the integrand in the interval
[a, b]. For f (x) and f (x, y), this can be determined graphically or using calcu-
lus. For functions with more than 2 variables, calculus techniques are generally
required.
4. To determine if the random point (rx,ry) is under the graph of the integrand f (x),
compare ry and f (rx). If ry < f (rx), then the point (rx, ry) is under the graph of
the integrand.
5. To obtain one estimate of the value of the integral of f (x) over the interval [a, b]
given n total random points in the rectangle containing the graph of f (x) and u
random points under the graph of f (x), calculate the percentage of points under
the curve, then multiply the area of the rectangle by the percentage: estimate =
u
n
× w × h.
To determine a confidence interval for the approximation:
1. Create a list to store nvals results, where nvals is greater than 30.
2. In a loop, execute one of the functions described below and store the result in the
list.
1
For a uniform distribution, the probability of picking any value k from an interval [a,b] is the same for
all values k1, k2, ..., kn in the interval.
3