Today: Fundamentals of Monte Carlo

Similar documents
Today: Fundamentals of Monte Carlo

Today: Fundamentals of Monte Carlo

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

André Schleife Department of Materials Science and Engineering

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

Numerical integration and importance sampling

Monte Carlo Methods in High Energy Physics I

Structural Reliability

Cheng Soon Ong & Christian Walder. Canberra February June 2018

Dimensionality Reduction and Principle Components

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

16 : Markov Chain Monte Carlo (MCMC)

8 STOCHASTIC SIMULATION

Lecture 6: Monte-Carlo methods

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

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

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

Transformation of Probability Densities

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

A6523 Modeling, Inference, and Mining Jim Cordes, Cornell University

Modern Methods of Data Analysis - WS 07/08

Applicability of Quasi-Monte Carlo for lattice systems

Kinetic Theory 1 / Probabilities

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

Preliminary statistics

Reduction of Variance. Importance Sampling

Computer Vision Group Prof. Daniel Cremers. 11. Sampling Methods

Differentiation and Integration

Polynomial Chaos and Karhunen-Loeve Expansion

Probability and Statistics

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

Monte Carlo integration (naive Monte Carlo)

Brief introduction to Markov Chain Monte Carlo

Name of the Student: Problems on Discrete & Continuous R.Vs

SUMMARY OF PROBABILITY CONCEPTS SO FAR (SUPPLEMENT FOR MA416)

ELEG 3143 Probability & Stochastic Process Ch. 4 Multiple Random Variables

Monte Caro simulations

Continuous Random Variables

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

component risk analysis

Lecture 6 Positive Definite Matrices

Introduction. Spatial Processes & Spatial Patterns

Lecture 2 : CS6205 Advanced Modeling and Simulation

Monte Carlo Integration I

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

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

Monte Carlo and cold gases. Lode Pollet.

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

Name: Class: Math 7B Date:

Chapter 2. First-Order Differential Equations

Basics of Stochastic Modeling: Part II

2 Functions of random variables

Kinetic Theory 1 / Probabilities

Monte Carlo Simulations

Robert Collins CSE586, PSU Intro to Sampling Methods

ELEG 3143 Probability & Stochastic Process Ch. 6 Stochastic Process

Name of the Student: Problems on Discrete & Continuous R.Vs

Bayesian Regression Linear and Logistic Regression

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

EM Algorithm & High Dimensional Data

6 Markov Chain Monte Carlo (MCMC)

Numerical Methods I Monte Carlo Methods

However, reliability analysis is not limited to calculation of the probability of failure.

LECTURE NOTES ELEMENTARY NUMERICAL METHODS. Eusebius Doedel

MAS1302 Computational Probability and Statistics

P 1.5 X 4.5 / X 2 and (iii) The smallest value of n for

Numerical methods for lattice field theory

Previously Monte Carlo Integration

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

Probability Methods in Civil Engineering Prof. Rajib Maity Department of Civil Engineering Indian Institute of Technology, Kharagpur

Properties of surfaces II: Second moment of area

The Binomial distribution. Probability theory 2. Example. The Binomial distribution

Dimensionality Reduction and Principal Components

Scientific Computing: Monte Carlo

p(z)

Advanced Monte Carlo Methods Problems

Basic Statistical Tools

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

Multiple Random Variables

Probability Review. Gonzalo Mateos

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

n N CHAPTER 1 Atoms Thermodynamics Molecules Statistical Thermodynamics (S.T.)

6.1 Moment Generating and Characteristic Functions

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

CSC 446 Notes: Lecture 13

In manycomputationaleconomicapplications, one must compute thede nite n

functions Poisson distribution Normal distribution Arbitrary functions

General Random Variables

Probing the covariance matrix

PHYS 6710: Nuclear and Particle Physics II

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

1: PROBABILITY REVIEW

GATE Engineering Mathematics SAMPLE STUDY MATERIAL. Postal Correspondence Course GATE. Engineering. Mathematics GATE ENGINEERING MATHEMATICS

Linear Regression and Its Applications

in Computer Simulations for Bioinformatics

CSCI-6971 Lecture Notes: Monte Carlo integration

Statistical Methods in Particle Physics

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

Transcription:

Today: Fundamentals of Monte Carlo What is Monte Carlo? Named at Los Alamos in 1940 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. 1

