A Term Paper On Monte Carlo Analysis / Simulation
A Term Paper On Monte Carlo Analysis / Simulation
A Term Paper On Monte Carlo Analysis / Simulation
WRITTEN BY
ADEKITAN ADERIBIGBE
FACULTY OF TECHNOLOGY
UNIVERSITY OF IBADAN
SEPTEMBER 2014
1.0 INTRODUCTION
Monte Carlo (MC) approach to analysis was developed in the 1940's, it is a computer based
analytical method which employs statistical sampling techniques for obtaining a probabilistic
approximation to the solution of a mathematical equation or model by utilizing sequences of random
numbers as inputs into a model which yields results that are indications of the performance of the
developed model.
Monte Carlo simulation was developed as part of the atomic program. Scientist at the Los Alamos
National Laboratory originally used it to model the random diffusion of neutrons. The scientist who
developed this simulation technique gave it the name Monte Carlo after the city in Monaco and its
many casinos. Monte Carlo simulation are used in a wide array of applications, including physics,
finance, and system reliability
Monte Carlo analysis utilizes statistical tools to mathematically model a real life system or process
and then it estimates the probability of obtaining a successful outcome. The statistical distribution of
the process to be modeled must be determined first before Monte Carlo simulation can be applied.
Monte Carlo entails using random numbers as a tool to compute something that is not random. MC
simulation is a versatile tool to analyze and evaluate complex measurements using a model of a
system, and to experiment with the model towards drawing inferences of the systems behavior.
1
ATTRIBUTES OF MONTE CARLO SIMULATION
There is no single Monte Carlo methodthe term covers a wide range of approaches to simulation.
However, these approaches use a certain pattern in which:
1. A domain of possible inputs is defined;
2. Inputs are randomly generated from the domain;
3. Using the inputs, a deterministic computation is performed;
4. The results are aggregated from the individual computations to give a final result
1. Determine the pseudo-population or model that represents the true population of interest.
2. Use a sampling procedure to sample from the pseudo-population.
3. Calculate a value for the statistic of interest and store it.
4. Repeat steps 2 and 3 for N trials.
5. Use the N values found in step 4 to study the distribution of the statistic.
It is often asked that when do we simulate? and when do we approach a problem using analytical
methods? The catch is this Calculate when you can, simulate when you cant!
One favorable feature of Monte Carlo is that it is possible to estimate the order of magnitude of
statistical error, which is the dominant error in most Monte Carlo computations. These estimates are
often called error bars because of the way they are indicated on plots of Monte Carlo results. Monte
Carlo error bars are essentially statistical confidence intervals. At times algorithm used for MC
simulations could result in wide variations in output for different computations and this necessitates
developing better algorithms. The search for more accurate alternative algorithms is often called
variance reduction.
2
ADVANTAGES
DISADVANTAGES
1. Monte Carlo simulation is not universally accepted in simulating a system that is not in
equilibrium (i.e. in a transient state).
2. A large number of samples are required to reach the desired results. This can be time-consuming
compared to using a spreadsheet program, such as Excel, which can generate a simple
calculation fairly quickly.
3. A single sample cannot be used in simulation; to obtain results there must be many samples.
4. The results are only an approximation of the true value.
5. Simulation results can show large variance.
6. It may be very expensive to build simulation
7. It is easy to misuse simulation by stretching it beyond the limits of credibility
3
COMPARISON OF ANALYTICAL AND MONTE CARLO SIMULATION MODELS
Simulation Method
4
time. One of the most famous early uses of MC simulation was by Enrico Fermi in 1930, when
he used a random method to calculate the properties of the newly-discovered neutron
4. Monte Carlo Simulation is also used in Reliability Analysis and Six Sigma
5
3.0 SAMPLE APPLICATION OF MONTE CARLO SIMULATION
In basic terms, Monte Carlo entails taking a large set of defined random inputs, applying them as
inputs to a model of the process under study and studying the result obtained as shown below.
RANDOM OUTPUT OF
PROCESS
INPUT THE
DISTRIBUTION MODEL
SIMULATION
Using the above steps lets determine the Volume of a unit sphere (radius =1)
To determine the volume, let us assume that the sphere is inscribed in a cube of length = 2R
In a 3D space, the distance (d) between any two points (x1, y1, z1) and (x2, y2, z2) is given by
2 2
d= ( x 2x 1 ) + ( y 2 y 1 ) + ( z 2z 1)
2
x
-1 1
6
Let the centre of the sphere be at (0, 0, 0) hence,
d2 = x2 +y2+z2
The mean of f(x, y) is obtained by considering the portion of the total N points that falls within the
circular region within the square such that;
f = sum of the values of f(x, y) within the circle the number of points within the circle
Using MATLAB
Clear
clc
n=10000;
x =rand (n,1);
y=rand(n,1);
withinsphere=0; z= zeros(); d=zeros();
r=1; sum=0;
for i=1:n
d(i)= x(i).^2 + y(i).^2;
if d(i)<=r^2 && d(i)>0
z(i)= sqrt (r^2- d(i));
sum = sum + z(i);
withinsphere= withinsphere + 1;
7
end
end
meanz= sum/withinsphere;
%since the integral over f(x,y) = z =sqrt [r2 - [2 + y2]] only covers
half the volume
%of the sphere we multiply by 2
%The volume by monte carlo integration = Actual Integral =
% 2* pi*r^2 * meanz
%where pi*r*r is now the integral volume
%expected answer is 4.18879
Discussion
For N=100000 MATLAB gave a value of 4.187988e+000 which is very close to the expected value
of 4 / 3 = 4.1889020
2000
Number of occurence
1500
1000
500
0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Range of values of Z
Using this simulation we aim to confirm if there is any relationship between the accuracy of the
simulation result and the number of random inputs used vis--vis the number of times for which the
simulation was repeated.
8
Analytically
4 3
r
Sphere volume 3
= = =0.523599
Cube volume 8r
3
6
Using MATLAB
% here the ratio of sphere volume to cube is pi/6
%The distance from a point in a 3d space is r^2= sqrt [x^2 + y^2 +z^2]
factor=10000;
n=6 *factor;
x =rand (n,1);
y=rand(n,1);
z=rand(n,1);
k=0; T= [];
% repeating the iteration T times and finding the average to improve
% accuracy
range=1;
for T=1:range
for i=1:n
d(i)= sqrt (x(i).^2 + y(i).^2 + z(i).^2);
if d(i)<=1 && d(i)>0
k=k+1;
end
end
store(T)=k/factor;
k=0;
end
%to find the average value of pi
sum=0;
for T=1:range
sum= sum + store (T);
end
pii = sum/range
9
Observation
After running the algorithm for different values of N for several numbers of times and then finding
the mean and standard deviation, it was observed that the expectation is better approached with
higher values of N (number of samples) than by using lower values of N and then repeating the
simulation a high number of times, although the higher the value of N the longer the computation
time and the greater the computer resources utilized. The standard deviation seemed to vary
randomly and nothing significant could be observed from it.
4.0 CONCLUSION
Monte Carlo methods are flexible and can take many sources of uncertainty, but they may not
always be appropriate. In general, the method is preferable only if there are several sources of
uncertainty.
5.0 REFERENCES
Analysis Using Monte Carlo Simulation. (n.d.). Retrieved September 23, 2014, from
http://www.qfinance.com/asset-management-checklists/analysis-using-monte-carlo-simulation
Applied R&M Manual for Defence Systems, P. D.-S. (n.d.). MONTE-CARLO SIMULATION.
Haugh, M. (2004). Overview of Monte Carlo Simulation, Probability Review and Introduction to Matlab. IEOR
E4703, 1 - 11.
10
Raychaudhuri, S. (2008). Introduction to Monte Carlo Simulation. Proceedings of the 2008 Winter Simulation
Conference
11