a term paper on monte carlo analysis / simulation

12
A TERM PAPER ON MONTE CARLO ANALYSIS / SIMULATION WRITTEN BY ADEKITAN ADERIBIGBE DEPA RTMENT OF ELECTRICAL AND ELECTRONIC ENGINEERING FACUL TY OF TECHNOLOGY UNIVERSITY OF IBADAN SEPTEMBER 2014

Upload: ferdad4real

Post on 01-Jun-2018

222 views

Category:

Documents


0 download

TRANSCRIPT

8/9/2019 A TERM PAPER ON MONTE CARLO ANALYSIS / SIMULATION

http://slidepdf.com/reader/full/a-term-paper-on-monte-carlo-analysis-simulation 1/12

A TERM PAPER ON MONTE CARLO ANALYSIS / SIMULATION

WRITTEN BY

ADEKITAN ADERIBIGBE

DEPARTMENT OF ELECTRICAL AND ELECTRONIC ENGINEERING

FACULTY OF TECHNOLOGY

UNIVERSITY OF IBADAN

SEPTEMBER 2014

8/9/2019 A TERM PAPER ON MONTE CARLO ANALYSIS / SIMULATION

http://slidepdf.com/reader/full/a-term-paper-on-monte-carlo-analysis-simulation 2/12

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 techniues !or obtaining a probabilistic

appro"imation to the solution o! a mathematical euation or model by utili#ing seuences o! random

numbers as inputs into a model which yields results that are indications o! the per!ormance o! the

developed model$

Monte Carlo simulation was developed as part o! the atomic program$ %cientist at the &os lamos

 ational &aboratory originally used it to model the random di!!usion o! neutrons$ he scientist who

developed this simulation techniue gave it the name *Monte Carlo+ a!ter the city in Monaco and its

many casinos$ Monte Carlo simulation are used in a wide array o! applications, including physics,

!inance, and system reliability

Monte Carlo analysis utili#es statistical tools to mathematically model a real li!e system or process

and then it estimates the probability o! obtaining a success!ul outcome$ he statistical distribution o! 

the process to be modeled must be determined !irst be!ore 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 analy#e and evaluate comple" measurements using a model o! a

system, and to e"periment with the model towards drawing in!erences o! the systems behavior$

QUESTIONS TO ASK WHEN CONSIDERING USING MONTE CARLO

1$ Consider the problem$ -oes it have many sources o! uncertainty.

/$ s there an analytical solution. ! so, use that$

$ Choose the so!tware you will use !or Monte Carlo simulation$4$ -ecide on the nature and source o! inputs to use

2$ 3hat distribution do the random variables have.

$ 5ow do we generate these random variables !or the simulation.6$ 5ow do we analy#e the output o! the simulation.7$ 5ow many simulation runs do we need.

9$ 5ow do we improve the e!!iciency o! the simulation.

10$ 5ow do we interpret the generated result.

ATTRIBUTES OF MONTE CARLO SIMULATION

here is no single Monte Carlo method8the term covers a wide range o! approaches to simulation$

5owever, these approaches use a certain pattern in which

1

8/9/2019 A TERM PAPER ON MONTE CARLO ANALYSIS / SIMULATION

http://slidepdf.com/reader/full/a-term-paper-on-monte-carlo-analysis-simulation 3/12

1$ domain o! possible inputs is de!ined:

/$ nputs are randomly generated !rom the domain:

$ ;sing the inputs, a deterministic computation is per!ormed:4$ he results are aggregated !rom the individual computations to give a !inal result

2.0 MONTE CARLO ANALYSIS

PROCEDURE FOR APPLYING MONTE CARLO

1$ -etermine the pseudo<population or model that represents the true population o! interest$

/$ ;se a sampling procedure to sample !rom the pseudo<population$

$ Calculate a value !or the statistic o! interest and store it$4$ =epeat steps / and !or trials$

2$ ;se the values !ound in step 4 to study the distribution o! the statistic$

t is o!ten as>ed that when do we simulate. and when do we approach a problem using analytical

methods. he catch is this *Calculate when you can, simulate when you can’t ?+

