The Monte Carlo Method An Introduction to Markov Chain MC

Similar documents
Markov Processes. Stochastic process. Markov process

Copyright 2001 University of Cambridge. Not to be quoted or copied without permission.

Random Walks A&T and F&S 3.1.2

Doing Physics with Random Numbers

Math 456: Mathematical Modeling. Tuesday, April 9th, 2018

12. LOCAL SEARCH. gradient descent Metropolis algorithm Hopfield neural networks maximum cut Nash equilibria

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

Monte Carlo (MC) Simulation Methods. Elisa Fadda

The Monte Carlo Algorithm

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

Brief introduction to Markov Chain Monte Carlo

Computer Vision Group Prof. Daniel Cremers. 11. Sampling Methods: Markov Chain Monte Carlo

Classical Monte-Carlo simulations

Computer simulation methods (1) Dr. Vania Calandrini

Enrico Fermi and the FERMIAC. Mechanical device that plots 2D random walks of slow and fast neutrons in fissile material

Physics 115/242 Monte Carlo simulations in Statistical Physics

Numerical Analysis of 2-D Ising Model. Ishita Agarwal Masters in Physics (University of Bonn) 17 th March 2011

Monte Carlo Simulation of the Ising Model. Abstract

Markov Chain Monte Carlo The Metropolis-Hastings Algorithm

Lecture notes on Regression: Markov Chain Monte Carlo (MCMC)

Evaluation of Wang-Landau Monte Carlo Simulations

Markov Chains Handout for Stat 110

Introduction to Machine Learning CMU-10701

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

CE 530 Molecular Simulation

J ij S i S j B i S i (1)

Computer Vision Group Prof. Daniel Cremers. 10a. Markov Chain Monte Carlo

Monte Carlo and cold gases. Lode Pollet.

CS 781 Lecture 9 March 10, 2011 Topics: Local Search and Optimization Metropolis Algorithm Greedy Optimization Hopfield Networks Max Cut Problem Nash

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

Monte Carlo Methods in High Energy Physics I

Monte Carlo Methods in Statistical Mechanics

Numerical integration and importance sampling

A Monte Carlo Implementation of the Ising Model in Python

3.320 Lecture 18 (4/12/05)

Computational Physics (6810): Session 13

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

Simulation of the two-dimensional square-lattice Lenz-Ising model in Python

Parallel Tempering Algorithm in Monte Carlo Simulation

April 20th, Advanced Topics in Machine Learning California Institute of Technology. Markov Chain Monte Carlo for Machine Learning

The University of British Columbia Computer Science 405 Practice Midterm Solutions

CHEM-UA 652: Thermodynamics and Kinetics

Today: Fundamentals of Monte Carlo

Markov Chain Monte Carlo Inference. Siamak Ravanbakhsh Winter 2018

Monte Caro simulations

Today: Fundamentals of Monte Carlo

Chapter 4: Monte Carlo Methods. Paisan Nakmahachalasint

Let s start by reviewing what we learned last time. Here is the basic line of reasoning for Einstein Solids

Markov chain Monte Carlo Lecture 9

Results: MCMC Dancers, q=10, n=500

3.320: Lecture 19 (4/14/05) Free Energies and physical Coarse-graining. ,T) + < σ > dµ

Monte Carlo Methods for Computation and Optimization (048715)

Numerical methods for lattice field theory

Physics 403. Segev BenZvi. Numerical Methods, Maximum Likelihood, and Least Squares. Department of Physics and Astronomy University of Rochester

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

Monte Carlo programs

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

Preliminary statistics

Wang-Landau Monte Carlo simulation. Aleš Vítek IT4I, VP3

The Particle Filter. PD Dr. Rudolph Triebel Computer Vision Group. Machine Learning for Computer Vision

Bayes Nets: Sampling

Lecture 2+3: Simulations of Soft Matter. 1. Why Lecture 1 was irrelevant 2. Coarse graining 3. Phase equilibria 4. Applications

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

André Schleife Department of Materials Science and Engineering

Introduction to the Renormalization Group

Announcements. Inference. Mid-term. Inference by Enumeration. Reminder: Alarm Network. Introduction to Artificial Intelligence. V22.

Markov Chain Monte Carlo Method

COMS 4721: Machine Learning for Data Science Lecture 20, 4/11/2017

