P(r)dr = probability of generating a random number in the interval dr near r. For this probability idea to make sense we must have

Similar documents
COMP 423 lecture 11 Jan. 28, 2008

Introduction to Integration

Approximate computations

10.5 Graphing Quadratic Functions

The Fundamental Theorem of Calculus

2 Computing all Intersections of a Set of Segments Line Segment Intersection

6.3 Volumes. Just as area is always positive, so is volume and our attitudes towards finding it.

Representation of Numbers. Number Representation. Representation of Numbers. 32-bit Unsigned Integers 3/24/2014. Fixed point Integer Representation

Improper Integrals. October 4, 2017

Lecture 10 Evolutionary Computation: Evolution strategies and genetic programming

Lecture 7: Integration Techniques

CS321 Languages and Compiler Design I. Winter 2012 Lecture 5

Integration. September 28, 2017

Fig.25: the Role of LEX

Math 464 Fall 2012 Notes on Marginal and Conditional Densities October 18, 2012

Unit #9 : Definite Integral Properties, Fundamental Theorem of Calculus

1.5 Extrema and the Mean Value Theorem

Pointwise convergence need not behave well with respect to standard properties such as continuity.

Integration. October 25, 2016

Before We Begin. Introduction to Spatial Domain Filtering. Introduction to Digital Image Processing. Overview (1): Administrative Details (1):

ZZ - Advanced Math Review 2017

a < a+ x < a+2 x < < a+n x = b, n A i n f(x i ) x. i=1 i=1

If you are at the university, either physically or via the VPN, you can download the chapters of this book as PDFs.

1. SEQUENCES INVOLVING EXPONENTIAL GROWTH (GEOMETRIC SEQUENCES)

Section 10.4 Hyperbolas

MA 124 (Calculus II) Lecture 2: January 24, 2019 Section A3. Professor Jennifer Balakrishnan,

8.2 Areas in the Plane

Numerical integration methods

If f(x, y) is a surface that lies above r(t), we can think about the area between the surface and the curve.

Slides for Data Mining by I. H. Witten and E. Frank

This notebook investigates the properties of non-integer differential operators using Fourier analysis.

6.2 Volumes of Revolution: The Disk Method

Approximation of Two-Dimensional Rectangle Packing

MATH 25 CLASS 5 NOTES, SEP

Agilent Mass Hunter Software

such that the S i cover S, or equivalently S

APPLICATIONS OF INTEGRATION

9 Graph Cutting Procedures

Presentation Martin Randers

MATH 2530: WORKSHEET 7. x 2 y dz dy dx =

Product of polynomials. Introduction to Programming (in C++) Numerical algorithms. Product of polynomials. Product of polynomials

Math 142, Exam 1 Information.

Solutions to Math 41 Final Exam December 12, 2011

Fig.1. Let a source of monochromatic light be incident on a slit of finite width a, as shown in Fig. 1.

4452 Mathematical Modeling Lecture 4: Lagrange Multipliers

Matlab s Numerical Integration Commands

MA1008. Calculus and Linear Algebra for Engineers. Course Notes for Section B. Stephen Wills. Department of Mathematics. University College Cork

A Tautology Checker loosely related to Stålmarck s Algorithm by Martin Richards

CS143 Handout 07 Summer 2011 June 24 th, 2011 Written Set 1: Lexical Analysis

Definition of Regular Expression

EXPONENTIAL & POWER GRAPHS

)

Class-XI Mathematics Conic Sections Chapter-11 Chapter Notes Key Concepts

6.3 Definite Integrals and Antiderivatives

Simplifying Algebra. Simplifying Algebra. Curriculum Ready.

12-B FRACTIONS AND DECIMALS

Double Integrals. MATH 375 Numerical Analysis. J. Robert Buchanan. Fall Department of Mathematics. J. Robert Buchanan Double Integrals

Area & Volume. Chapter 6.1 & 6.2 September 25, y = 1! x 2. Back to Area:

Hyperbolas. Definition of Hyperbola

INTRODUCTION TO SIMPLICIAL COMPLEXES

Unit 5 Vocabulary. A function is a special relationship where each input has a single output.

