Monte Carlo Methods So far we have discussed Monte Carlo methods based on a uniform distribution of random numbers on the interval [0,1] p(x) = 1 0  x.

Slides:



Advertisements
Similar presentations
Monte Carlo Methods and Statistical Physics
Advertisements

Random Number Generation. Random Number Generators Without random numbers, we cannot do Stochastic Simulation Most computer languages have a subroutine,
Chapter 8 Random-Variate Generation
CHAPTER 16 MARKOV CHAIN MONTE CARLO
Bayesian Reasoning: Markov Chain Monte Carlo
Graduate School of Information Sciences, Tohoku University
Simulation Where real stuff starts. ToC 1.What, transience, stationarity 2.How, discrete event, recurrence 3.Accuracy of output 4.Monte Carlo 5.Random.
Computational statistics 2009 Random walk. Computational statistics 2009 Random walk with absorbing barrier.
Simulation Modeling and Analysis
Machine Learning CUNY Graduate Center Lecture 7b: Sampling.
Random Numbers Dick Steflik. Pseudo Random Numbers In most cases we do not want truly random numbers –most applications need the idea of repeatability.
Statistics.
Generating Continuous Random Variables some. Quasi-random numbers So far, we learned about pseudo-random sequences and a common method for generating.
Random Number Generation
Monte Carlo Integration COS 323 Acknowledgment: Tom Funkhouser.
G. Cowan Lectures on Statistical Data Analysis 1 Statistical Data Analysis: Lecture 8 1Probability, Bayes’ theorem, random variables, pdfs 2Functions of.
Statistical Background
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Parallel Programming in C with MPI and OpenMP Michael J. Quinn.
Continuous Random Variables and Probability Distributions
A) Transformation method (for continuous distributions) U(0,1) : uniform distribution f(x) : arbitrary distribution f(x) dx = U(0,1)(u) du When inverse.
Properties of Random Numbers
The Monte Carlo Method: an Introduction Detlev Reiter Research Centre Jülich (FZJ) D Jülich
Lecture II-2: Probability Review
Principles of the Global Positioning System Lecture 10 Prof. Thomas Herring Room A;
Monte Carlo Integration Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan and Torsten Moller.
ETM 607 – Random Number and Random Variates
1 CE 530 Molecular Simulation Lecture 7 David A. Kofke Department of Chemical Engineering SUNY Buffalo
Simulation of Random Walk How do we investigate this numerically? Choose the step length to be a=1 Use a computer to generate random numbers r i uniformly.
Monte Carlo Methods: Basics
01/24/05© 2005 University of Wisconsin Last Time Raytracing and PBRT Structure Radiometric quantities.
880.P20 Winter 2006 Richard Kass 1 Confidence Intervals and Upper Limits Confidence intervals (CI) are related to confidence limits (CL). To calculate.
Probability theory 2 Tron Anders Moger September 13th 2006.
0 Simulation Modeling and Analysis: Input Analysis K. Salah 8 Generating Random Variates Ref: Law & Kelton, Chapter 8.
Monte Carlo Simulation CWR 6536 Stochastic Subsurface Hydrology.
1 Lesson 3: Choosing from distributions Theory: LLN and Central Limit Theorem Theory: LLN and Central Limit Theorem Choosing from distributions Choosing.
PROBABILITY AND STATISTICS FOR ENGINEERING Hossein Sameti Department of Computer Engineering Sharif University of Technology Two Functions of Two Random.
Machine Learning Lecture 23: Statistical Estimation with Sampling Iain Murray’s MLSS lecture on videolectures.net:

Chapter 7 Random-Number Generation
Module 1: Statistical Issues in Micro simulation Paul Sousa.
1 Lesson 8: Basic Monte Carlo integration We begin the 2 nd phase of our course: Study of general mathematics of MC We begin the 2 nd phase of our course:
Monte Carlo Methods.
Experimental Method and Data Process: “Monte Carlo Method” Presentation # 1 Nafisa Tasneem CHEP,KNU
Monte Carlo Methods1 T Special Course In Information Science II Tomas Ukkonen
APPENDIX D R ANDOM N UMBER G ENERATION Organization of chapter in ISSO* – General description and linear congruential generators Criteria for “good” random.
1 Two Functions of Two Random Variables In the spirit of the previous lecture, let us look at an immediate generalization: Suppose X and Y are two random.
Monté Carlo Simulation  Understand the concept of Monté Carlo Simulation  Learn how to use Monté Carlo Simulation to make good decisions  Learn how.
COMP155 Computer Simulation September 8, States and Events  A state is a condition of a system at some point in time  An event is something that.
Chapter 2 Statistical Background. 2.3 Random Variables and Probability Distributions A variable X is said to be a random variable (rv) if for every real.
Path Integral Quantum Monte Carlo Consider a harmonic oscillator potential a classical particle moves back and forth periodically in such a potential x(t)=
1 Introduction to Statistics − Day 4 Glen Cowan Lecture 1 Probability Random variables, probability densities, etc. Lecture 2 Brief catalogue of probability.
CHAPTER 5 Simulation Modeling. Introduction In many situations a modeler is unable to construct an analytic (symbolic) model adequately explaining the.
1 Chapter 8: Model Inference and Averaging Presented by Hui Fang.
Lecture 3 Types of Probability Distributions Dr Peter Wheale.
G. Cowan Lectures on Statistical Data Analysis Lecture 9 page 1 Statistical Data Analysis: Lecture 9 1Probability, Bayes’ theorem 2Random variables and.
Gil McVean, Department of Statistics Thursday February 12 th 2009 Monte Carlo simulation.
G. Cowan Lectures on Statistical Data Analysis Lecture 5 page 1 Statistical Data Analysis: Lecture 5 1Probability, Bayes’ theorem 2Random variables and.
Kevin Stevenson AST 4762/5765. What is MCMC?  Random sampling algorithm  Estimates model parameters and their uncertainty  Only samples regions of.
0 Simulation Modeling and Analysis: Input Analysis 7 Random Numbers Ref: Law & Kelton, Chapter 7.
Module 9.2 Simulations. Computer simulation Having computer program imitate reality, in order to study situations and make decisions Applications?
Chapter 3 Generating Uniform Random Variables. In any kind of simulation, we need data, or we have to produce them. Especially in Monte Marco simulation.
Introduction to Computer Simulation of Physical Systems (Lecture 10) Numerical and Monte Carlo Methods (CONTINUED) PHYS 3061.
Monte Carlo Integration Digital Image Synthesis Yung-Yu Chuang 12/3/2008 with slides by Pat Hanrahan and Torsten Moller.
Generating Random Variates
Lesson 8: Basic Monte Carlo integration
Basic simulation methodology
Lecture 2 – Monte Carlo method in finance
Computing and Statistical Data Analysis Stat 3: The Monte Carlo Method
Statistical Methods for Data Analysis Random number generators
Monte Carlo Integration
Presentation transcript:

Monte Carlo Methods So far we have discussed Monte Carlo methods based on a uniform distribution of random numbers on the interval [0,1] p(x) = 1 0  x  1 p(x)= 0 otherwise the hit and miss algorithm generates pairs of points (x,y) and either accepts or rejects the point the sample mean method samples points uniformly on the interval [a,b]

Choose p(x) so that f(x)/p(x) is a fairly constant function

Nonuniform probability distributions Consider a probability density p(x) such that p(x)dx is the probability that event x is in the interval between x and x+dx +  We have  p(x) dx = 1 -  x Calculate P(x) =  p(x’) dx’ = r =  dr -  p(x’)dx’ = dr ==> p(x’)= dr/dx’ r is a uniform random number on the interval [0,1] Invert this and solve for x in terms of r

Eg.1 suppose we want p(x)= 1/(b-a), a  x  b = 0 otherwise x Calculate P(x) =  p(x’) dx’ a r = (x-a)/(b-a) Solving for x, x= a + (b-a) r obvious!

Eg.2 p(x) = (1/ ) exp(-x/ ), [0,  ] = 0 x < 0 Hence r = P(x) = 1 - exp(-x/ ) And x = - ln(1-r) = - ln(r) This technique is only feasible if the inversion process can be carried out.

Eg.3 p(x) = (1/ 2  2 ) 1/2 exp(-x 2 /2  2 ) P(x) = ? However the two-dimensional distribution p(x,y)dxdy = (1/ 2  2 ) exp(-(x 2 +y 2 )/2  2 )dxdy can be integrated by a change of variable  = r 2 /2= (x 2 +y 2 )/2  2, tan  =y/x p( ,  )d  d  = (1/2  ) exp(-  )d  d  Generate  uniformly on the interval [0,2  ] i.e.  = 2  r Generate  according to the exponential distribution with = 1 i.e.  = -ln r x= (2  2 ) 1/2 cos  and y=(2  2 ) 1/2 sin  are Gaussian distributed