NATIONAL UNIVERSITY OF SINGAPORE PC5215 NUMERICAL RECIPES WITH APPLICATIONS. (Semester I: AY ) Time Allowed: 2 Hours

Advanced Sampling Algorithms

Monte Carlo integration (naive Monte Carlo)

Quantum Monte Carlo. Matthias Troyer, ETH Zürich

Brief Review of Statistical Mechanics

Lecture 6. Statistical Processes. Irreversibility. Counting and Probability. Microstates and Macrostates. The Meaning of Equilibrium Ω(m) 9 spins

Lecture 15: MCMC Sanjeev Arora Elad Hazan. COS 402 Machine Learning and Artificial Intelligence Fall 2016

Statistical Mechanics. Atomistic view of Materials

Kyle Reing University of Southern California April 18, 2018

Advanced Monte Carlo Methods Problems

Perfect simulation for image analysis

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

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

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

Applied Statistics. Monte Carlo Simulations. Troels C. Petersen (NBI) Statistics is merely a quantisation of common sense

18.600: Lecture 32 Markov Chains

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

What is a random variable

18.175: Lecture 30 Markov chains

Monte Carlo importance sampling and Markov chain

Strong Lens Modeling (II): Statistical Methods

Time-Dependent Statistical Mechanics 5. The classical atomic fluid, classical mechanics, and classical equilibrium statistical mechanics

Basics of Statistical Mechanics

Phase Transition & Approximate Partition Function In Ising Model and Percolation In Two Dimension: Specifically For Square Lattices

CE 530 Molecular Simulation

ECE295, Data Assimila0on and Inverse Problems, Spring 2015

Convergence Rate of Markov Chains

Today: Fundamentals of Monte Carlo

CPSC 540: Machine Learning

Monte Carlo study of the Baxter-Wu model

C. Show your answer in part B agrees with your answer in part A in the limit that the constant c 0.

Advanced sampling. fluids of strongly orientation-dependent interactions (e.g., dipoles, hydrogen bonds)

Transcription:

The Monte Carlo Method An Introduction to Markov Chain MC Sachin Shanbhag Department of Scientific Computing, Florida State University

Sources. Introduction to Monte Carlo Algorithms : Werner Krauth. Available as a pdf download at http://lps.ens.fr/~krauth. This is a great introduction to MC methods, geared towards applications in physical sciences, through puzzles and simple non-technical problems. 2. David Kofke s page on Molecular Simulation.

system with three states Markov Chains Transition-Probability Matrix Example "!! 2! 3 # " 0. 0.5 0.4# & ' $!!! % = $ 0.9 0. 0.0 % 2 22 23 $! 3! 32! % $ 33 0.3 0.3 0.4% ( ) ( ) If in state, will stay in state with probability 0. If in state, will move to state 3 with probability 0.4 Never go to state 3 from state 2 Requirements of transition-probability matrix all probabilities non-negative, and no greater than unity sum of each row is unity probability of staying in present state may be non-zero

Distribution of State Occupancies Consider process of repeatedly moving from one state to the next, choosing each subsequent state according to Π 2 2 3 2 2 3 3 2 3 etc. Histogram the occupancy number for each state n = 3 p = 0.33 n 2 = 5 p 2 = 0.42 n 3 = 4 p 3 = 0.25 2 3 After very many steps, a limiting distribution emerges

The Limiting Distribution Consider the product of Π with itself "!! 2! 3 # "!! 2! 3 # 2 & ' $!!! % ( $!!! % 2 22 23 2 22 23 $! 3! 32! % $ 33! 3! 32! % ) * ) 33 * "!! +! 2! 2 +! 3! 3!! 2 +! 2! 22 +! 3! 32 etc. # = $!! +!! +!!!! +!! +!! etc. % 2 22 2 23 3 2 2 22 22 23 32 $! 3! +! 32! 2 +! 33! 3! 3! 2 +! 32! 22 +! 33! 32 etc. % ) * In general! n is the n-step transition probability matrix probabilities of going from state i to j in exactly n steps All ways of going from state to state 2 in two steps Probability of going from state 3 to state 2 in two steps " ( n) ( n) ( n)!! 2! # 3 $ % n ( n) ( n) ( n) & ' $! 2! 22! 23 % ( n) ( n) ( n) $! 3! 32! % ( 33 ) defines ( n)! ij