cisc1110 fall 2010 lecture VI.2 call by value function parameters another call by value example:

Section 3.1: Sequences and Series

In the last lecture, we discussed how valid tokens may be specified by regular expressions.

Dr. D.M. Akbar Hussain

CSCI 104. Rafael Ferreira da Silva. Slides adapted from: Mark Redekopp and David Kempe

Languages. L((a (b)(c))*) = { ε,a,bc,aa,abc,bca,... } εw = wε = w. εabba = abbaε = abba. (a (b)(c)) *

Answer Key Lesson 6: Workshop: Angles and Lines

Solving Problems by Searching. CS 486/686: Introduction to Artificial Intelligence Winter 2016

Lexical Analysis: Constructing a Scanner from Regular Expressions

9 4. CISC - Curriculum & Instruction Steering Committee. California County Superintendents Educational Services Association

Math 35 Review Sheet, Spring 2014

Example: 2:1 Multiplexer

Midterm 2 Sample solution

CS311H: Discrete Mathematics. Graph Theory IV. A Non-planar Graph. Regions of a Planar Graph. Euler s Formula. Instructor: Işıl Dillig

Section 5.3 : Finding Area Between Curves

Engineer To Engineer Note

CS412/413. Introduction to Compilers Tim Teitelbaum. Lecture 4: Lexical Analyzers 28 Jan 08

The Math Learning Center PO Box 12929, Salem, Oregon Math Learning Center

Graphing Conic Sections

Summer Review Packet For Algebra 2 CP/Honors

CHAPTER III IMAGE DEWARPING (CALIBRATION) PROCEDURE

CSCE 531, Spring 2017, Midterm Exam Answer Key

Small Business Networking

Solving Problems by Searching. CS 486/686: Introduction to Artificial Intelligence

A REINFORCEMENT LEARNING APPROACH TO SCHEDULING DUAL-ARMED CLUSTER TOOLS WITH TIME VARIATIONS

CS 241 Week 4 Tutorial Solutions

Lily Yen and Mogens Hansen

Dynamic Programming. Andreas Klappenecker. [partially based on slides by Prof. Welch] Monday, September 24, 2012

CSc 453. Compilers and Systems Software. 4 : Lexical Analysis II. Department of Computer Science University of Arizona

Calculus Differentiation

Physics 208: Electricity and Magnetism Exam 1, Secs Feb IMPORTANT. Read these directions carefully:

Fall 2018 Midterm 2 November 15, 2018

The Distributed Data Access Schemes in Lambda Grid Networks

F. R. K. Chung y. University ofpennsylvania. Philadelphia, Pennsylvania R. L. Graham. AT&T Labs - Research. March 2,1997.

Typing with Weird Keyboards Notes

The Greedy Method. The Greedy Method

a(e, x) = x. Diagrammatically, this is encoded as the following commutative diagrams / X

Small Business Networking

Patterns and Algebra. My name. Series

Transcription:

Rndom Numers nd Monte Crlo Methods Rndom Numer Methods The integrtion methods discussed so fr ll re sed upon mking polynomil pproximtions to the integrnd. Another clss of numericl methods relies upon using rndom numers. These methods hve come to e known under the generl ruric Monte Crlo methods, fter the fmous gmling csino. Before discussing Monte Crlo integrtion, we must digress to lern out rndom numers. Rndom Numer Genertors Any stndrd rndom numer genertor produces set of uniformly distriuted (equl proility) numers on some intervl. For the intervl [,] we define P(r)dr = proility of generting rndom numer in the intervl dr ner r For this proility ide to mke sense we must hve P(r)dr = 1= totl proility of generting rndom numer In the cse of uniform distriution, P(r) = constnt nd hence P(r) = 1 All such numericl rndom numer genertors give sequence of numers with lrge repet cycle on some intervl. A good genertor will hve very lrge repet cycle(10 8 10 9 nonrepeting numers). In MATLAB, the rnd(n,m) function genertes uniformly distriuted pseudo-rndom numers. We illustrte the uniform distriution of 100,000 rndom numers elow: >> hist(rnd(1,100000),10) Pge 1