Simple example: Buffon s needle Monte Carlo determination of Pi Consider a square inscribed by circle. Consider one quadrant. By geometry: area of 1/4 circle = π r 2 /4 = π /4. area of square r 2 Simple MC like throwing darts at unit square target: Using RNG ~ (0,1), pick a pair of coordinates (x,y). Count # of points (darts) in shaded section versus total. Pts in shaded circle/pts in square ~ π /4. Code Snippet hits = 0 DO n=1,n{ x = (random #) y = (random #) distance2 = (x 2 + y 2 ) If (distance2 1) hits = hits + 1} 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: By conventional deterministic methods: Lay out a grid with L points in each direction with h=1/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 + (1/2)f (x 0 )h 2 + direct CPU time ~ ε -D/2. (ε~h 2 and CPU~h D ) But by sampling we find ε -2. (ε~n -1/2 and CPU~N) To get another decimal place takes 100 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., 1-D like 1/L and 2-D like 1/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=1/l Number of points is N=h D =L D ~ CPU time. Stochastic Integration (Monte Carlo) Monte Carlo: ε ~ M -1/2 (sqrt of sampled points) CPU time: T ~ M ~ ε -2. > In the limit of small ε, MC wins if D > 2α! 4

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 1947 5

Probability Distributions P(x)dx= probability of observing a value in (x,x+dx) is a probability distribution function (p.d.f.) x can be either a continuous or discrete variable. Cumulative distribution: Probability of x<y. Useful for sampling Average or expectation Moments: Zero th moment I 0 =1 Mean <x>=i 1 Variance <(x-<x>) 2 > =I 2 -(I 1 ) 2 6

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 1, so y 0 What is the pdf of y? With p y (y)dy=p x (x)dx x What happens when g is not monotonic? Example: y=g(x) = ln(x) *Distributed exponentially, like in Poisson event, e.g. y/λ has PDF of λe λy 7

What is Mapping Doing? Generate random deviate 1 Uniform deviate in PDF is normalized Let p(y)=f(y), then y(x) = C 1 (x) a functional inverse of c(y). Thus, dx/dy = f(y) or x=c(y) y c(y) = d y f ( y ) o x p(y) = f(y) 0 y transformed deviate out 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,1) such that its corresponding y on the definite-integral curve is desired deviate, i.e. x = c(y). 8

Interpreting the Mapping Let p(y)=f(y), then y(x) = C 1 (x), dx/dy = f(y) and x=c(y) 1 Uniform deviate in y c(y) = d y f ( y ) o x p(y) = f(y) 0 y transformed deviate out Since c(y) is area under p(y)=f(y), y(x) = C 1 (x) prescribes that Choose x=(0,1], then find value y that has that fraction x of area to left of y, or x=c(y) Return that value of y. Example: Drawing from Poisson Distribution y= ln(x)/λ, p(y)= λe λy and x=f(y) = 1 e λy Note: x = 1 e λy or x = 1- x = e λy (with x =(0,1]). So, indeed, y(x) = ln(x )/λ 9

Example: Drawing from Normal Gaussian Box-Muller method: get random deviates with normal distr. Consider: uniform deviates (0,1), x 1 and x 2, and two quantities y 1 and y 2. Or, equivalently, where So, each y is independently normal distributed. Better: Pick Advantage: no sine and cosine by using v 1 / R 2 and v 2 / R 2 and And get two RNG per calculation (1 for now, 2 for next time) 10

Reminder: Gauss Central Limit Theorem Sample N values from p(x)dx, i.e. (X 1, X 2, X 3, X N ). Estimate mean from y = (1/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: Then Taylor expand cumulants 11

Cumulants: κ n Mean = κ 1 =<x> = x Variance= κ 2 =<(x-x) 2 > = 2 Skewness = κ 3 / 3 =<((x-x)/ ) 3 > Kurtosis= κ 4 / 4 =<((x-x)/ ) 4 >-3 What happens to the reduced moments? The n=1 moment remains invariant. The rest get reduced by higher powers of N. Given enough averaging almost anything becomes a Gaussian distribution. 12

Approach to normality Gauss Central Limit Thm For any population distribution, the distribution of the mean will approach Gaussian. 13

Conditions on Central Limit Theorem We need the first three moments to exist. If I 0 is not defined -> not a pdf If I 1 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 We need: Divergence because of singular behavior of P at finite x: 14

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: 15

2d histogram of occurrences of means x 2 Off-diagonal components of v ij are called the co-variance. Data can be uncorrelated, positively or negatively correlated depending on sign of v ij Like a moment of inertia tensor 2 principal axes with variances Find axes with diagonalization or singular value decomposition Eigenvectors of covariance matrix x 1 Individual error bars on x 1 and x 2 can be misleading if correlated. 16