Today: Fundamentals of Monte Carlo

Similar documents
Today: Fundamentals of Monte Carlo

Today: Fundamentals of Monte Carlo

Sampling Distributions Allen & Tildesley pgs and Numerical Recipes on random numbers

Data Analysis I. Dr Martin Hendry, Dept of Physics and Astronomy University of Glasgow, UK. 10 lectures, beginning October 2006

Numerical integration - I. M. Peressi - UniTS - Laurea Magistrale in Physics Laboratory of Computational Physics - Unit V

[POLS 8500] Review of Linear Algebra, Probability and Information Theory

Monte Carlo Simulations

16 : Markov Chain Monte Carlo (MCMC)

Structural Reliability

2 Functions of random variables

Chapter 2. Some Basic Probability Concepts. 2.1 Experiments, Outcomes and Random Variables

conditional cdf, conditional pdf, total probability theorem?

Note: Final Exam is at 10:45 on Tuesday, 5/3/11 (This is the Final Exam time reserved for our labs). From Practice Test I

Physics 116C The Distribution of the Sum of Random Variables

Stochastic Processes for Physicists

André Schleife Department of Materials Science and Engineering

From Random Numbers to Monte Carlo. Random Numbers, Random Walks, Diffusion, Monte Carlo integration, and all that

P (x). all other X j =x j. If X is a continuous random vector (see p.172), then the marginal distributions of X i are: f(x)dx 1 dx n

UNIVERSITY OF HOUSTON HIGH SCHOOL MATHEMATICS CONTEST Spring 2018 Calculus Test

Monte Carlo Integration. Computer Graphics CMU /15-662, Fall 2016

Sampling Distributions Allen & Tildesley pgs and Numerical Recipes on random numbers

Multivariate Distribution Models

Grade: The remainder of this page has been left blank for your workings. VERSION D. Midterm D: Page 1 of 12

Lecture Notes 1 Probability and Random Variables. Conditional Probability and Independence. Functions of a Random Variable

The Gaussian distribution

Statistics, Data Analysis, and Simulation SS 2015

Preliminary statistics

Bayesian Methods with Monte Carlo Markov Chains II

18.440: Lecture 28 Lectures Review

Lecture 2 : CS6205 Advanced Modeling and Simulation

Transformation of Probability Densities

Monte Carlo and cold gases. Lode Pollet.

A6523 Signal Modeling, Statistical Inference and Data Mining in Astrophysics Spring 2011

Reduction of Variance. Importance Sampling

Multiple Random Variables

Monte Carlo Methods in High Energy Physics I

Random processes and probability distributions. Phys 420/580 Lecture 20

Cheng Soon Ong & Christian Walder. Canberra February June 2018

8 STOCHASTIC SIMULATION

Lecture Notes 1 Probability and Random Variables. Conditional Probability and Independence. Functions of a Random Variable

Numerical integration and importance sampling

Series Solution of Linear Ordinary Differential Equations

EE4601 Communication Systems

Winter 2019 Math 106 Topics in Applied Mathematics. Lecture 9: Markov Chain Monte Carlo

Monte Carlo integration (naive Monte Carlo)

Monte Carlo. Lecture 15 4/9/18. Harvard SEAS AP 275 Atomistic Modeling of Materials Boris Kozinsky

E[X n ]= dn dt n M X(t). ). What is the mgf? Solution. Found this the other day in the Kernel matching exercise: 1 M X (t) =

AP Calculus Chapter 9: Infinite Series

SUMMARY OF PROBABILITY CONCEPTS SO FAR (SUPPLEMENT FOR MA416)

Numerical Methods I Monte Carlo Methods

Introduction. Microscopic Theories of Nuclear Structure, Dynamics and Electroweak Currents June 12-30, 2017, ECT*, Trento, Italy

Math Exam III - Spring

A Probability Review

functions Poisson distribution Normal distribution Arbitrary functions

STA 256: Statistics and Probability I

component risk analysis

Let X and Y denote two random variables. The joint distribution of these random

ECE295, Data Assimila0on and Inverse Problems, Spring 2015

( x) ( ) F ( ) ( ) ( ) Prob( ) ( ) ( ) X x F x f s ds

Stochastic Processes. M. Sami Fadali Professor of Electrical Engineering University of Nevada, Reno

Lecture 6: Monte-Carlo methods

p(z)

MA/ST 810 Mathematical-Statistical Modeling and Analysis of Complex Systems

2 (Statistics) Random variables

ELEG 3143 Probability & Stochastic Process Ch. 6 Stochastic Process

3 Operations on One R.V. - Expectation

Exponential Family and Maximum Likelihood, Gaussian Mixture Models and the EM Algorithm. by Korbinian Schwinger

Review: mostly probability and some statistics

Markov Chains CK eqns Classes Hitting times Rec./trans. Strong Markov Stat. distr. Reversibility * Markov Chains

Random Variables. Random variables. A numerically valued map X of an outcome ω from a sample space Ω to the real line R

Probability and Statistics

Math 122L. Additional Homework Problems. Prepared by Sarah Schott

