Numerical Integration
The MC method for computing the area under a curve (continuous), y =
f(x) from x = a to x = b is described as below:
For every run of the simulation:
{
1)
Step 1: Randomly generate real numbers in the interval of [a, b]
2)
Step 2: Compute the values of y for the values of x generated by Step 1
3)
Step 3 : Add all the values that were computed in Step 2
}
Step 4: Compute the average
value of y by dividing the sum computed in Step 3 with the total number of
runs.
Step 5: The area under the curve
= Value computed in Step 4 * (b – a)
Compute the area under the curve of √sin(x) using the MC method
(see example below).
Example:
Monte Carlo - Area under a Curve
Input number of runs
100000
Input start of the interval - a
2
Input end of the interval - b
3.14
Area under the curve from 2.0 to 3.14 is = 0.7768