which oviously shows the uniform distriution on the intervl [0,1]. MATLAB lso generte normlly (Gussin) distriuted rndom numers using the rndn function. >> hist(rndn(1,100000),20)) which is oviously norml or gussin distriution. Pge 2

These two methods re exmples of "simple smpling" techniques. In mny prolems we need to use proility distriutions tht reflect the pproprite physics of the system under study. In this cse we use different technique clled "importnce smpling". The lgorithm for generting rndom numers with specified distriution(not uniform) goes this wy. Suppose tht we hve set of uniformly distriuted numers (s ove) in the intervl [0,1]. Then the rule r j = x j 0 dx'w(x') will generte set of numers x i rule w(x). For exmple, suppose w(x) = e x otin r j = 1 e x j x j = log(1 r j ) { } distriuted ccording to the 0 x 4. Then we which is the desired result. This is illustrted in the plot elow: >> hist((-log(1-rnd(1,100000))),20) Integrtion using Importnce Smpling (Monte Crlo Method) Now consider function to e integrted, s shown elow: Pge 3

y f(x) x The integrl is just the re under the curve. The width of the intervl (-) times the verge vlue of the function is lso the vlue of the integrl, tht is, f (x)dx = ( ) f verge = ( ) f So if we hd some indepent wy of clculting the verge vlue of the integrnd, then we could evlute the integrl. Tht is where we cn use rndom numers. Imgine tht we hve list of rndom numers, x j, uniformly distriuted etween nd. To clculte the function verge, we simply evlute f(x) t ech of the rndomly selected points, nd divide y the numer of points: f N = 1 N N i=1 f (x i ) As the numer of points used in clculting the verge increses, f N pproches the true verge vlue, f. Therefore, s numericl pproximtion we cn write f (x)dx = N f (x i ) N i=1 Alterntively, we cn look t this so-clled Monte Crlo integrtion method in the following wy: To integrte the function f(x) over the intervl [,] we Pge 4

[1] find some vlue M such tht f(x) < M over the intervl [,] [2] select rndom numer x from uniform distriution over the intervl [,] [3] select rndom numer y from uniform distriution over the intervl [0,M] [4] determine if y > f(x) or y f(x) [5] repet this process N times, keeping trck of the numer of times y f(x) or under the curve (= successes); cll the totl numer of successes S. The estimted proility of success is then S N = Are under curve Totl re inside rectngle = f (x)dx M ( ) where the rectngle used is shown in the figure elow: y y = M f(x) x After numer of trils, the vlue of the integrl cn e clculted from the ove formul f (x)dx = M ( ) S N Think out throwing drts nd counting the numer of drts tht lnd in the re representing the integrl. Your progrm ove only works if the integrnd is greter thn or equl to zero everywhere over the rnge of integrtion. Suppose, in fct, tht the function f(x) ws not lwys greter thn zero in the intervl [,] s shown elow. Pge 5

y y = M f(x) x y = -R We cn modify the Monte Crlo integrtion method to hndle such cses, i.e., fix the prolem with f(x) possily eing less thn zero s follows. To integrte the function f(x) over the intervl [,] we [1] find some vlue M such tht f(x) < M over the intervl [,] [2] find some R such tht f(x) > - R over the intervl [,] [2] select rndom numer x from uniform distriution over the intervl [,] [3] select rndom numer y from uniform distriution over the intervl [-R,M] [4] determine if y > f(x) or y f(x) [5] repet this process N times, keeping trck of the numer of times y f(x) or under the curve (= successes); cll the totl numer of successes S. The estimted proility of success is then S N = Are under curve Totl re inside rectngle = f (x)dx = (M + R)( ) S N f (x)dx (M + R)( ) This must now e corrected for the fct tht the line y = -R hs een used s the seline for the integrl insted of the line y = 0. This is ccomplished y sutrcting the rectngulr re R(-). The finl integrl is then f (x)dx = (M + R)( ) S R( ) N Pge 6

