|
Algorithm 1 Monte Carlo Approximation of Double Integral |
|
Input: N: the total number of trials in Monte Carlo estimation.
Output: The approximation result of the predefined double integral .
-
1:
▹ for counting the number of points inside the valid x–y region.
-
2:
▹ for summing up individual evaluations of .
-
3:
a random number between a and b
-
4:
a random number between and ,
-
5:
for
do
-
6:
if
and
then ▹ If the random point is located inside the valid x–y region.
-
7:
-
8:
-
9:
end if
-
10:
end for
-
11:
area, ▹ Estimating the area of the valid x–y region.
-
12:
▹ Note that the function was evaluated valid_points times.
-
13:
returnvolume ▹ The estimated volume as the double integral result.
|