5.1 Simulation Determinatic Behaviour
5.1 Simulation Determinatic Behaviour
5.1 Simulation Determinatic Behaviour
In this section we illustrate the use of Monte Carlo simulation to model a deterministic
behavior, the area under a curve. We begin by nding an approximate value to the area under a
nonnegative curve. Speci cally, suppose y D f .x/ is some given continuous nfunction
satisfying 0 f .x/ M over the closed interval a x b. Here, the number M is simply some
constant that bounds the function. This situation is depicted in Figure 5.2. Notice that the area
we seek is wholly contained within the rectangular region of height M and length b a (the
length of the interval over which defined).
Now we select a point P .x; y/ at random from within the rectangular region. We will do
so by generating two random numbers, x and y, satisfying a x b and 0 y M , and interpreting
them as a point P with coordinates x and y. Once P .x; y/ is selected, we ask whether it lies
within the region below the curve. That is, does the y-coordinate satisfy 0 y f .x/? If the
answer is yes, then count the point P by adding 1 to some counter.
Two counters will be necessary: one to count the total points generated and a second to count
those points that lie below the curve (Figure 5.2). You can then calculate an approximate
value for the area under the curve by the following formula:
As discussed in the Introduction, the Monte Carlo technique is probabilistic and typically
requires a large number of trials before the deviation between the predicted and true values
becomes small. A discussion of the number of trials needed to ensure a predetermined level of
con dence in the nal estimate requires a background in statistics. However, as a general rule,
to double the accuracy of the result (i.e., to cut the expected error in half), about four times as
many experiments are necessary.
The following algorithm gives the sequence of calculations needed for a general com-puter
simulation of this Monte Carlo technique for nding the area under a curve
Table 5.1 gives the results of several different simulations to obtain the area beneath the
curve y D cos x over the interval =2 x =2, where 0 cos x < 2.
The actual area under the curve y D cos x over the given interval is 2 square units. Note
that even with the relatively large number of points generated, the error is signi cant. For
functions of one variable, the Monte Carlo technique is generally not competitive with
quadrature techniques that you will learn in numerical analysis. The lack of an error bound
and the dif culty in nding an upper bound M are disadvantages as well. Nevertheless, the
Monte Carlo technique can be extended to functions of several variables and becomes more
practical in that situation.
The methodology to approximate the volume is very similar to that of nding the area under a
curve. However, now we will use an approximation for the volume under the surface by the
following rule
Monte Carlo Volume Algorithm
STOP
The actual volume in the first octant is found to be approximately 0:5236 cubic units. =6/.
Generally, though not uniformly, the error becomes smaller as the number of points generated
increases.
PROBLEMS 5.1
Q W x2 C y2 D 1; x 0; y 0
where the quarter circle is taken to be inside the
square
SW0x 1 and 0 y 1
4. Use Monte Carlo simulation to approximate the area under the curve f .x/ D x, over the
interval 12 x 32 .
5. Find the area trapped between the two curves y D x2 and y D 6 x and the x- and y-axes.
6. Using Monte Carlo simulation, write an algorithm to calculate that part of the volume of
an ellipsoid
x2 C y2 C z2 16 2 4 8
z D 8 x2 y2 and z D x2 C 3y2
Note that the two paraboloids intersect on the elliptic cylinder
x2 C 2y2 D 4