The Limiting Distribution Define! (0) i as a unit state vector ( 0 0) ( 0 0) ( 0 0 ) (0) (0) (0) 2 3! =! =! =!! " # n ( ) (0) Then i n i is a vector of probabilities for ending at each state after n steps if beginning at state i " ( n) ( n) ( n)!! 2! # 3 $ % n! =! & ' 0 0 $!!! % =!!! ( n) ( n) ( n) $! 3! 32! % ( 33 ) The limiting distribution corresponds to n independent of initial state ( ) ( ) ( n) (0) ( n) ( n) ( n) ( n) ( n) ( n) 2 22 23 2 3 (") (") (") 2 3! =! =! #!

Stationary property of π The Limiting Distribution (0) n! = lim %! & i ' ( ) n"# ( (0) n ) lim % $! & i = ' ' ( ) n"# =!' π is a left eigenvector of Π with unit eigenvalue such an eigenvector is guaranteed to exist for matrices with rows that each sum to unity Equation for elements of limiting distribution π! i = "! j!! ji = 0.! + 0.9! 2 + 0.3! 3 " 0. 0.5 0.4# j! 2 = 0.5! + 0.! 2 + 0.3! 3 e. g. & = $ 0.9 0. 0.0 % $! 3 0.4! 0.0! 2 0.4! 3 0.3 0.3 0.4% = + + ' (! +! 2 +! 3 =! +! 2 +! 3 not independent

Statistical Mechanics NVT N particles, position r i = (x,y,z) momentum p i = (p x, p y, p z ) {r i, p i } = 6N degrees of freedom A particular snapshot of {r i, p i } is called a microstate Total energy of the system H({r i, p i }) = U({r i }) + K({p i }) U = U({r i }) potential energy (often pairwise summation) K = Σ p i2 /2m i kinetic energy

Statistical Mechanics In an NVT ensemble, NVT "(r i,p i ) = Q exp(# H(r,p ) i i ) kt where Q = classical partition function, defined by Q = h 3N N! " dp " dp 2 L" dp N " dr " dr 2 L dr N " exp(# H(r,p ) i i ) kt this is like a effective volume of the phase space It is related to the free energy via A/kT = - ln Q(N,V,T) An average property (e.g. specific heat) may be obtained via, A = " dp " N dr N A(r i,p i )#(r i,p i )