The Metropolis Algorithm Suppose tht we wnt to generte set of points in some, possily multidimensionl, spce of vriles X distriuted with proility density w(x) (not necessrily uniform). The Metropolis lgorithm genertes set of points X 0, X 1, X 2,... s those visited successively y rndom wlker moving through the X spce. As the wlk ecomes longer nd longer, the points it connects will pproximte closely the desired distriution. The rules for the rndom wlk re s follows: [1] Suppose tht the wlker is t point X n in the sequence. To generte X n+1 it mkes tril step to new point X t. This new point cn e chosen in ny convenient mnner, for exmple, uniformly t rndom within multidimensionl cue of smll side δ out X n. [2] This tril step is then "ccepted" or "rejected" ccording to the rtio r = w(x t ) w(x n ) tht is, if r is lrger thn one, then the step is lwys ccepted (i.e., we put X n+1 = X t, while if r is less thn one, the step is ccepted with proility r. This ltter step is conveniently ccomplished y compring r with rndom numer η uniformly distriuted in the intervl nd ccepting the step if η < r. If the tril step is not ccepted, then it is rejected, nd we put X n+1 = X n. This genertes X n+1, nd we my proceed to generte X n+2 y the sme process. Any ritrry point X n cn e used to strt this rndom wlk. A MATLAB code to use the Metropolis lgorithm for the cse w(x) = e 0.2 X 2 looks like: x=[]; X0=0; delt=4; nccept=0; Pge 7

n=0; while (nccept < 5000) n=n+1; XT = X0 + delt*(2*rnd(1,1)-1); rtio=exp(0.5*(x0^2-xt^2)); if (rtio > rnd) x=[x,xt]; X0=XT; nccept=nccept+1; hist(x,40) which clerly reflects the proposed Gussin distriution. A good rule is to choose δ so tht out 1/3 of the trils is ccepted nd to choose X 0 such tht w(x) is ner mximum. Becuse successive points in this distriution re not sttisticlly indepent of ech other, some cre must e tken when choosing set of points to use from lrger set tht hs een generted erlier. Generlly, the ccepted method is to choose points seprted y some intervl, sy every k th point, where k is such tht ny correltions re wshed out. Pge 8

A simple Metropolis method function is : function z=metropolis(input) % must hve nother funct.m file defined rnd('seed',sum(100*clock)); x=input(1); delt=input(2); xtril=x+delt*(2*rnd(1)-1); w=funct(xtril)/funct(x); if (rnd < w) z=xtril; else z= x; The code elow tests this function for w(x) = e 0.2 X 2 : zz=zeros(100000) z=metropolis([0.0,4.0]); for j=1:100000 z=metropolis([z,4.0]); zz(j)=z hist(zz,40); Agin this clerly reflects the correct distriution. Simple Simultion Exmple Using Rndom Numers Pge 9

Another exmple of using rndom numers to simulte prticles in ox with two distinct sides. Suppose prticle cn e t only two positions XR nd XL nd tht w(x) = n R N δ X, XL + n L N δ X, XR tht is, the proility of eing on given side of the ox is given y the rtio of the numer of prticles on tht side of the ox to the totl numer of prticles. Consider the progrm elow. We hve N = 1000 prticles in ox. We strt with rndom frction of the N prticles on the LHS of the ox. If ll prticles on the LHS, then we s one to the RHS. In ll other cses, we then use the Metropolis lgorithm to decide whether we decrese the numer of prticles on the LHS y 1 (increse the numer on the RHS y 1) or vice vers. The rtio r in this cse is the proility of eing on the LHS. rtio = r = w(xl) = n L N Consider the progrm elow: % Metropoplis simultion rnd('seed',sum(100*clock)); N=1000; tmx=10000; nl=round(rnd*n); t=0; p=plot(t,nl,'.','ersemode','none'); xis([0,tmx,0,n]); while (t <= tmx) t=t+1; rtio=nl/n; if (rtio >= 1) nl=nl-1; else if (rnd <= rtio) nl=nl-1; else nl=nl+1; Pge 10

set(p,'xdt',t,'ydt',nl) drwnow The result is: When we run this simultion, we lwys up with pproximtely 1/2 of the prticles on ech side(the equilirium configurtion) nd the simultion ccurtely represents the fluctutions present t equilirium. This exmple illustrtes how chnce or rndom motion cn generte deterministic ehvior. Pge 11