Dennis Bricker Dept of Mechanical & Industrial Engineering The University of Iowa

Chapter 2. Random Variable. Define single random variables in terms of their PDF and CDF, and calculate moments such as the mean and variance.

Expectation. DS GA 1002 Probability and Statistics for Data Science. Carlos Fernandez-Granda

Physics 403. Segev BenZvi. Parameter Estimation, Correlations, and Error Bars. Department of Physics and Astronomy University of Rochester

Monte Carlo Integration I

Continuous Random Variables

Quiz Solutions, Math 136, Sec 6, 7, 16. Spring, Warm-up Problems - Review

Chapter 5,6 Multiple RandomVariables

Dimensionality Reduction and Principle Components

MATH 307: Problem Set #3 Solutions

1 Review of di erential calculus

Chapter 3, 4 Random Variables ENCS Probability and Stochastic Processes. Concordia University

ECE Lecture #10 Overview

Infinite series, improper integrals, and Taylor series

L2: Review of probability and statistics

Lecture 1: August 28

Part IA Probability. Definitions. Based on lectures by R. Weber Notes taken by Dexter Chua. Lent 2015

Chapter 4. Continuous Random Variables 4.1 PDF

Review of Probability Theory

If the objects are replaced there are n choices each time yielding n r ways. n C r and in the textbook by g(n, r).

3. Probability and Statistics

Chapter 3: Random Variables 1

Brandon C. Kelly (Harvard Smithsonian Center for Astrophysics)

Name Class. (a) (b) (c) 4 t4 3 C

Algorithms for Uncertainty Quantification

Expectation. DS GA 1002 Statistical and Mathematical Models. Carlos Fernandez-Granda

Brief introduction to Markov Chain Monte Carlo

LECTURE NOTES ELEMENTARY NUMERICAL METHODS. Eusebius Doedel

Transcription:

Today: Fundamentals of Monte Carlo What is Monte Carlo? Named at Los Alamos in 940 s after the casino. Any method which uses (pseudo)random numbers as an essential part of the algorithm. Stochastic - not deterministic! A method for doing highly dimensional integrals by sampling the integrand. Often a Markov chain, called Metropolis MC. Simple example: Buffon s needle Monte Carlo determination of Consider a square inscribed by circle. Consider one quadrant. By geometry: area of /4 circle = r 2 /4 = /4. area of square r 2 Simple MC like throwing darts at unit square target: Using RNG (0,), pick a pair of coordinates (x,y). Count # of points (darts) in shaded section versus total. Pts in shaded circle/pts in square ~ /4. hits = 0 DO n=,n{ x = (random #) y = (random #) distance2 = (x 2 + y 2 ) If (distance2 ) hits = hits + } pi= 4 * hits/n 2

MC is advantageous for high dimensional integrals -the best general method Consider an integral in the unit D-dimensional hypercube: I dx...dx D f (x,...,x D ) By conventional deterministic methods: Lay out a grid with L points in each direction with h=/l Number of points is N =L D =h D CPU time. How does error scale with CPU time or Dimensionality? Error in trapezoidal rule goes as =f (x) h 2 since f(x)=f(x 0 ) + f (x 0 ) h + (/2)f (x 0 )h 2 + direct CPU time -D/2. (~h 2 and CPU~h D ) But by sampling we find -2. (~M -/2 and CPU~M) To get another decimal place takes 00 times longer! But MC is advantageous for D>4! 3 Improved Numerical Integration Integration methods in D-dimensions: Trapeziodal Rule: ~ f (2) (x) h 2 Simpson s Rule: ~ f (4) (x) h 4 generally: ~ f () (x) h And CPU time scales with sample points (grid size) CPU time ~ h -D (e.g., -D like /L and 2-D like /L 2 ) Time to do integral: T int ~ -D/ By conventional deterministic methods: Lay out a grid with L points in each direction with h=/l Number of points is N=h D =L D CPU time. Stochastic Integration (Monte Carlo) Monte Carlo: ~ M -/2 (sqrt of sampled points) CPU time: T ~ M -2. > In the limit of small, MC wins if D > 2! 4 2

4D 6D 8D Log(CPU Time) 2D MC Good Log(error) Bad Other reasons to do Monte Carlo: Conceptually and practically simple. Comes with built in error bars. Many methods of integration have been tried, and will be tried in this world of sin and woe. No one pretends that Monte Carlo is perfect or all-wise. Indeed, it has been said that Monte Carlo is the worst method except all those other methods that have been tried from time to time. Churchill 947 5 Probability Distributions P(x)dx= probability of observing a value in (x,x+dx) is a probability distribution function (p.d.f.) dx P(x) P(x) 0 x can be either a continuous or discrete variable. Cumulative distribution: Probability of x<y. y c( y) dx Useful for sampling P(x) 0 c( y) Average or expectation Moments: Zero th moment I 0 = Mean <x>=i Variance <(x-<x>) 2 >=I 2 -(I ) 2 g(x) g I n x n dx P(x)g(x) dx P(x)x n 6 3