Statistical Mechanics The kinetic energy factors can be integrated out, Q = Q = h 3N N! h 3N N! " dp N dr N " exp(# U({r }) + K({p }) i i ) kt " dr N exp(# U({r }) i kt ) " dp N $ p i 2 2m i Z N = configurational integral It is easy to show that, A = Q = Z N " 3N Why do we care? Z N N! " dr N A(r i )exp(# U kt ) In MC, unlike MD, we don t typically have access to momenta (only positions).

Statistical Mechanics This is an integration problem, I can use quadrature! NVT A = Z N N! " dr N A(r i )exp(# U kt ) One dimensional integrals I b =! f ( x) dx a Sum areas of shapes approximating shape of curve f ( x) Error δi ~ /n 2 (for D) δi ~ /n 2/D (for dd) x n b! a I " # x f ( x ) = f ( x ) $ $ i i= n i= n i

Where is Monte Carlo? This is an integration problem, I can use quadrature! A = Z N N! " dr N A(r i )exp(# U kt ) One dimensional integrals I b =! a f ( x) dx Error δi ~ /n 0.5 (for D) δi ~ /n 0.5 (for dd) I n b! a " # n i= f ( x ) i! ( x) For large dimensions, MC has better convergence n points selected from uniform distribution p(x) x

Where is Monte Carlo? A = Z N N! " dr N A(r i )exp(# U kt ) Typically, 3D space, say N=00 particles, DOF = 3N = 300 n=0 points between (-L, +L) (dx, for example) If each function evaluation is flop (lower-bound), need 0 300 function evaluations to get integral. Fastest computers (IBM BlueGene/L ~ 500 Tflops) Time required = 0 300 /5*0 4 ~ 0 278 years age of the universe 3 billion years IMPOSSIBLE

The Etymology of Monte Carlo Principality of Monaco (~ mile2 - UM) Famous for casinos, Formula- races, royalty Random numbers

The Ubiquity of Monte Carlo Random Examples Chip Design and Newpaper Panels floorplanning Finance and Social Sciences

Broadly Speaking Monte Carlo Simulation Equilibrium Monte Carlo Kinetic or Dynamic Monte Carlo i. Detailed balance i. Detailed balance ii. Lot of algorithmic freedom ii. Kinetics (or Model) today iii. Trial Moves restricted to be local

The Tradition of Monte Carlo (930-950) various attempts The Manhattan Project Ulam, Feynman, von Neumann Fermi

The Miracle of the Central Limit Theorem p(x ) x = x x 2 = + 2 p(x 2 ) x 2 p(x N ) The probability distribution of the average of independent random variables becomes increasingly Gaussian and increasingly narrower sigma ~ /sqrt(n) x N

Children s s game in Monaco Mathematically oriented kids of Monaco want to find the pi N red /(N red +N blue ) bench = A cir /A sq =pi*(a/2) 2 /a 2 bench bench = pi/4 pi = 4 * N red /(N red +N blue ) a=50 ft bench N = N red + N blue Here, pi = 4 *0/3 ~ 3.08

Children s s game in Monaco estimate of pi N = N red + N blue The invisible hand of the CLT operates to ensure that we converge to the true value of pi as the number of rocks thrown is increased. Error vanishes as /sqrt(n)

Older people s s game in Monaco Time spent planting flags in the circular region is proportional to the area of the circle plant flags on a helipad A CHOICES (i) Move to B. Plant a gray flag. Continue throwing. (ii) Stay at A. Don t plant flag. Throw again. (iii) Stay at A. Plant a flag. Continue throwing. B 500 ft Many MC simulations are wrong because they make the wrong choice. Condition of Detailed Balance will give us sound advice. a= mile pi = 4 * N red /(N red +N blue )

Some Concepts KID S GAME OLDER PEOPLE S VERSION Each sample (place where throw lands) independent Direct Sampling Converges faster (Think CLT, think independent samples) Sample dependent on previous position (is within radius of 500ft) Markov-chain Sampling Need more throws (samples) to attain same level of accuracy May not be feasible for realistic problems!

Coins in a Shoebox Problem Q: How do you generate random configurations of coins such that they don t overlap? Direct Sampling Markov-chain Sampling Start with a legit configuration Random Sequential Depositon (?) Trial: Move a randomly chosen coin just a little in a randomly chosen direction WRONG! yes Overlap? no phi RSD < phi CP Reject move Enact move Physicists (since 953) haven t found a direct sampling algorithm

So far Central Limit Theorem: The Engine Sampling: How do I generate trials? Direct Sampling Kid s game, better, not always possible Markov Chain Sampling Older people s game, more common Coin in a shoe-box problem Unsolved Mystery: What should you do if you throw the stone out of bounds in the adults game? Tricky question, full of consequences for world peace and prosperity. We said upcoming condition of detailed balance will resolve it.

Scrambling Game Objective: Create a perfect scrambling algorithm such that any possible configuration of the puzzle is generated with equal probability Toddler s algorithm equilibrium where each state is equiprobable. Rip the whole thing apart Put it back together

Scrambling Game Scrambling Game Older People Version Choose central square to go (N, E, W, S) each with probability ¼ (which is indeed correct) Move the empty square in a random direction, each timestep 5 3 6 7 8 2 4 5 3 6 7 2 8 4 5 3 6 7 8 2 4 0.25 5 3 6 7 8 2 4 5 6 7 3 8 2 4 0.25 0.25 0.25

Scrambling Game /3? 4 6 2 7 3 8 5 b F(a) = F(b) = F(c) = F(d) : at equilibrium F(a) = F(a) p(a a) + F(b) p(b a) + F(c) p(c a) + F(d) p(d a) 4 6 2 7 3 8 5 a /3? 4 6 2 3 8 7 5 c [- p(a a) ]F(a) = F(b) p(b a) + F(c) p(c a) + F(d) p(d a) p(a a) + p(a b) + p(a c) + p(a d) = /3? 4 6 2 7 3 8 5 d p(a b) + p(a c) + p(a d) = - p(a a) [p(a b) + p(a c) + p(a d) ]F(a) = F(b)p(b a) + F(c) p(c a) + F(d) p(d a)

Scrambling Game [p(a b) + p(a c) + p(a d) ]F(a) = F(b)p(b a) + F(c) p(c a) + F(d) p(d a) F(a) p(a b) + F(b) p(b a) + F(a) p(a c) + = F(c) p(c a) + F(a) p(a d) F(d) p(d a) (A) Impose a condition that terms of the same color on either side of the = are equal F(a) p(a b) = F(a) p(a c) = F(a) p(a d) = F(b) p(b a) F(c) p(c a) F(d) p(d a) This recipe for satisfying equation (A) is called the condition of detailed balance Sufficient, but not necessary condition

Scrambling Game Look at one of these carefully, p(a c)/p(c a) = F(c)/F(a) 4 6 c 2 3 8 7 5 0.25 4 6 a 2 7 3 8 5 Given: F(a) = F(c) p(a c) = p(c a) = 0.25 (not /3) Therefore algorithm is: (i) Pick {N, E, W, S} with equal probability (ii) Move blank square to corresponding direction, if possible. Otherwise, stay where you are, reject the move, and advance the clock.

Older people s s game in Monaco Time spent planting flags in the circular region is proportional to the area of the circle plant flags on a helipad A CHOICES B (i) Move to B. Plant a gray flag. Continue throwing. (ii) Stay at A. Don t plant flag. Throw again. (iii) Stay at A. Plant a flag. Continue throwing. Many MC simulations are wrong because they make the wrong choice. Condition of Detailed Balance will give us wise advice. a= mile 500 ft pi = 4 * N red /(N red +N blue )

Some More Concepts Concept of REJECTION arose from the condition of detailed balance p(a c)/p(c a) = F(c)/F(a) This method of rejection has been enshrined into the Metropolis Algorithm p(a c) = min[, F(c)/F(a)] Connection with Statistical Mechanics F(c) = exp(-u c /k B T) p(a c) = min[, exp[-(u c -U a )/k B T]] Boltzmann

The Metropolis Method (over 7500 citations between 988-2003) THE JOURNAL OF CHEMICAL PHYSICS VOLUME 2, NUMBER 6 JUNE, 953 Equation of State Calculations by Fast Computing Machines NICHOLAS METROPOLIS, ARIANNA W. ROSENBLUTH, MARSHALL N. ROSENBLUTH, AND AUGUSTA H. TELLER, Los Alamos Scientific Laboratory, Los Alamos, New Mexico AND EDWARD TELLER, * Department of Physics, University of Chicago, Chicago, Illinois (Received March 6, 953) A general method, suitable for fast computing machines, for investigating such properties as equations of state for substances consisting of interacting individual molecules is described. The method consists of a modified Monte Carlo integration over configuration space. Results for the two-dimensional rigidsphere system have been obtained on the Los Alamos MANIAC and are presented here. These results are compared to the free volume equation of state and to a four-term virial coefficient expansion. 087 Nicholas Metropolis with the MANIAC

Back to Statistical Mechanics A = Z N N! " dr N A(r i )exp(# U kt ) Observation 2 It may be possible to compute <A> without evaluating Z N? This function is sharply peaked. Observation In the area of the circle problem, we evaluated an area (like a partition function), and the probability distribution was uniform (obs and 2 inapplicable). In the scramble problem, the probability distribution was uniform (obs inapplicable)

Back to Statistical Mechanics A = Z N N! " dr N A(r i )exp(# U kt ) Metropolis helps us generate new microstates with the appropriate probability. Thus a simple average over all the microstates gives us <A> Samples the important region of phase space

Detailed Balance Eigenvector equation for limiting distribution A sufficient (but not necessary) condition for solution is! i! ij =! j! ji Thus detailed balance or microscopic reversibility! i = "! j! ji j! =!! i j ji j = " " j!! i " ij =!! =! i ij i j! = " 0. 0.5 0.4# $ 0.9 0. 0.0% $ % & 0.3 0.3 0.4' For a given Π, it is not always possible to satisfy detailed balance; e.g. for this!! "!! Π 3 32 2 23 zero

Tutorial: Ising Model 924: Ising solved D 944: Onsager solved 2D Simple model for understanding magnetism Ferromagnets: Fe, Ni - magnetic even in the absence of an electric field Unpaired electrons = origin of magnetism Paramagnets: Al, Ba - magnetic only in the presence of an electric field Up-state Down state

Tutorial: Ising Model (a) Energy E({"}) = #J $ " i " j (b) Magnetization M({"}) = #" i N

Tutorial: Markov Chains

Tutorial: Markov Chains