Monte Carlo integration (naive Monte Carlo)

Size: px
Start display at page:

Download "Monte Carlo integration (naive Monte Carlo)"

Transcription

1 Monte Carlo integration (naive Monte Carlo) Example: Calculate π by MC integration [xpi] 1/21 INTEGER n total # of points INTEGER i INTEGER nu # of points in a circle REAL x,y coordinates of a point in a sphere REAL rnd(-1,1) function returning a random number in interval [ 1, 1) nu := 0 FOR i := 1 TO n DO x := rnd(-1,1) y := rnd(-1,1) IF x*x+y*y < 1 THEN nu := nu + 1 PRINT "pi=", 4*nu/n area of square = 4 PRINT "std. error=", 4*sqrt((1-nu/n)*(nu/n)/(n-1)) Also random shooting. Generally Ω f(x 1,..., x D ) dx 1... dx D Ω K K k=1 f(x (k) 1,..., x(k) D ) where (x (k) 1,..., x(k) D ) is a random vector from region Ω ( Ω = area, volume,... ; calculation of π: Ω = ( 1, 1) 2, Ω = 4)

2 Exercise Buffon s needle Let a needle of length l be dropped randomly on a plane ruled with parallel lines d units apart, l d. The probability that the needle crosses a line is p = 2l/πd. 2/21 Proof: expression (a < b) gives 1, if the inequality holds true, 0 otherwise p = 1 d/2 d/2 0 dz 1 π/2 π/2 0 dθ (z < l2 ) cos θ = 1 1 d/2π/2 π/2 0 l 2 cos θdθ = 2l πd Usage (δp is the standard error of p) π 2l pd, where p = n crosses n total, grid: pic/buffon-grid.pdf and buffon.sh δp p(1 p) n 1, 2l δπ = pd δp p rel. error

3 Exercises + 3/21 Easy. Calculate by Monte Carlo integration: 1 r r 0 d r where r 0 = (1, 1, 1) x>0,y>0,z>0,x+y+z< Hard. Calculate by Monte Carlo integration the second virial coefficient of the Lennard-Jones diatomics (ɛ/k B T = 1, σ = 1) for bond length L = σ. B 2 = 1 [ ( exp u ) ] 1 d r dω 1 dω 2 2 k B T 4π 4π u = u LJ ( r 1A r 2A ) + u LJ ( r 1A r 2B ) + u LJ ( r 1B r 2A ) + u LJ ( r 1B r 2B ) Hints: d r 4πr 2 dr substitution r = 1/u 1 dω i = d cos θ i dφ i 1.24

4 Importance sampling 4/21 e βu( r N) f( r N ) 1 K K k=1 f( r N,(k) ) where r N,(k) is a random vector with a probability density e βu( rn). Metropolis algorithm: r N,(k+1) generated sequentially from r N,(k) naive MC importance sampling

5 Metropolis method (intuitively) 5/21 Choose a particle, i (e.g., randomly) Try to move it, e.g.: x tr i = x i + u ( d,d), y tr i = y i + u ( d,d), z tr i = z i + u ( d,d) so that the probability of the reversed move is the same Calculate the change in the potential energy, U = U tr U or in/on sphere, Gaussian,... If U 0, the change is accepted If U 0, the change is accepted with probability exp( β U) Why? Because then it holds for the probability ratio: new : old = p tr : p = exp( β U) (moves there and back are compared, always the probability of one move = 1, and of the other = Boltzmann probability)

6 A bit of theory: random variables 6/21 Random variable S gives values in {A i }, i = 1,... M, with probabilities π(a i ) = π i. Normalization: i π i = 1 Markov chain is a sequence S (k), k = 1,..., such that S (k+1) depends only on S (k), or mathematically π (k+1) j = Normalization: M i=1 π (k) i W i j vector notation: π (k+1) = π (k) W M W i j = 1 j=1 for all i

