MONTE CARLO NUMERICAL METHOD - PowerPoint PPT Presentation

1 / 40
About This Presentation
Title:

MONTE CARLO NUMERICAL METHOD

Description:

MONTE CARLO NUMERICAL METHOD BY A. Lecture KARRAR DH. MOHAMMED F(xi)=exi xi ri Ni 6.296 1.84 0.42 1 4.7588 1.56 0.28 2 14.879 2.7 0.85 3 8.4994 2.14 0.57 4 11.2458 2 ... – PowerPoint PPT presentation

Number of Views:230
Avg rating:3.0/5.0
Slides: 41
Provided by: KARR76
Category:

less

Transcript and Presenter's Notes

Title: MONTE CARLO NUMERICAL METHOD


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 (kni) mod m . such that
  • ni integer number
  • k multiplier number
  • m modulus number
  • no initial value

18
  • step 2
  • ri ni /m in0,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 no1,k3,m7
  • We compute the random numbers (n) as follows-
  • nik (ni-1) mod 7
  • n1(31) mod 7 3
  • n2(33) mod 7 2
  • n3(32) mod 7 6
  • n4(36) mod 7 4

23
  • n5 (34) mod 7 5
  • n6 (35) mod 7 1
  • n7 (31) mod 7 3 ... Stop
  • Number of random m-17-16

24
Step 2-by the following we shall compute ri
  • rini/m
  • r13/70.42
  • r22/70.28
  • r36/70.85
  • r44/70.57
  • r55/70.71
  • r61/70.14

25
Step 3-now we shall compute xi as following
  • Xi xminri(xmax-xmin)
  • X110.42(2)1.84
  • X210.28(2)1.56
  • X310.85(2)2.7
  • X410.57(2)2.14
  • X510.71(2)2.42
  • X610.44(2)1.28

26
F(xi)sin(xi) xi ri Ni
0.032 1.84 0.42 1
0.027 1.56 0.28 2
0.047 2.7 0.85 3
0.0373 2.14 0.57 4
0.0422 2.42 0.71 5
0.0233 1.28 0.14 6

27
  • I
  • I (1/6)(0.207)0.0345

28
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

29
Step 1-let no1,k3,m7
  • We compute the random numbers (n) as follows-
  • nik (ni-1) mod 7
  • n1(31) mod 7 3
  • n2(33) mod 7 2
  • n3(32) mod 7 6
  • n4(36) mod 7 4

30
  • n5 (34) mod 7 5
  • n6 (35) mod 7 1
  • n7 (31) mod 7 3 ... Stop
  • Number of random

31
  • n5 (34) mod 7 5
  • n6 (35) mod 7 1
  • n7 (31) mod 7 3 ... Stop
  • Number of random m-17-16

32
Step 2-by the following we shall compute ri
  • rini/m
  • r13/70.42
  • r22/70.28
  • r36/70.85
  • r44/70.57
  • r55/70.71
  • r61/70.14

33
Step 3-now we shall compute xi as follows
  • Xi xminri(xmax-xmin)
  • X110.42(2)1.84
  • X210.28(2)1.56
  • X310.85(2)2.7
  • X410.57(2)2.14
  • X510.71(2)2.42
  • X610.44(2)1.28

34
F(xi)exi xi ri Ni
6.296 1.84 0.42 1
4.7588 1.56 0.28 2
14.879 2.7 0.85 3
8.4994 2.14 0.57 4
11.2458 2.42 0.71 5
3.5966 1.28 0.14 6

35
  • I
  • I (1/6)(49.277) 8.2128

36
The Monte Carlo method program by MATLAB
  • clc
  • clear
  • cinput('please enter the lower bound of interval
    i.e c ')
  • dinput('please enter the upper bound of interval
    i.e d ')
  • minput('please enter the modulus number i.e m
    ')
  • nm-1
  • trans_fun(c,d)
  • a0
  • b1
  • s0
  • z1
  • h(b-a)/n
  • k0

37
  • while kltn
  • p3z
  • qmod(p,m)
  • zq
  • rq/m
  • xc(r(d-c))
  • fsind(x)
  • ssf
  • yhs
  • kk1
  • end
  • y

38
The transformation function program
  • function g trans_fun(a,b)
  • if (a0)(b1)
  • winput('please enter the number of intervals
    points you wont to convert it w ')
  • for v 1w
  • xinput('please enter the point of interval you
    want to convert it x ')
  • g (x-a)/(b-a)
  • end
  • disp('the original interval convert to a0
    b1')
  • else
  • disp('already a0 b1')
  • end

39
Finally
40
Thanks for being so patient
Write a Comment
User Comments (0)
About PowerShow.com