Mappings of random variables Let p x (x)dx be a probability distribution Let y=g(x) be a new variable y=g(x) -- e.g., y=g(x) = ln(x) with 0 < x soy, 0 What is the pdf of y? With p y (y)dy=p x (x)dx p y (y) p x (x) dx dy p x(x) dx dg(x) p x(x) dg(x) dx x What happens when g is not monotonic? x Example: y=g(x) = ln(x) p y (y)dy p x (x) dg(x) dx dy e y dy *Distributed exponentially, like in Poisson event, e.g. y/ has PDF of e y 7 What is Mapping Doing? Generate random deviate p(x)dx dx 0 x 0 otherswise p(x) dx PDF is normalized Let p(y)=f(y), (y), then y(x) = F (x) )(functional inverse), dx/dy = f(y) or x=f(y) F(y) = 0y dy f(y ) Uniform deviate in x 0 y transformed deviate out p(y) = f(y) Allows a random deviate y from a known probability distribution p(y). The indefinite integral of p(y) must be known and invertible. A uniform deviate x is chosen from (0,) such that its corresponding y on the definite-integral curve is desired deviate, i.e. x = F(y). 8 4

Interpreting the Mapping Let p(y)=f(y), then y(x) = F (x), dx/dy = f(y) and x=f(y) Uniform deviate in x 0 y transformed deviate out F(y) = 0y dy f(y ) p(y) = f(y) Since F(y) is area under p(y)=f(y), y(x) = F (x) prescribes that Choose x=(0,], then find value y that has that fraction x of area to left of y, or x=f(y) Return that value of y. Example: Drawing from Poisson Distribution y= ln(x)/, p(y)= e y and x=f(y) = e y Note: x= e y or x = - x = e y (which is still x =(0,]). So, indeed, y(x) = ln(x )/ 9 Example: Drawing from Normal Gaussian p(y, y 2,...)dy dy 2... p(x, x 2,...) (x, x 2,...) (y, y 2,...) dy dy 2... Box-Muller method: get random deviates with normal distr. p(y)dy 2 e y 2 /2 dy Consider: uniform deviates (0,), x and x 2, and two quantities y and y 2. where y ln x cos2 x 2 y 2 ln x sin 2 x 2 Or, equivalently, x exp([y 2 y 2 2 ]/2) x 2 2 arctan(y 2 / y ) (x, x 2,...) 2 2 (y, y 2,...) 2 e y /2 2 e y 2 /2 So, each y is independently normal distributed. Better: Pick R 2 v 2 v 2 2 so x R 2 and (v,v 2 ) 2 x 2 Advantage: no sine and cosine by using v / R 2 and v 2 / R 2 and And get two RNG per calculation ( for now, 2 for next time) 0 5

Reminder: Gauss Central Limit Theorem Sample N values from p(x)dx, i.e. (X, X 2, X 3, X N ). Estimate mean from y = (/N) x i. What is the pdf of mean? Solve by fourier transforms. If you add together two random variables, you multiply together their characteristic functions: c x (k) e ikx dx P(x)e ikx so c x y (k) c x (k)c y (k) Then c x (k) c (k) N and c (k) c (k / N) N x... x N ) x y x Taylor expand ln[c y (k)] n (ik) n n! n cumulants Cumulants: n Mean = =<x> = x Variance= 2 =<(x-x) 2 > = 2 Skewness = 3 / 3 =<((x-x)/) 3 > Kurtosis= 4 / =<((x-x)/) 4 >-3 n What happens to the reduced d moments? n N n The n= moment remains invariant. The rest get reduced by higher powers of N. lim N c y (k) e ik k 2 2 /2N ik 3 3 /6N 2... P( y) (N /2 2 ) /2 exp N( y )2 2 2 Given enough averaging almost anything becomes a Gaussian distribution. 2 6

Approach to normality Gauss Central Limit Thm For any population distribution, the distribution of the mean will approach Gaussian. 3 Conditions on Central Limit Theorem I n x n dx P(x)x n We need the first three moments to exist. If I 0 is not defined not a pdf If I does not exist not mathematically well-posed. If I 2 does not exist infinite variance. Important to know if variance is finite for Monte Carlo. Divergence could happen because of tails of distribution I 2 x 2 dx P(x)x 2 We need: lim x x 3 P(x) 0 Divergence because of singular behavior of P at finite x: lim x0 xp(x) 0 4 7

Multidimensional Generalization Suppose r is an m dimensional vector from a multidimensional pdf: p(r)d m r. The mean is defined as before. The variance becomes the covariance, a positive symmetric m x m matrix : V i,j = <(x i -< x i >)(x j -< x j >)> For sufficiently large N, the estimated mean (y) will approach the distribution: P(y)dy 2 /2 N det(v) exp[(y i y i ) Nv 2 (y y j j )] 5 2d histogram of occurrences of means x 2 Off-diagonal components of ij are called the co-variance. Data can be uncorrelated, positively or negatively correlated depending on sign of ij Like a moment of inertia tensor 2 principal axes with variances Find axes with diagonalization or singular value decomposition x Individual error bars on x and x 2 can be misleading if correlated. 6 8