@ne !avorable !eature o! Monte Carlo is that it is possible to estimate the order o! magnitude o!

statistical error, which is the dominant error in most Monte Carlo computations$ hese estimates are

o!ten called error bars because o! the way they are indicated on plots o! Monte Carlo results$ Monte

Carlo error bars are essentially statistical con!idence intervals$ t times algorithm used !or MC

simulations could result in wide variations in output !or di!!erent computations and this necessitates

developing better algorithms$ he search !or more accurate alternative algorithms is o!ten called

variance reduction$

ADVANTAGES

1$ ;sing Monte Carlo simulation is uite straight!orward$/$ t can provide statistical sampling !or numerical e"periments using a computer$

$ n optimi#ation problems, Monte Carlo simulation can o!ten reach the optimum and overcome

local e"tremes$

2

8/9/2019 A TERM PAPER ON MONTE CARLO ANALYSIS / SIMULATION

http://slidepdf.com/reader/full/a-term-paper-on-monte-carlo-analysis-simulation 4/12

4$ t provides appro"imate solutions to many mathematical problems$

2$ Monte Carlo analysis produces a narrower range o! results than a Awhat i!+ analysis$

DISADVANTAGES

1$ Monte Carlo simulation is not universally accepted in simulating a system that is not in

euilibrium (i$e$ in a transient state)$

/$ large number o! samples are reuired to reach the desired results$ his can be time<consuming

compared to using a spreadsheet program, such as B"cel, which can generate a simple

calculation !airly uic>ly$$ single sample cannot be used in simulation: to obtain results there must be many samples$

4$ he results are only an appro"imation o! the true value$

2$ %imulation results can show large variance$$ t may be very e"pensive to build simulation

6$ t is easy to misuse simulation by stretching it beyond the limits o! credibility

3

8/9/2019 A TERM PAPER ON MONTE CARLO ANALYSIS / SIMULATION

http://slidepdf.com/reader/full/a-term-paper-on-monte-carlo-analysis-simulation 5/12

COMPARISON OF ANALYTICAL AND MONTE CARLO SIMULATION MODELS

Simulation Method

Advantages Analytical Monte-Carloa$ ives e"act results (given the

assumptions o! the model)$a. Very fexible. There isvirtually no limit to theanalysis. Empiricaldistributions can behandled.

b. Once the model isdeveloped, output willenerally be rapidlyobtained.

b. !an enerally beeasily extended anddeveloped as re"uired.

c. #t need not always beimplemented on a computer$ paper analyses may su%ce.

c. Easily understood bynon&mathematicians.

Disadvantages

a. 'enerally re"uiresrestrictive assumptions toma(e the problem tractable.

a. )sually re"uires acomputer.

b. *ecause o+ a. it is lessfexible than onte&!arlo. #nparticular, the scope +orextendin or developin amodel may be limited.

