Simulation Lab Report 9
Simulation Lab Report 9
Grade:
ABSTRACT
In this lab we will perform Monte Carlo simulation and will find the value of Pi and area under
the curve.
Objective of lab:
Objective of lab is to perform Monte Carlo Simulation
Objective significance:
Monte Carlo simulation (also known as the Monte Carlo Method) lets you see all the possible
outcomes of your decisions and assess the impact of risk, allowing for better decision making
under uncertainty
Objectives
Consider a circle inscribed in a unit square. Given that the circle and the square have a ratio of
areas that is /4, the value of can be approximated using a Monte Carlo method:[2]
1.
2.
3.
4.
In this procedure the domain of inputs is the square that circumscribes our circle. We generate
random inputs by scattering grains over the square then perform a computation on each input (test
whether it falls within the circle). Finally, we aggregate the results to obtain our final result, the
approximation of .
When writing the program by following Monte Carlo method having:
1. Domain: Set of real numbers .
2. Probability distribution: Uniform probability distribution
3. Perform a deterministic computation on the inputs: by using equation of square x2+y2=r2
If x2+y2<r2 count the random numbers they are inside the circle else do not count.
4. Aggregate the results: divide the all counts from total and multiply the results from 4.
Functions
1. Area under the curve
function area = AreaUnderTheCurve(a,b,m,n)
%UNTITLED3 Summary of this function goes here
% Detailed explanation goes here
count = 0;
for i=1:n
x(i)=a+(rand()*(b-a));
y(i)=m*rand();
if(y(i)<=x(i)^2)
count= count+1;
else
continue;
end
end
area = (m(b-a))*(count/n);
end
2. Approximating value of PI
function piVal = FindPi(n)
%UNTITLED Summary of this function goes here
% Detailed explanation goes here
count = 0;
for i=1:n
x(i)=rand();
y(i)=rand();
if(((x(i)*x(i)) + (y(i)*y(i))) < 1)
count= count+1;
else
continue;
end
end
piVal = (count/n)*4;
end
Conclusion
Monte Carlo simulation (also known as the Monte Carlo Method) lets you see all the possible
outcomes of your decisions and assess the impact of risk, allowing for better decision making
under uncertainty and by using Monte Carlo Simulation we can estimate any given measure
which is difficult to calculate through a defined mathematical model. By using Monte Carlo
method we can find the values under high uncertainty by doing hit and trial.
References
[1] http://www.investopedia.com/terms/m/montecarlosimulation.asp#ixzz3XU3Wt3LE
[2] http://en.wikipedia.org/wiki/Monte_Carlo_method