Importance Sampling The error estimate in Monte Carlo is proportional to the variance of the integrand: ( - 2 ) 1/2 n 1/2 How can we reduce the variance? b Introduce a function p(x) such that  p(x)dx = 1 a b And rewrite F =  [f(x)/p(x)] p(x) dx a

Importance Sampling Evaluate the integral by sampling according to p(x): F n = (1/n)  f(x i )/p(x i ) Choose p(x) to minimize variance of f(x)/p(x) i.e try to make f(x)/p(x) slowly varying since a constant has zero variance

1 eg. F =  exp(-x 2 ) dx = Sample [0,1] uniformly n F n  n Choose p(x)= A exp(-x) and sample [0,1] again n F n  n The variance of the integrand is reduced by about a factor of 4 which means that fewer samplings are needed to obtain the same accuracy.

c Program Importance Sampling n=10000 h=1. a=0. b=1. sum=0. psum=0. sum2=0. psum2=0. m=2 do 4 i=1,n ww=r250(idum) x=a+b*ww y=-log(1.-ww+ww*exp(-1.)) g=exp(-y*y) p=(1.-ww+ww*exp(-1.))/(1.-exp(-1.)) f=exp(-x*x) sum=sum+f psum=psum+g/p sum2=sum2+f*f psum2=psum2+(g*g)/(p*p) sig2=sum2/i -(sum/i)*(sum/i) sig=sqrt(sig2) psig2=psum2/i -(psum/i)*(psum/i) psig=sqrt(psig2) if((i-(i/10**m)*10**m).eq.0) then write(6,10) 1.*i,sum/i,sig,psum/i,psig m=m+1 else continue end if 10 format(1x,f10.0,3x,f10.5,3x,f10.5,3x,f10.5,3x,f10.5) 4 continue stop end

The above ideas can be used to simulate many different types of physical problems Random walks and polymers Percolation Fractal growth Complexity and neural networks Phase Transitions and Critical Phenomena

Monte Carlo Methods Random numbers generated by the computer are used to simulate naturally random processes many previously intractable thermodynamic and quantum mechanics problems have been solved using Monte Carlo techniques how do we know is the random numbers are really random?

Random Sequences A sequence of numbers r 1,r 2,… is random if there are no correlations among the numbers in the sequence however most random number generators yield a sequence in which each number is used to find the succeeding one according to a well defined algorithm the most widely used random number generator is based on the linear congruential method

where a,c and m are integers the notation y= z mod m means that m is subtracted from z until 0  y <m the process is characterized by the multiplier a, the increment c and the modulus m since m is largest integer generated by this method, the maximum possible period is m Given a seed x 0, each number in the sequence is determined by the one-dimensional map

Example a=3 c=4 m=32 and x 0 =1 produces x1=(3 x 1 + 4) mod32 = 7 x2=(3 x 7 + 4) mod32 = 25 x3=(3 x 25 +4) mod32= 79mod32=15 and so on …. 1,7,25,15,17,23,9,31,1,7,25,…. period is 8! Rather than the maximum of 32

Random Sequences If we choose a, c and m carefully then all numbers in the range from 0 to m-1 will appear in the sequence to have the numbers in the range 0  r <1, the generator returns x m /m which is always < 1 there is no necessary and sufficient test for the randomness of a finite sequence of numbers we need to consider various tests an obvious requirement for a random number generator is that its period be much greater than the number of random numbers needed in a specific problem

Sequences A way of visualizing the period is to consider a random walker and plot the displacement as a function of the number of steps N when the period of the random number generator is reached the plot will begin to repeat itself consider a=899, c=0, m=32768 with x 0 =12 Sequence

Correlations We can check for correlations by plotting x i+k as a function of x i if there are any obvious patterns in the plot then there are correlations correlations

Uniformity test

Correlations One way to reduce sequential correlation and to lengthen the period is to mix or shuffle two different random number generators statistical tests should be performed on random number generators for serious calculations

Exploration It has been claimed that the logistic map in the chaotic region is a good random number generator test this for yourself x i+1 = 4x i (1 - x i ) will make the sequence uniform