b. !alculations can ta(emuch loner thananalytical models.

c. The model miht only beunderstood bymathematicians. This maycause credibility problems i+output conficts withpreconceived ideas o+desiners or manaement.

c. -olutions are notexact, but depend onthe number o+ repeatedruns used to producethe output statistics. That is, all outputs areestimates.

COMMON AREAS OF APPLICATION OF MONTE CARLO

1$ Monte Carlo %imulation is used in Mathematics and %tatistical Dhysics

t is used !or numerically solving comple" multi<dimensional partial di!!erentiation and

integration problems$ t is also used to solve optimi#ation problems in @perations =esearch

(these optimi#ation methods are called simulation optimi#ation)$ MC method is used !or

simulating uantum systems, which allows a direct representation o! many<body e!!ects in the

uantum domain, at the cost o! statistical uncertainty that can be reduced with more simulation

8/9/2019 A TERM PAPER ON MONTE CARLO ANALYSIS / SIMULATION

http://slidepdf.com/reader/full/a-term-paper-on-monte-carlo-analysis-simulation 6/12

time$ @ne o! the most !amous early uses o! MC simulation was by Bnrico Eermi in 190, when

he used a random method to calculate the properties o! the newly<discovered neutron

/$ Monte Carlo %imulation in Bngineering

t is used in reliability analysis o! components in engineering and to determine the e!!ective li!e

o! pressure vessels in reactors$ lso in electronics engineering and circuit design: circuits in

computer chips are simulated using MC methods !or estimating the probability o! !etching

instructions in memory bu!!ers etc$

$ t is also used in !inance in the !ollowing areas

=eal @ptions nalysis, Dort!olio nalysis, @ption nalysis, Dersonal Einancial Dlanning etc

4$ Monte Carlo %imulation is also used in =eliability nalysis and %i" %igma

/

8/9/2019 A TERM PAPER ON MONTE CARLO ANALYSIS / SIMULATION

http://slidepdf.com/reader/full/a-term-paper-on-monte-carlo-analysis-simulation 7/12

RANDOM INPUT DISTRIUTIONPROC!SS MOD!"OUTPUT O# T$! SIMU"ATION

x

y

1&1

0

central plane o+ the sphere showin the x and y axes

3.0 SAMPLE APPLICATION OF MONTE CARLO SIMULATION

n basic terms, Monte Carlo entails ta>ing a large set o! de!ined random inputs, applying them as

inputs to a model o! the process under study and studying the result obtained as shown below$

;sing the above steps lets determine the Folume o! a unit sphere (radius G1)

F!"!# $%& V'()*& '+ , )!$ -%&& R,")- R 1

o determine the volume, let us assume that the sphere is inscribed in a cube o! length G /= 

n a - space, the distance (d) between any two points ("1, y1, #1) and ("/, y/, #/) is given by

d=√ ( x2− x

1 )2

+( y2− y

1 )2

+ ( z2− z1)2

8/9/2019 A TERM PAPER ON MONTE CARLO ANALYSIS / SIMULATION

http://slidepdf.com/reader/full/a-term-paper-on-monte-carlo-analysis-simulation 8/12

&et the centre o! the sphere be at (0, 0, 0) hence,

d/ G "/ Hy/H#/

&et us de!ine the !unction ! (", y) G # ¿√ (r )2

−( x )2

+( y )2

U-!# M'!$& C,(' I!$&#,$'! H$ ,!" *-- *&$%'"

Eor an MH1 dimensional volume: ntegral FMH1 G FM I f 

3here FM is the m<dimensional volume de!ining the integration area

 f is the mean value G1

 N ∑i=1

 N 

f  ( x)i  G N 

h N 

  is the total number o! points randomly considered or the number o! trials$

 h is the number o! hits

 @B < he integral over !(", y) only covers hal! the volume o! the sphere so we multiply by /

ctual ntegral G /I ntegral Folume I f 

ntegral Folume G pi I r /

he mean o! !(", y) is obtained by considering the portion o! the total points that !alls within the

circular region within the suare such that:

 f = sum of the values of f(x, y) within the circle ÷ the number of points within the circle

U-!# 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).! " y(i).!;

  if d(i)#=r! $$ d(i)%0

8/9/2019 A TERM PAPER ON MONTE CARLO ANALYSIS / SIMULATION

http://slidepdf.com/reader/full/a-term-paper-on-monte-carlo-analysis-simulation 9/12

  z(i)= s&rt (r!' d(i));

  sum = sum " z(i);

  withinsphere= withinsphere " 1;

end

end

meanz= sumwithinsphere;%since the integral over f(x,y) = z =sqrt [r2 - [2 + y2]] only covers

half the volume

%of the shere !e multily "y 2

%#he volume "y monte carlo integration = $ctual ntegral = 

% 2& i&r'2 & meanz

%!here i&r&r is no! the integral volume

%execte ans!er is *.

sphereolume = !* pi*r*r * meanz;

+-/ = sprintf(/0ut of % ranom oints % fell !ithin the shere

giving a simulate shere volume of %/,n, withinsphere,

sphereolume)

disp(/1y calculation the execte values is *.2/)

D-)--'!

Eor G100000 M&J gave a value o! 4$176977eH000 which is very close to the e"pected value

o! 4 K L G 4$17790/0

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10

500

1000

1500

2000

2500

Range of values of Z

 N u m b e r o f o c c u r e n c e

Distribution of the input across the sample space

U-!# , S%&& !-&" ! , C)& $' +!" $%& 5,()& '+

8/9/2019 A TERM PAPER ON MONTE CARLO ANALYSIS / SIMULATION

http://slidepdf.com/reader/full/a-term-paper-on-monte-carlo-analysis-simulation 10/12

;sing this simulation we aim to con!irm i! there is any relationship between the accuracy o! the

simulation result and the number o! random inputs used vis<<vis the number o! times !or which the

simulation was repeated$

A!,(6$,((6

he volume o! a sphere is given by 4L K r 

Eor the cube (& G J G 3 G /r): Folume G (/r)

he ratio o! the two volumes gives

Spherevolume

Cubevolume  =

4

3π r

3

8 r3  =

π 

6=0.523599

U-!# MATLAB

% here the ratio of shere volume to cu"e is i34 

%#he istance from a oint in a 5 sace is r'2= sqrt [x'2 + y'2 +z'2]

 

!actorG10000:

nG I!actor:

" Grand (n,1):

yGrand(n,1):#Grand(n,1):

>G0: G NO:% reeating the iteration # times an fining the average to imrove

% accuracy 

rangeG1:

!or  G1range!or  iG1n

  d(i)G srt ("(i)$P/ H y(i)$P/ H #(i)$P/):

  i!  d(i)QG1 RR d(i)S0  >G>H1:

endendstore()G>L!actor:

>G0:

end %to fin the average value of i

 sumG0:

 !or  G1range  sumG sum H store ():

4

8/9/2019 A TERM PAPER ON MONTE CARLO ANALYSIS / SIMULATION

http://slidepdf.com/reader/full/a-term-paper-on-monte-carlo-analysis-simulation 11/12

 end

  pii G sumLrange

O-&5,$'!

!ter running the algorithm !or di!!erent values o! !or several numbers o! times and then !inding

the mean and standard deviation, it was observed that the e"pectation is better approached with

higher values o! (number o! samples) than by using lower values o! and then repeating the

simulation a high number o! times, although the higher the value o! the longer the computation

time and the greater the computer resources utili#ed$ he standard deviation seemed to vary

randomly and nothing signi!icant could be observed !rom it$

The Num%er o& times &or 'hich the simulation is re(eated5 1 /66 1666 /666 16666 16666666 3.1466 3.2266

-td. 7

2.21e&

61

3.266

-td. 7

./4e&

61

3.1466

-td. 7

1./22e&

613

3.666

-td. 7

/.141e&

613

3.166

-td. 7

.41e&

612666 3.116 3.1646

-td. 7

1.e&61

3.126

-td. 7

/.2e&61

3.166

-td. 7

1.426e&613

3.1/46

-td. 7

2.43/e&613

3.116

-td. 7

.13e&613666

6

3.12 3.134

-td. 7

1.6e&

61

3.1/

-td. 7

.36e&

61

3.1/61

-td. 7

2.446e&

613

3.134

-td. 7

.314e&

613

3.13

-td. 7

/.1e&

612

4.0 CONCLUSION

Monte Carlo methods are !le"ible and can ta>e many sources o! uncertainty, but they may not

always be appropriate$ n general, the method is pre!erable only i! there are several sources o!

uncertainty$

16

8/9/2019 A TERM PAPER ON MONTE CARLO ANALYSIS / SIMULATION

http://slidepdf.com/reader/full/a-term-paper-on-monte-carlo-analysis-simulation 12/12

7.0 REFERENCES

 Analysis Using Monte Carlo Simulation. 8n.d.9. 0etrieved -eptember 23, 261, +rom

http:;;www."<nance.com;asset&manaement&chec(lists;analysis&usin&monte&carlo&

simulation

=pplied 0> anual +or ?e+ence -ystems, @. ?.&-. 8n.d.9. MONTE-CARLO SIMULATION. 

Aauh, . 82669. Overview o+ onte !arlo -imulation, @robability 0eview and

#ntroduction to atlab. IEOR E470, 1 & 11.

0aychaudhuri, -. 82669. #ntroduction to onte !arlo -imulation. !ro"ee#ings o$ t%e

&00' (inter Simulation Con$eren"e

11