1 / 40

MONTE CARLO NUMERICAL METHOD

MONTE CARLO NUMERICAL METHOD. BY A. Lecture KARRAR DH. MOHAMMED. History of the Monte Carlo Method. The Monte Carlo name is taken from the Monte Carlo, the capital of Monaco which was a center for gambling.

cara-wade
Download Presentation

MONTE CARLO NUMERICAL METHOD

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. MONTE CARLO NUMERICAL METHOD BY A. Lecture KARRAR DH. MOHAMMED

  2. History of the Monte Carlo Method The Monte Carlo name is taken from the Monte Carlo, the capital of Monaco which was a center for gambling .

  3. Monte Carlo methods are used in many different ways e.g. as a technique of integration of a function. One of this ways is: The Monte Carlo method as a numerical technique for calculating the integral by using sequences of random numbers.

  4. In mathematics, Monte Carlo integration is numerical integration using random numbers. That is, Monte Carlo integration methods are algorithms for the approximate evaluation of definite integrals, usually multidimensional ones.

  5. The usual algorithms evaluate the integrand at a regular grid. Monte Carlo methods, however, randomly choose the points at which the integrand is evaluated, informally, to estimate the area of a domain D,

  6. First, pick a simple domain E whose area is easily calculated and which contains D. • Now pick a sequence of random points that fall within E. • Some fraction of these points will also fall within D.

  7. The area of D is then estimated as this fraction multiplied by the area of E. • The traditional Monte Carlo algorithm distributes the evaluation points uniformly over the integration region .

  8. Why are Monte Carlo techniques used ? • Two of the main reasons why we use Monte Carlo methods: • their ant-aliasing properties, and • their ability to approximate quickly an answer that would be very time-consuming to find out.

  9. if we want to use a method to determine the exact answer, Monte Carlo method can be used to simulate problems that are too difficult and time-consuming.

  10. An example is in the use of Monte Carlo techniques in integrating very complex multidimensional integrals. • This is a task that other processes can not handle well, but which Monte Carlo can.

  11. The first point refers to the fact that since Monte Carlo methods involve a random component in the algorithm, then they go some way to avoid the problems of ant-aliasing (only for certain applications).

  12. An example that was brought to my attention was that of finding the area of the black squares on a chess board. Now, if I was using an acceptance-rejection method to attack this problem, I should come out with a fair approximation,

  13. Due to the fact that I would be going to random points on the chessboard, I will do the same process by using an algorithm that moved to a certain next point in a set of distance away and then continued to do this,

  14. thus not having any random point selection, the potential problem is that this person may have a bad step size and may over evaluate or under evaluate the number of successful trials he has, thus inevitably giving a poor approximation.

  15. These are two solid reasons why people use Monte Carlo techniques. Other possible reasons could include its ease in simulating complex physical systems in the fields of physics, engineering and chemistry

  16. Transformation Function • T : [c,d] [0,1] • is defined by :- • T (x) =(x-c) / (d-c)

  17. Generate a random number x uniform in [X min,X max]: • Step 1: • A random number generated by the following relation :- • ni = (k*ni) mod m . such that • ni: integer number • k: multiplier number • m: modulus number • no : initial value

  18. step 2: • ri = ni /m in[0,1] where • ni ={n1,n2 ,n3,………} • m: modulus • step 3: • Xi (random) =X min + ri * (X max – X min)

  19. Crude Monte Carlo • We are going to use this technique to solve the integral I. • I = • The method is that you take a number N for random number where c ≤ xi ≤ d then for all xi we find the function • f (xi) .

  20. For the f(x) we sum all of these values and divide by N to get the mean value for the random number. We then multiply this value by the interval (b-a) to get the integral by: • I=

  21. EXAMPLE : • Solve the following integral by using Monte Carlo method • I= • Solution:-we use the previous steps to get the solution

  22. Step 1:-let no=1,k=3,m=7 • We compute the random numbers (n)asfollows:- • ni=k * (ni-1) mod 7 • n1=(3*1) mod 7 =3 • n2=(3*3) mod 7 =2 • n3=(3*2) mod 7 =6 • n4=(3*6) mod 7 =4

  23. n5= (3*4) mod 7 =5 • n6= (3*5) mod 7 =1 • n7= (3*1) mod 7 =3 ... Stop • Number of random m-1=7-1=6

  24. Step 2:-by the following we shall compute ri ri=ni/m r1=3/7=0.42 r2=2/7=0.28 r3=6/7=0.85 r4=4/7=0.57 r5=5/7=0.71 r6=1/7=0.14

  25. Step 3:-now we shall compute xi as following • Xi= xmin+ri(xmax-xmin) • X1=1+0.42(2)=1.84 • X2=1+0.28(2)=1.56 • X3=1+0.85(2)=2.7 • X4=1+0.57(2)=2.14 • X5=1+0.71(2)=2.42 • X6=1+0.44(2)=1.28

  26. I= • I= (1/6)*(0.207)=0.0345

  27. Example: • Solve the following integral by using Monte Carlo method • I= • Solution:- we use the same steps in the previous example to get the solution

  28. Step 1:-let no=1,k=3,m=7 • We compute the random numbers (n)as follows:- • ni=k * (ni-1) mod 7 • n1=(3*1) mod 7 =3 • n2=(3*3) mod 7 =2 • n3=(3*2) mod 7 =6 • n4=(3*6) mod 7 =4

  29. n5= (3*4) mod 7 =5 • n6= (3*5) mod 7 =1 • n7= (3*1) mod 7 =3 ... Stop • Number of random

  30. n5= (3*4) mod 7 =5 • n6= (3*5) mod 7 =1 • n7= (3*1) mod 7 =3 ... Stop • Number of random m-1=7-1=6

  31. Step 2:-by the following we shall compute ri ri=ni/m r1=3/7=0.42 r2=2/7=0.28 r3=6/7=0.85 r4=4/7=0.57 r5=5/7=0.71 r6=1/7=0.14

  32. Step 3:-now we shall compute xi as follows • Xi= xmin+ri(xmax-xmin) • X1=1+0.42(2)=1.84 • X2=1+0.28(2)=1.56 • X3=1+0.85(2)=2.7 • X4=1+0.57(2)=2.14 • X5=1+0.71(2)=2.42 • X6=1+0.44(2)=1.28

  33. I= • I= (1/6)*(49.277) =8.2128

  34. The Monte Carlo method program by MATLAB • clc • clear • c=input('please enter the lower bound of interval i.e c =') • d=input('please enter the upper bound of interval i.e d =') • m=input('please enter the modulus number i.e m =') • n=m-1; • trans_fun(c,d) • a=0; • b=1; • s=0; • z=1; • h=(b-a)/n; • k=0;

  35. while k<n • p=3*z; • q=mod(p,m); • z=q; • r=q/m; • x=c+(r*(d-c)); • f=sind(x); • s=s+f; • y=h*s; • k=k+1; • end • y

  36. The transformation function program • function [g] = trans_fun(a,b) • if (a~=0)&&(b~=1) • w=input('please enter the number of intervals points you wont to convert it w = ') • for v = 1:w • x=input('please enter the point of interval you want to convert it x = ') • g =(x-a)/(b-a) • end • disp('the original interval convert to a=0 & b=1') • else • disp('already a=0 & b=1') • end

  37. Finally

  38. Thanks for being so patient

More Related