7 Example [xoctave../octave/markov.m MARKOV] 7/21 Computer network: { 1. in order 2. out of order If in order: will crash with 10% probability (the following day is out of order) If out of order: gets fixed with 30% probability (the following day is in order) ( ) W = lim k π (k) = (0.75, 0.25) Profit: { 2000 in order 500 out of order X = ( Averaged profit = π i X i = π X = 1625 )

8 Detailed balance and microreversibility 8/21 We are looking for W, so that π i = exp[ βu(a i)] i exp[ βu(a i)] Conditions: W i j 0 for all i, j = 1,..., M M W i j = 1 for all i = 1,..., M j=1 π W = π sometimes detailed balance π i W i j = π j W j i microscopic reversibility (detailed balance) If: all states are accessible from an arbitrary state in a finite number of steps with a nonzero probability and no state is periodic then the set of states is called ergodic and for any initial state probability distribution π (1) there exists a limit π = lim k π (k)

9 Metropolis again 9/21 One of solutions (Metropolis): α i j for i j a π j π i W i j = π j α i j π i 1 k, k i W i k for i j a π j < π i for i = j Equivalent form: W i j = α i j min { 1, π } j π i for i j where matrix α i j = α j i describes a trial change of a configuration... equivalent to the algorithm given above

10 Algorithm details 10/21 Choose a particle (lattice site,... ) to move A tr := A (k) + random move (spin) of the chosen particle U := U(A tr ) U(A (k) ) U tr U (k) The configuration is accepted (A (k+1) := A tr ) with probability min{1, e β U } otherwise rejected: Version 1 Version 2 Version 3 u := u (0,1) u := u (0,1) IF U < 0 IF u < min{1, e β U } IF u < e β U THEN A (k+1) := A tr THEN A (k+1) := A tr THEN A (k+1) := A tr ELSE ELSE A (k+1) := A (k) ELSE A (k+1) := A (k) u := u (0,1) IF u < e β U k := k + 1 and again and again THEN A (k+1) := A tr ELSE A (k+1) := A (k)

11 [start z-vitezneho-oblouku.mov] 11/21 How to choose a particle to move In a cycle check the reversibility! Deterring examples of microreversibility violation: Three species A, B, C in a ternary mixture moved sequentially in the order of A B C A B C Sequence: move molecule A move molecule B change volume Randomly Chaos is better than bad control

12 Heat-bath method + 12/21 good for lattice models: Usually: W i j = exp( βu j ) A k C part exp( βu k ) for A i, A j C part choose spin/lattice site choose a new spin value with a Boltzmann probability (it depends on the neighbourhood)

13 Acceptance ratio 13/21 χ = number of accepted configurations number of all configurations χ depends on the displament d. Optimal χ depends on the system, quantity, algorithm. Often 0.3 is a good choice. Exception: diluted systems δp d LJ (reduced units): T = 1.2, ρ = χ

14 Exercise 14/21 Write a computer code for one molecule of nitrogen in a gravitational field. Use temperature T = 300 K. Determine the pressure at elevation of 8850 m and the acceptance ratio. Hint: a suitable displacement length is about 30 km. The potential of a molecule is u(z) = { for z < 0 mgz for z bar If you get bored: Determine the optimum trial displacement z with respect to the averaged height z. Note: it is necessary to measure z including the statistical error and to set z to minimize the error. cca. 30 km, ξ = 0.3

15 (Pseudo)random numbers [simul/ibm.sh 10000] 15/21 r i = F(r i 1, r i 2,..., r i m ) Requirements: the period (smallest number p such that r i+p = r i ) is as long as possible; distribution r i is (in an interval given) uniform, particularly: also the lowest bits are random; (r i, r i+1 ), triplets (r i, r i+1, r i+2 ), etc., are uncorrelated; the same holds for all functions f i : pairs (f 0 (r i ), f 1 (r i 1 )), triplets (f 0 (r i ), f 1 (r i+1 ), f 2 (r i+2 )), etc., are uncorrelated; the code is fast. IBM: K( , 2 31 )

16 Feedback shift-register generators 16/21 R(A, B, C,...) : r i = r i A r i B r i C..., = addition modulo 2 = XOR: 0 0 = 1 1 = 0, 1 0 = 0 1 = 1 Max. period is 2 max(a,b...) 1 A word (32 or 64 bits) at once E.g., R(108, 250), R(471, 1586, 6988, 9689) Example. R(5, 2): 1 step: = 0 more steps: here period = = 31 (maximum possible)

17 Feedback shift-register generators + 17/21 Algorithm: CONST A=103 CONST B=205 CONST M=255 where M is the smallest number of form 2 k 1 so that B M INTEGER n unsigned integer INTEGER r[0..m] array, filled in advance by random numbers of any origin one step generating a random number (all bits): n := n+1 r[n and M] := r[(n-a) and M] xor r[(n-b) and M] where and and xor work bitwise RETURN r[n and M] The code is especially simple as a C/C++ macro: #define rnd (++n, r[n&m] = r[(n-a)&m] ^ r[(n-b)&m]) Pros: fast, mathematical theory for the perion and correlations Cons: fails with some tests,, e.g., the random walk Remedy #1: combine two of them (still fast) Remedy #2: Mersenne twister (high quality, popular)

18 Congruence generators [simul/kongr.sh] 18/21 K(C, M) : r i = Cr i 1 mod M where A mod B is a reminder after division A/B K(5 7, 2 32 ): period 2 32 /8 K(7 5, ): period Example. K(5, 31): Suppression of correlations combine 2 generators Declare a table and fill it by random numbers using generator #1 take randomly selected (index = random number using generator #2) item of the table replace the used number by a new random number using generator #1

19 Other distributions 19/21 Library functions usually give random number u (0,1), uniformly distributed in (0, 1) (or [0, 1) or [0, 1] be careful!), i.e., φ(x) = { 1, x (0, 1) 0, x (0, 1) A number uniformly distributed in interval (a, b) is u (a,b) = a + (b a)u (0,1). Generally: function f(u) applied to u (0,1) φ(y) = x,f(x)=y 1 f (x) Inverse problem: known distribution φ(x), φ(x)dx = 1, needed: the distribution function y φ(x)dx must be inverted. Example: x = ln u gives φ(x) = exp( x) (check for u = 0!)

20 Gauss normal distribution u Gauss = 2 ln u (0,1) cos(2πu (0,1) ) 20/21 where both random numbers u (0,1) are independent, function u (0,1) thus has to be called twice. Second indepent number: replace cos sin. Approximately: u Gauss 2(u (0,1) u (0,1) + u (0,1) u (0,1) + u (0,1) u (0,1) ) General distribution When φ (in interval (a, b)) is not known (or too complicated): 1. generate x = u (a,b), 2. generate u = u (0,m), where m is the maximum of φ(x) in interval (a, b), 3. if u < φ(x), accept x as the number, otherwise repeat by step 1.

21 Multidimensional distribution [cd simul; insphere.sh; onsphere.sh] 21/21 In a unit ball (ball = inside of a sphere) 1. generate x = u ( 1,1), y = u ( 1,1), z = u ( 1,1), 2. calculate r 2 = x 2 + y 2 + z 2, 3. if r 2 < 1, accept vector (x, y, z), otherwise repeat by step 1. On a unit sphere: divide r in ball r (check for r 0), or: 1. z = u ( 1,1), φ = u (0,1) 2. x = 1 z 2 sin(2πφ), y = 1 z 2 cos(2πφ) Uniform discrete distribution u N = int(nu (0,1) ) Better not like this (r is a random integer): u N = r mod N (very bad for congruence generators lower significant bits are not random)

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

Monte Carlo. Lecture 15 4/9/18. Harvard SEAS AP 275 Atomistic Modeling of Materials Boris Kozinsky Monte Carlo Lecture 15 4/9/18 1 Sampling with dynamics In Molecular Dynamics we simulate evolution of a system over time according to Newton s equations, conserving energy Averages (thermodynamic properties)

More information

Cheng Soon Ong & Christian Walder. Canberra February June 2018

Cheng Soon Ong & Christian Walder. Canberra February June 2018 Cheng Soon Ong & Christian Walder Research Group and College of Engineering and Computer Science Canberra February June 2018 Outlines Overview Introduction Linear Algebra Probability Linear Regression

More information

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

Random processes and probability distributions. Phys 420/580 Lecture 20 Random processes and probability distributions Phys 420/580 Lecture 20 Random processes Many physical processes are random in character: e.g., nuclear decay (Poisson distributed event count) P (k, τ) =

More information

Physics 403. Segev BenZvi. Monte Carlo Techniques. Department of Physics and Astronomy University of Rochester

Physics 403. Segev BenZvi. Monte Carlo Techniques. Department of Physics and Astronomy University of Rochester Physics 403 Monte Carlo Techniques Segev BenZvi Department of Physics and Astronomy University of Rochester Table of Contents 1 Simulation and Random Number Generation Simulation of Physical Systems Creating

More information

Today: Fundamentals of Monte Carlo

Today: Fundamentals of Monte Carlo 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

More information

Physics 403 Monte Carlo Techniques

Physics 403 Monte Carlo Techniques Physics 403 Monte Carlo Techniques Segev BenZvi Department of Physics and Astronomy University of Rochester Table of Contents 1 Simulation and Random Number Generation Simulation of Physical Systems Creating

More information

Today: Fundamentals of Monte Carlo

Today: Fundamentals of Monte Carlo 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 -

More information

Statistical Thermodynamics and Monte-Carlo Evgenii B. Rudnyi and Jan G. Korvink IMTEK Albert Ludwig University Freiburg, Germany

Statistical Thermodynamics and Monte-Carlo Evgenii B. Rudnyi and Jan G. Korvink IMTEK Albert Ludwig University Freiburg, Germany Statistical Thermodynamics and Monte-Carlo Evgenii B. Rudnyi and Jan G. Korvink IMTEK Albert Ludwig University Freiburg, Germany Preliminaries Learning Goals From Micro to Macro Statistical Mechanics (Statistical

More information

Monte Carlo (MC) Simulation Methods. Elisa Fadda

Monte Carlo (MC) Simulation Methods. Elisa Fadda Monte Carlo (MC) Simulation Methods Elisa Fadda 1011-CH328, Molecular Modelling & Drug Design 2011 Experimental Observables A system observable is a property of the system state. The system state i is

More information

Uniform Random Number Generators

Uniform Random Number Generators JHU 553.633/433: Monte Carlo Methods J. C. Spall 25 September 2017 CHAPTER 2 RANDOM NUMBER GENERATION Motivation and criteria for generators Linear generators (e.g., linear congruential generators) Multiple

More information

Advanced Monte Carlo Methods Problems

Advanced Monte Carlo Methods Problems Advanced Monte Carlo Methods Problems September-November, 2012 Contents 1 Integration with the Monte Carlo method 2 1.1 Non-uniform random numbers.......................... 2 1.2 Gaussian RNG..................................

More information

Markov Processes. Stochastic process. Markov process

Markov Processes. Stochastic process. Markov process Markov Processes Stochastic process movement through a series of well-defined states in a way that involves some element of randomness for our purposes, states are microstates in the governing ensemble

More information

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

From Random Numbers to Monte Carlo. Random Numbers, Random Walks, Diffusion, Monte Carlo integration, and all that From Random Numbers to Monte Carlo Random Numbers, Random Walks, Diffusion, Monte Carlo integration, and all that Random Walk Through Life Random Walk Through Life If you flip the coin 5 times you will

More information

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

Sampling Distributions Allen & Tildesley pgs and Numerical Recipes on random numbers Sampling Distributions Allen & Tildesley pgs. 345-351 and Numerical Recipes on random numbers Today I explain how to generate a non-uniform probability distributions. These are used in importance sampling

More information

Week 7: Integration: Special Coordinates

Week 7: Integration: Special Coordinates Week 7: Integration: Special Coordinates Introduction Many problems naturally involve symmetry. One should exploit it where possible and this often means using coordinate systems other than Cartesian coordinates.

More information

The curious properties of spin

The curious properties of spin The curious properties of spin February, 07 The Stern-Gerlach experiment The Schrödinger equation predicts degenerate energy levels for atoms electron states that differ only in the z-component of their

More information

Today: Fundamentals of Monte Carlo

Today: Fundamentals of Monte Carlo 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 -

More information

( ) ( ) Monte Carlo Methods Interested in. E f X = f x d x. Examples:

( ) ( ) Monte Carlo Methods Interested in. E f X = f x d x. Examples: Monte Carlo Methods Interested in Examples: µ E f X = f x d x Type I error rate of a hypothesis test Mean width of a confidence interval procedure Evaluating a likelihood Finding posterior mean and variance

More information

The XY-Model. David-Alexander Robinson Sch th January 2012

The XY-Model. David-Alexander Robinson Sch th January 2012 The XY-Model David-Alexander Robinson Sch. 08332461 17th January 2012 Contents 1 Introduction & Theory 2 1.1 The XY-Model............................... 2 1.2 Markov Chains...............................

More information

Monte Carlo Methods for Computation and Optimization (048715)

Monte Carlo Methods for Computation and Optimization (048715) Technion Department of Electrical Engineering Monte Carlo Methods for Computation and Optimization (048715) Lecture Notes Prof. Nahum Shimkin Spring 2015 i PREFACE These lecture notes are intended for

More information

3.320 Lecture 18 (4/12/05)

3.320 Lecture 18 (4/12/05) 3.320 Lecture 18 (4/12/05) Monte Carlo Simulation II and free energies Figure by MIT OCW. General Statistical Mechanics References D. Chandler, Introduction to Modern Statistical Mechanics D.A. McQuarrie,

More information

The Markov Chain Monte Carlo Method

The Markov Chain Monte Carlo Method The Markov Chain Monte Carlo Method Idea: define an ergodic Markov chain whose stationary distribution is the desired probability distribution. Let X 0, X 1, X 2,..., X n be the run of the chain. The Markov

More information

Note: Each problem is worth 14 points except numbers 5 and 6 which are 15 points. = 3 2

Note: Each problem is worth 14 points except numbers 5 and 6 which are 15 points. = 3 2 Math Prelim II Solutions Spring Note: Each problem is worth points except numbers 5 and 6 which are 5 points. x. Compute x da where is the region in the second quadrant between the + y circles x + y and

More information

1. (3) Write Gauss Law in differential form. Explain the physical meaning.

1. (3) Write Gauss Law in differential form. Explain the physical meaning. Electrodynamics I Midterm Exam - Part A - Closed Book KSU 204/0/23 Name Electro Dynamic Instructions: Use SI units. Where appropriate, define all variables or symbols you use, in words. Try to tell about

More information

Sampling Random Variables

Sampling Random Variables Sampling Random Variables Introduction Sampling a random variable X means generating a domain value x X in such a way that the probability of generating x is in accordance with p(x) (respectively, f(x)),

More information

Understanding Molecular Simulation 2009 Monte Carlo and Molecular Dynamics in different ensembles. Srikanth Sastry

Understanding Molecular Simulation 2009 Monte Carlo and Molecular Dynamics in different ensembles. Srikanth Sastry JNCASR August 20, 21 2009 Understanding Molecular Simulation 2009 Monte Carlo and Molecular Dynamics in different ensembles Srikanth Sastry Jawaharlal Nehru Centre for Advanced Scientific Research, Bangalore

More information

JUST THE MATHS UNIT NUMBER INTEGRATION APPLICATIONS 13 (Second moments of a volume (A)) A.J.Hobson

JUST THE MATHS UNIT NUMBER INTEGRATION APPLICATIONS 13 (Second moments of a volume (A)) A.J.Hobson JUST THE MATHS UNIT NUMBER 13.13 INTEGRATION APPLICATIONS 13 (Second moments of a volume (A)) by A.J.Hobson 13.13.1 Introduction 13.13. The second moment of a volume of revolution about the y-axis 13.13.3

More information

The Monte Carlo Algorithm

The Monte Carlo Algorithm The Monte Carlo Algorithm This algorithm was invented by N. Metropolis, A.W. Rosenbluth, M.N. Rosenbluth, A.H. Teller, and E. Teller, J. Chem. Phys., 21, 1087 (1953). It was listed as one of the The Top

More information

2 Random Variable Generation

2 Random Variable Generation 2 Random Variable Generation Most Monte Carlo computations require, as a starting point, a sequence of i.i.d. random variables with given marginal distribution. We describe here some of the basic methods

More information

Monte Carlo importance sampling and Markov chain

Monte Carlo importance sampling and Markov chain Monte Carlo importance sampling and Markov chain If a configuration in phase space is denoted by X, the probability for configuration according to Boltzman is ρ(x) e βe(x) β = 1 T (1) How to sample over

More information

André Schleife Department of Materials Science and Engineering

André Schleife Department of Materials Science and Engineering André Schleife Department of Materials Science and Engineering Length Scales (c) ICAMS: http://www.icams.de/cms/upload/01_home/01_research_at_icams/length_scales_1024x780.png Goals for today: Background

More information

Mean Intensity. Same units as I ν : J/m 2 /s/hz/sr (ergs/cm 2 /s/hz/sr) Function of position (and time), but not direction

Mean Intensity. Same units as I ν : J/m 2 /s/hz/sr (ergs/cm 2 /s/hz/sr) Function of position (and time), but not direction MCRT: L5 MCRT estimators for mean intensity, absorbed radiation, radiation pressure, etc Path length sampling: mean intensity, fluence rate, number of absorptions Random number generators J Mean Intensity

More information

Jim Lambers MAT 280 Summer Semester Practice Final Exam Solution. dy + xz dz = x(t)y(t) dt. t 3 (4t 3 ) + e t2 (2t) + t 7 (3t 2 ) dt

Jim Lambers MAT 280 Summer Semester Practice Final Exam Solution. dy + xz dz = x(t)y(t) dt. t 3 (4t 3 ) + e t2 (2t) + t 7 (3t 2 ) dt Jim Lambers MAT 28 ummer emester 212-1 Practice Final Exam olution 1. Evaluate the line integral xy dx + e y dy + xz dz, where is given by r(t) t 4, t 2, t, t 1. olution From r (t) 4t, 2t, t 2, we obtain

More information

Computer Intensive Methods in Mathematical Statistics

Computer Intensive Methods in Mathematical Statistics Computer Intensive Methods in Mathematical Statistics Department of mathematics KTH Royal Institute of Technology jimmyol@kth.se Lecture 2 Random number generation 27 March 2014 Computer Intensive Methods

More information

Metropolis/Variational Monte Carlo. Microscopic Theories of Nuclear Structure, Dynamics and Electroweak Currents June 12-30, 2017, ECT*, Trento, Italy

Metropolis/Variational Monte Carlo. Microscopic Theories of Nuclear Structure, Dynamics and Electroweak Currents June 12-30, 2017, ECT*, Trento, Italy Metropolis/Variational Monte Carlo Stefano Gandolfi Los Alamos National Laboratory (LANL) Microscopic Theories of Nuclear Structure, Dynamics and Electroweak Currents June 12-30, 2017, ECT*, Trento, Italy

More information

Modern Methods of Data Analysis - WS 07/08

Modern Methods of Data Analysis - WS 07/08 Modern Methods of Data Analysis Lecture III (29.10.07) Contents: Overview & Test of random number generators Random number distributions Monte Carlo The terminology Monte Carlo-methods originated around

More information

Random numbers and generators

Random numbers and generators Chapter 2 Random numbers and generators Random numbers can be generated experimentally, like throwing dice or from radioactive decay measurements. In numerical calculations one needs, however, huge set

More information

SAMPLING SPECIAL DISTRIBUTIONS

SAMPLING SPECIAL DISTRIBUTIONS SAMPLING SPECIAL DISTRIBUTIONS M. Ragheb 4/9/4 INTRODUCTION Monte Carlo simulations require the sampling of various distributions at different steps in the simulation process. There exist a multitude of

More information

PHYS 7411 Spring 2015 Computational Physics Homework 3

PHYS 7411 Spring 2015 Computational Physics Homework 3 PHYS 7411 Spring 2015 Computational Physics Homework 3 Due by 3:00pm in Nicholson 447 on 13 March 2015, Friday the 13th (Any late assignments will be penalized in the amount of 25% per day late. Any copying

More information

MTH739U/P: Topics in Scientific Computing Autumn 2016 Week 6

MTH739U/P: Topics in Scientific Computing Autumn 2016 Week 6 MTH739U/P: Topics in Scientific Computing Autumn 16 Week 6 4.5 Generic algorithms for non-uniform variates We have seen that sampling from a uniform distribution in [, 1] is a relatively straightforward

More information

Power Series. Part 2 Differentiation & Integration; Multiplication of Power Series. J. Gonzalez-Zugasti, University of Massachusetts - Lowell

Power Series. Part 2 Differentiation & Integration; Multiplication of Power Series. J. Gonzalez-Zugasti, University of Massachusetts - Lowell Power Series Part 2 Differentiation & Integration; Multiplication of Power Series 1 Theorem 1 If a n x n converges absolutely for x < R, then a n f x n converges absolutely for any continuous function

More information

Markov Chain Monte Carlo Simulations and Their Statistical Analysis An Overview

Markov Chain Monte Carlo Simulations and Their Statistical Analysis An Overview Markov Chain Monte Carlo Simulations and Their Statistical Analysis An Overview Bernd Berg FSU, August 30, 2005 Content 1. Statistics as needed 2. Markov Chain Monte Carlo (MC) 3. Statistical Analysis

More information

Lecture 20. Randomness and Monte Carlo. J. Chaudhry. Department of Mathematics and Statistics University of New Mexico

Lecture 20. Randomness and Monte Carlo. J. Chaudhry. Department of Mathematics and Statistics University of New Mexico Lecture 20 Randomness and Monte Carlo J. Chaudhry Department of Mathematics and Statistics University of New Mexico J. Chaudhry (UNM) CS 357 1 / 40 What we ll do: Random number generators Monte-Carlo integration

More information

1 Stat 605. Homework I. Due Feb. 1, 2011

1 Stat 605. Homework I. Due Feb. 1, 2011 The first part is homework which you need to turn in. The second part is exercises that will not be graded, but you need to turn it in together with the take-home final exam. 1 Stat 605. Homework I. Due

More information

Markov Chain Monte Carlo (MCMC)

Markov Chain Monte Carlo (MCMC) Markov Chain Monte Carlo (MCMC Dependent Sampling Suppose we wish to sample from a density π, and we can evaluate π as a function but have no means to directly generate a sample. Rejection sampling can

More information

Monte Carlo methods for kinetic equations

Monte Carlo methods for kinetic equations Monte Carlo methods for kinetic equations Lecture 2: Monte Carlo simulation methods Lorenzo Pareschi Department of Mathematics & CMCS University of Ferrara Italy http://utenti.unife.it/lorenzo.pareschi/

More information

Markov chain Monte Carlo

Markov chain Monte Carlo Markov chain Monte Carlo Probabilistic Models of Cognition, 2011 http://www.ipam.ucla.edu/programs/gss2011/ Roadmap: Motivation Monte Carlo basics What is MCMC? Metropolis Hastings and Gibbs...more tomorrow.

More information

Math Stochastic Processes & Simulation. Davar Khoshnevisan University of Utah

Math Stochastic Processes & Simulation. Davar Khoshnevisan University of Utah Math 5040 1 Stochastic Processes & Simulation Davar Khoshnevisan University of Utah Module 1 Generation of Discrete Random Variables Just about every programming language and environment has a randomnumber

More information

SOUTH AFRICAN TERTIARY MATHEMATICS OLYMPIAD

SOUTH AFRICAN TERTIARY MATHEMATICS OLYMPIAD SOUTH AFRICAN TERTIARY MATHEMATICS OLYMPIAD. Determine the following value: 7 August 6 Solutions π + π. Solution: Since π

More information

Riemann integral and volume are generalized to unbounded functions and sets. is an admissible set, and its volume is a Riemann integral, 1l E,

Riemann integral and volume are generalized to unbounded functions and sets. is an admissible set, and its volume is a Riemann integral, 1l E, Tel Aviv University, 26 Analysis-III 9 9 Improper integral 9a Introduction....................... 9 9b Positive integrands................... 9c Special functions gamma and beta......... 4 9d Change of

More information

Mathematical Methods for Neurosciences. ENS - Master MVA Paris 6 - Master Maths-Bio ( )

Mathematical Methods for Neurosciences. ENS - Master MVA Paris 6 - Master Maths-Bio ( ) Mathematical Methods for Neurosciences. ENS - Master MVA Paris 6 - Master Maths-Bio (2014-2015) Etienne Tanré - Olivier Faugeras INRIA - Team Tosca October 22nd, 2014 E. Tanré (INRIA - Team Tosca) Mathematical

More information

Monte Carlo and cold gases. Lode Pollet.

Monte Carlo and cold gases. Lode Pollet. Monte Carlo and cold gases Lode Pollet lpollet@physics.harvard.edu 1 Outline Classical Monte Carlo The Monte Carlo trick Markov chains Metropolis algorithm Ising model critical slowing down Quantum Monte

More information

CE 530 Molecular Simulation

CE 530 Molecular Simulation CE 530 Molecular Simulation Lecture 0 Simple Biasing Methods David A. Kofke Department of Chemical Engineering SUNY Buffalo kofke@eng.buffalo.edu 2 Review Monte Carlo simulation Markov chain to generate

More information

Perfect simulation for image analysis

Perfect simulation for image analysis Perfect simulation for image analysis Mark Huber Fletcher Jones Foundation Associate Professor of Mathematics and Statistics and George R. Roberts Fellow Mathematical Sciences Claremont McKenna College

More information

Monte Carlo Radiation Transfer I

Monte Carlo Radiation Transfer I Monte Carlo Radiation Transfer I Monte Carlo Photons and interactions Sampling from probability distributions Optical depths, isotropic emission, scattering Monte Carlo Basics Emit energy packet, hereafter

More information

Random Number Generation. Stephen Booth David Henty

Random Number Generation. Stephen Booth David Henty Random Number Generation Stephen Booth David Henty Introduction Random numbers are frequently used in many types of computer simulation Frequently as part of a sampling process: Generate a representative

More information

Physics 9 Spring 2012 Midterm 1 Solutions

Physics 9 Spring 2012 Midterm 1 Solutions Physics 9 Spring 22 NAME: TA: Physics 9 Spring 22 Midterm s For the midterm, you may use one sheet of notes with whatever you want to put on it, front and back. Please sit every other seat, and please

More information

Computer simulation methods (1) Dr. Vania Calandrini

Computer simulation methods (1) Dr. Vania Calandrini Computer simulation methods (1) Dr. Vania Calandrini Why computational methods To understand and predict the properties of complex systems (many degrees of freedom): liquids, solids, adsorption of molecules

More information

Random Walks A&T and F&S 3.1.2

Random Walks A&T and F&S 3.1.2 Random Walks A&T 110-123 and F&S 3.1.2 As we explained last time, it is very difficult to sample directly a general probability distribution. - If we sample from another distribution, the overlap will

More information

1 Maintaining a Dictionary

1 Maintaining a Dictionary 15-451/651: Design & Analysis of Algorithms February 1, 2016 Lecture #7: Hashing last changed: January 29, 2016 Hashing is a great practical tool, with an interesting and subtle theory too. In addition

More information

You may not start to read the questions printed on the subsequent pages until instructed to do so by the Invigilator.

You may not start to read the questions printed on the subsequent pages until instructed to do so by the Invigilator. MATHEMATICAL TRIPOS Part IB Thursday 7 June 2007 9 to 12 PAPER 3 Before you begin read these instructions carefully. Each question in Section II carries twice the number of marks of each question in Section

More information

Answers and expectations

Answers and expectations Answers and expectations For a function f(x) and distribution P(x), the expectation of f with respect to P is The expectation is the average of f, when x is drawn from the probability distribution P E

More information

Preliminary Exam 2018 Solutions to Morning Exam

Preliminary Exam 2018 Solutions to Morning Exam Preliminary Exam 28 Solutions to Morning Exam Part I. Solve four of the following five problems. Problem. Consider the series n 2 (n log n) and n 2 (n(log n)2 ). Show that one converges and one diverges

More information

Math 350 Solutions for Final Exam Page 1. Problem 1. (10 points) (a) Compute the line integral. F ds C. z dx + y dy + x dz C

Math 350 Solutions for Final Exam Page 1. Problem 1. (10 points) (a) Compute the line integral. F ds C. z dx + y dy + x dz C Math 35 Solutions for Final Exam Page Problem. ( points) (a) ompute the line integral F ds for the path c(t) = (t 2, t 3, t) with t and the vector field F (x, y, z) = xi + zj + xk. (b) ompute the line

More information

14 Higher order forms; divergence theorem

14 Higher order forms; divergence theorem Tel Aviv University, 2013/14 Analysis-III,IV 221 14 Higher order forms; divergence theorem 14a Forms of order three................ 221 14b Divergence theorem in three dimensions.... 225 14c Order four,

More information

Numerical integration and importance sampling

Numerical integration and importance sampling 2 Numerical integration and importance sampling 2.1 Quadrature Consider the numerical evaluation of the integral I(a, b) = b a dx f(x) Rectangle rule: on small interval, construct interpolating function

More information

Homework 10 Solution

Homework 10 Solution CS 174: Combinatorics and Discrete Probability Fall 2012 Homewor 10 Solution Problem 1. (Exercise 10.6 from MU 8 points) The problem of counting the number of solutions to a napsac instance can be defined

More information

Preliminary Exam 2016 Solutions to Morning Exam

Preliminary Exam 2016 Solutions to Morning Exam Preliminary Exam 16 Solutions to Morning Exam Part I. Solve four of the following five problems. Problem 1. Find the volume of the ice cream cone defined by the inequalities x + y + z 1 and x + y z /3

More information

Monte Carlo Methods in Statistical Mechanics

Monte Carlo Methods in Statistical Mechanics Monte Carlo Methods in Statistical Mechanics Mario G. Del Pópolo Atomistic Simulation Centre School of Mathematics and Physics Queen s University Belfast Belfast Mario G. Del Pópolo Statistical Mechanics

More information

MSc Mas6002, Introductory Material Mathematical Methods Exercises

MSc Mas6002, Introductory Material Mathematical Methods Exercises MSc Mas62, Introductory Material Mathematical Methods Exercises These exercises are on a range of mathematical methods which are useful in different parts of the MSc, especially calculus and linear algebra.

More information

Monte Carlo Sampling

Monte Carlo Sampling Monte Carlo Sampling Sampling from PDFs: given F(x) in analytic or tabulated form, generate a random number ξ in the range (0,1) and solve the equation to get the randomly sampled value X X ξ = F(x)dx

More information

ICCP Project 2 - Advanced Monte Carlo Methods Choose one of the three options below

ICCP Project 2 - Advanced Monte Carlo Methods Choose one of the three options below ICCP Project 2 - Advanced Monte Carlo Methods Choose one of the three options below Introduction In statistical physics Monte Carlo methods are considered to have started in the Manhattan project (1940

More information

Pattern Recognition and Machine Learning. Bishop Chapter 11: Sampling Methods

Pattern Recognition and Machine Learning. Bishop Chapter 11: Sampling Methods Pattern Recognition and Machine Learning Chapter 11: Sampling Methods Elise Arnaud Jakob Verbeek May 22, 2008 Outline of the chapter 11.1 Basic Sampling Algorithms 11.2 Markov Chain Monte Carlo 11.3 Gibbs

More information

Instructions: No books. No notes. Non-graphing calculators only. You are encouraged, although not required, to show your work.

Instructions: No books. No notes. Non-graphing calculators only. You are encouraged, although not required, to show your work. Exam 3 Math 850-007 Fall 04 Odenthal Name: Instructions: No books. No notes. Non-graphing calculators only. You are encouraged, although not required, to show your work.. Evaluate the iterated integral

More information

1. Find and classify the extrema of h(x, y) = sin(x) sin(y) sin(x + y) on the square[0, π] [0, π]. (Keep in mind there is a boundary to check out).

1. Find and classify the extrema of h(x, y) = sin(x) sin(y) sin(x + y) on the square[0, π] [0, π]. (Keep in mind there is a boundary to check out). . Find and classify the extrema of hx, y sinx siny sinx + y on the square[, π] [, π]. Keep in mind there is a boundary to check out. Solution: h x cos x sin y sinx + y + sin x sin y cosx + y h y sin x

More information

Classical Monte-Carlo simulations

Classical Monte-Carlo simulations Classical Monte-Carlo simulations Graduate Summer Institute Complex Plasmas at the Stevens Insitute of Technology Henning Baumgartner, A. Filinov, H. Kählert, P. Ludwig and M. Bonitz Christian-Albrechts-University

More information

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

Introduction. Microscopic Theories of Nuclear Structure, Dynamics and Electroweak Currents June 12-30, 2017, ECT*, Trento, Italy Introduction Stefano Gandolfi Los Alamos National Laboratory (LANL) Microscopic Theories of Nuclear Structure, Dynamics and Electroweak Currents June 12-30, 2017, ECT*, Trento, Italy Stefano Gandolfi (LANL)

More information

CE 530 Molecular Simulation

CE 530 Molecular Simulation CE 530 Molecular Simulation Lecture 7 Beyond Atoms: Simulating Molecules David A. Kofke Department of Chemical Engineering SUNY Buffalo kofke@eng.buffalo.edu Review Fundamentals units, properties, statistical

More information

In this approach, the ground state of the system is found by modeling a diffusion process.

In this approach, the ground state of the system is found by modeling a diffusion process. The Diffusion Monte Carlo (DMC) Method In this approach, the ground state of the system is found by modeling a diffusion process. Diffusion and random walks Consider a random walk on a lattice with spacing

More information

Monte Carlo Molecular Simulation with Isobaric-Isothermal and Gibbs-NPT Ensembles. Thesis by Shouhong Du

Monte Carlo Molecular Simulation with Isobaric-Isothermal and Gibbs-NPT Ensembles. Thesis by Shouhong Du Monte Carlo Molecular Simulation with Isobaric-Isothermal and Gibbs-NPT Ensembles Thesis by Shouhong Du In Partial Fulfillment of the Requirements For the Degree of Master of Science King Abdullah University

More information

Question: My computer only knows how to generate a uniform random variable. How do I generate others? f X (x)dx. f X (s)ds.

Question: My computer only knows how to generate a uniform random variable. How do I generate others? f X (x)dx. f X (s)ds. Simulation Question: My computer only knows how to generate a uniform random variable. How do I generate others?. Continuous Random Variables Recall that a random variable X is continuous if it has a probability

More information

Final exam (practice 1) UCLA: Math 32B, Spring 2018

Final exam (practice 1) UCLA: Math 32B, Spring 2018 Instructor: Noah White Date: Final exam (practice 1) UCLA: Math 32B, Spring 218 This exam has 7 questions, for a total of 8 points. Please print your working and answers neatly. Write your solutions in

More information

xy 2 e 2z dx dy dz = 8 3 (1 e 4 ) = 2.62 mc. 12 x2 y 3 e 2z 2 m 2 m 2 m Figure P4.1: Cube of Problem 4.1.

xy 2 e 2z dx dy dz = 8 3 (1 e 4 ) = 2.62 mc. 12 x2 y 3 e 2z 2 m 2 m 2 m Figure P4.1: Cube of Problem 4.1. Problem 4.1 A cube m on a side is located in the first octant in a Cartesian coordinate system, with one of its corners at the origin. Find the total charge contained in the cube if the charge density

More information

Lecture 10 - Moment of Inertia

Lecture 10 - Moment of Inertia Lecture 10 - oment of Inertia A Puzzle... Question For any object, there are typically many ways to calculate the moment of inertia I = r 2 dm, usually by doing the integration by considering different

More information

Stat 516, Homework 1

Stat 516, Homework 1 Stat 516, Homework 1 Due date: October 7 1. Consider an urn with n distinct balls numbered 1,..., n. We sample balls from the urn with replacement. Let N be the number of draws until we encounter a ball

More information

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

Data Analysis I. Dr Martin Hendry, Dept of Physics and Astronomy University of Glasgow, UK. 10 lectures, beginning October 2006 Astronomical p( y x, I) p( x, I) p ( x y, I) = p( y, I) Data Analysis I Dr Martin Hendry, Dept of Physics and Astronomy University of Glasgow, UK 10 lectures, beginning October 2006 4. Monte Carlo Methods

More information

A Repetition Test for Pseudo-Random Number Generators

A Repetition Test for Pseudo-Random Number Generators Monte Carlo Methods and Appl., Vol. 12, No. 5-6, pp. 385 393 (2006) c VSP 2006 A Repetition Test for Pseudo-Random Number Generators Manuel Gil, Gaston H. Gonnet, Wesley P. Petersen SAM, Mathematik, ETHZ,

More information

MATH5835 Statistical Computing. Jochen Voss

MATH5835 Statistical Computing. Jochen Voss MATH5835 Statistical Computing Jochen Voss September 27, 2011 Copyright c 2011 Jochen Voss J.Voss@leeds.ac.uk This text is work in progress and may still contain typographical and factual mistakes. Reports

More information

Solutions Ph 236b Week 1

Solutions Ph 236b Week 1 Solutions Ph 236b Week 1 Page 1 of 7 Solutions Ph 236b Week 1 Kevin Barkett and Mark Scheel January 19, 216 Contents Problem 1................................... 2 Part (a...................................

More information

Multimodal Nested Sampling

Multimodal Nested Sampling Multimodal Nested Sampling Farhan Feroz Astrophysics Group, Cavendish Lab, Cambridge Inverse Problems & Cosmology Most obvious example: standard CMB data analysis pipeline But many others: object detection,

More information

Problem Set 4. f(a + h) = P k (h) + o( h k ). (3)

Problem Set 4. f(a + h) = P k (h) + o( h k ). (3) Analysis 2 Antti Knowles Problem Set 4 1. Let f C k+1 in a neighborhood of a R n. In class we saw that f can be expressed using its Taylor series as f(a + h) = P k (h) + R k (h) (1) where P k (h).= k r=0

More information

Quantum Monte Carlo. Matthias Troyer, ETH Zürich

Quantum Monte Carlo. Matthias Troyer, ETH Zürich Quantum Monte Carlo Matthias Troyer, ETH Zürich 1 1. Monte Carlo Integration 2 Integrating a function Convert the integral to a discrete sum b! f (x)dx = b " a N a N ' i =1 # f a + i b " a % $ N & + O(1/N)

More information

Fault Tolerance & Reliability CDA Chapter 2 Cyclic Polynomial Codes

Fault Tolerance & Reliability CDA Chapter 2 Cyclic Polynomial Codes Fault Tolerance & Reliability CDA 5140 Chapter 2 Cyclic Polynomial Codes - cylic code: special type of parity check code such that every cyclic shift of codeword is a codeword - for example, if (c n-1,

More information

Contents. MATH 32B-2 (18W) (L) G. Liu / (TA) A. Zhou Calculus of Several Variables. 1 Multiple Integrals 3. 2 Vector Fields 9

Contents. MATH 32B-2 (18W) (L) G. Liu / (TA) A. Zhou Calculus of Several Variables. 1 Multiple Integrals 3. 2 Vector Fields 9 MATH 32B-2 (8W) (L) G. Liu / (TA) A. Zhou Calculus of Several Variables Contents Multiple Integrals 3 2 Vector Fields 9 3 Line and Surface Integrals 5 4 The Classical Integral Theorems 9 MATH 32B-2 (8W)

More information

Physics 115/242 Monte Carlo simulations in Statistical Physics

Physics 115/242 Monte Carlo simulations in Statistical Physics Physics 115/242 Monte Carlo simulations in Statistical Physics Peter Young (Dated: May 12, 2007) For additional information on the statistical Physics part of this handout, the first two sections, I strongly

More information

Math Final Exam.

Math Final Exam. Math 106 - Final Exam. This is a closed book exam. No calculators are allowed. The exam consists of 8 questions worth 100 points. Good luck! Name: Acknowledgment and acceptance of honor code: Signature:

More information

Bayesian Methods and Uncertainty Quantification for Nonlinear Inverse Problems

Bayesian Methods and Uncertainty Quantification for Nonlinear Inverse Problems Bayesian Methods and Uncertainty Quantification for Nonlinear Inverse Problems John Bardsley, University of Montana Collaborators: H. Haario, J. Kaipio, M. Laine, Y. Marzouk, A. Seppänen, A. Solonen, Z.

More information

Contents. 1 Probability review Introduction Random variables and distributions Convergence of random variables...

Contents. 1 Probability review Introduction Random variables and distributions Convergence of random variables... Contents Probability review. Introduction..............................2 Random variables and distributions................ 3.3 Convergence of random variables................. 6 2 Monte Carlo methods

More information

an introduction to bayesian inference

an introduction to bayesian inference with an application to network analysis http://jakehofman.com january 13, 2010 motivation would like models that: provide predictive and explanatory power are complex enough to describe observed phenomena

More information

Simulation. Where real stuff starts

Simulation. Where real stuff starts 1 Simulation Where real stuff starts ToC 1. What is a simulation? 2. Accuracy of output 3. Random Number Generators 4. How to sample 5. Monte Carlo 6. Bootstrap 2 1. What is a simulation? 3 What is a simulation?

More information