Introduction to Monte Carlo Simulation

Slides:



Advertisements
Similar presentations
RSLAB-NTU Lab for Remote Sensing Hydrology and Spatial Modeling 1 An Introduction to R Pseudo Random Number Generation (PRNG) Prof. Ke-Sheng Cheng Dept.
Advertisements

Monte Carlo Methods and Statistical Physics
Continuous Probability Distributions.  Experiments can lead to continuous responses i.e. values that do not have to be whole numbers. For example: height.
Random number generation Algorithms and Transforms to Univariate Distributions.
CHAPTER 16 MARKOV CHAIN MONTE CARLO
Part 9: Normal Distribution 9-1/47 Statistics and Data Analysis Professor William Greene Stern School of Business IOMS Department Department of Economics.
Different information
Simulation Modeling and Analysis
Using random numbers Simulation: accounts for uncertainty: biology (large number of individuals), physics (large number of particles, quantum mechanics),
Using random numbers Simulation: accounts for uncertainty: biology (large number of individuals), physics (large number of particles, quantum mechanics),
CS 351/ IT 351 Modelling and Simulation Technologies Random Variates Dr. Jim Holten.
Lecture 10 Outline Monte Carlo methods History of methods
Pseudorandom Number Generators
Evaluating Hypotheses
Statistics.
Generating Continuous Random Variables some. Quasi-random numbers So far, we learned about pseudo-random sequences and a common method for generating.
Simulation of emission tomography Robert L. Harrison University of Washington Medical Center Seattle, Washington, USA Supported in part by PHS grants CA42593.
K. Desch – Statistical methods of data analysis SS10
CHAPTER 6 Statistical Analysis of Experimental Data
CSCE Monte Carlo Methods When you can’t do the math, simulate the process with random numbers Numerical integration to get areas/volumes Particle.
Continuous Random Variables and Probability Distributions
Lehrstuhl für Informatik 2 Gabriella Kókai: Maschine Learning 1 Evaluating Hypotheses.
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
Chapter 21 Random Variables Discrete: Bernoulli, Binomial, Geometric, Poisson Continuous: Uniform, Exponential, Gamma, Normal Expectation & Variance, Joint.
Random-Number Generation. 2 Properties of Random Numbers Random Number, R i, must be independently drawn from a uniform distribution with pdf: Two important.
Random Number Generation Fall 2013
ETM 607 – Random Number and Random Variates
Component Reliability Analysis
1 CE 530 Molecular Simulation Lecture 7 David A. Kofke Department of Chemical Engineering SUNY Buffalo
1 Statistical Mechanics and Multi- Scale Simulation Methods ChBE Prof. C. Heath Turner Lecture 11 Some materials adapted from Prof. Keith E. Gubbins:
01/24/05© 2005 University of Wisconsin Last Time Raytracing and PBRT Structure Radiometric quantities.
Short Resume of Statistical Terms Fall 2013 By Yaohang Li, Ph.D.
880.P20 Winter 2006 Richard Kass 1 Confidence Intervals and Upper Limits Confidence intervals (CI) are related to confidence limits (CL). To calculate.
The University of Texas at Arlington Topics in Random Processes CSE 5301 – Data Modeling Guest Lecture: Dr. Gergely Záruba.
PROBABILITY & STATISTICAL INFERENCE LECTURE 3 MSc in Computing (Data Analytics)
Monte Carlo Simulation and Personal Finance Jacob Foley.
1 Theoretical Physics Experimental Physics Equipment, Observation Gambling: Cards, Dice Fast PCs Random- number generators Monte- Carlo methods Experimental.
Monte Carlo and Statistical Methods in HEP Kajari Mazumdar Course on Particle Physics, TIFR, August, 2009.
1 Lesson 3: Choosing from distributions Theory: LLN and Central Limit Theorem Theory: LLN and Central Limit Theorem Choosing from distributions Choosing.
Modeling and Simulation
1 Statistical Distribution Fitting Dr. Jason Merrick.
CS433 Modeling and Simulation Lecture 15 Random Number Generator Dr. Anis Koubâa 24 May 2009 Al-Imam Mohammad Ibn Saud Islamic University College Computer.
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:
Random Number Generators 1. Random number generation is a method of producing a sequence of numbers that lack any discernible pattern. Random Number Generators.
Monte Carlo Methods.
Experimental Method and Data Process: “Monte Carlo Method” Presentation # 1 Nafisa Tasneem CHEP,KNU
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.
PROBABILITY AND STATISTICS FOR ENGINEERING Hossein Sameti Department of Computer Engineering Sharif University of Technology Mean, Variance, Moments and.
Exam 2: Rules Section 2.1 Bring a cheat sheet. One page 2 sides. Bring a calculator. Bring your book to use the tables in the back.
Ch. 14: Markov Chain Monte Carlo Methods based on Stephen Marsland, Machine Learning: An Algorithmic Perspective. CRC 2009.; C, Andrieu, N, de Freitas,
Sampling and estimation Petter Mostad
1 6. Mean, Variance, Moments and Characteristic Functions For a r.v X, its p.d.f represents complete information about it, and for any Borel set B on the.
Continuous Random Variables and Probability Distributions
STA347 - week 91 Random Vectors and Matrices A random vector is a vector whose elements are random variables. The collective behavior of a p x 1 random.
EMIS 7300 SYSTEMS ANALYSIS METHODS FALL 2005 Dr. John Lipp Copyright © 2005 Dr. John Lipp.
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.
Generating Random Variates
Lesson 8: Basic Monte Carlo integration
Introductory Statistics and Data Analysis
Oliver Schulte Machine Learning 726
Chapter 3 Component Reliability Analysis of Structures.
Lecture 2 – Monte Carlo method in finance
Validating a Random Number Generator
Generating Random Variates
Continuous Random Variables: Basics
Presentation transcript:

Introduction to Monte Carlo Simulation Robert L. Harrison University of Washington Medical Center Seattle, Washington, USA Supported in part by PHS grants CA42593 and CA126593 SimSET as platform for research

What is Monte Carlo? Monte Carlo methods are a class of algorithms that rely on repeated random sampling to compute their results. (Wikipedia) Step through what is meant by modular: photons are tracked through the phantom/object, then through the collimator/endplates, then through the detector. Various models are available for the collimators and detectors. Available for free download from our website. We also supply user support.

An example: estimating an integral • Randomly generate points in square. • Count the points under the curve. • Divide the number under curve by total number of points. • 1000 points. • 717 under curve. • Estimate = 0.717. • 100 points. • 69 under curve. • Estimate = 0.69. • 400 points. • 278 under curve. • Estimate = 0.695. Over four hundred registered users. Looking through the hundreds of papers, dissertations and theses that have used SimSET, most have done one of these three things: Optimizing patient studies, e.g. Chicco et al compared the diagnostic capabilities of planar imaging and SPECT for diagnosing pulmonary lesions; Assessing and improving quantitation, e.g. Ollinger used SimSET in the development of model-based scatter correction; Prototyping tomomgraphs, big and small, e.g. Shokouhi et al at Brookhaven prototyped their RatCap tomograph using SimSET.

A little history… Buffon’s needle. Student / William Gosset. Manhattan project. The new block detector model allows a detector array to be built up from rectangular boxes of material. The block model is much closer to the actual design of most PET scanners than SimSET’s previous model (solid cylindrical annuli of crystal)

Buffon’s needle Georges-Louis Leclerc, Comte de Buffon (1707 – 1788). A party game using a lined piece of paper and a pin. Estimates the value of   = 2*drops/hits. Can’t really give a live demonstration of SimSET - it doesn’t have a pretty user interface with buttons and slider bars. It is run from the command line in Unix. A run is set up and controlled using text parameter files. This talk steps through the process of setting up a simulation. http://www.shodor.org/interactivate/activities/buffon

William Gosset (1876-1937) Supervised the experimental brewery at Guiness. Developed methods to draw conclusions from small sample size experiments. Published under the penname A. Student. Student t-test.

Manhattan project Development of first nuclear weapons. Needed to extrapolate knowledge of a single neutron’s behavior to the behavior of a system of neutrons. Experimentation was to dangerous, time-consuming, costly.

Manhattan project… John von Neumann (1903-1957) and Stanislaus Ulam (1909-1984). Developed particle tracking Monte Carlo simulation.

Why do people simulate? Throughout the following slides emphasize that these values are given in text parameter files.

Why do people simulate? Low cost way to experiment. Easy to repeat/modify. Study systems to complex to solve analytically. Examine hidden quantities. Throughout the following slides emphasize that these values are given in text parameter files.

Disadvantages Time consuming. Doesn’t give exact solution. Is the model correct? Bugs, bugs, bugs. Throughout the following slides emphasize that these values are given in text parameter files.

Alternatives Analytic solution. Experiment. Throughout the following slides emphasize that these values are given in text parameter files.

Mechanics of simulation General method. Random number generator. Sampling from a distribution. Accelerating a simulation. Only endplates.

General Monte Carlo Method Model a physical system as a (series of) probability density function(s). Repeatedly sample from the pdf(s). Tally the statistics of interest. (There are many Monte Carlo simulations that don’t fit the above exactly.)

Random numbers Generally we sample from a uniform distribution of integers over [0,n]. Convert to a uniform distribution on the interval (0,0), [0,1) or [0,1]. (e.g., divide integer value by n or n+1.) Lists of truly random numbers. E.g., time between radioactive decays. Pseudo-random number generators. Calculate a randoms number!?

Pseudo-random number generators Usually called random number generators (RNG). (Early - bad) Middle squares. (Still around - bad) Linear congruential generator. (Good) Mersenne twister.

Middle square Von Neumann, 1946. To generate a sequence of 10 digit integers, start with one, and square it and then take the middle 10 digits from the result as the next number in the sequence e.g. 57721566492 = 33317792380594909291 the next number is • Not a recommended method!

Linear congruential generator Lehmer, 1948. In+1 = (aIn + c) mod m I0 = Starting value (seed) a, c, and m are specially chosen constants.

Linear congruential generator… Values used by some built-in random functions are very poor. Good values for a, c, and m on-line. Even with good values, there can be problems. Three dimensional sampling from a linear congruential generator with poorly chosen values, RANDU (Wikipedia).

Mersenne twister Used in MatLab, Maple. Does very well on most tests of randomness. Ridiculously long period. Reasonably fast.

Mersenne twister Used in MatLab, Maple. Does very well on most tests of randomness. Ridiculously long period. Reasonably fast. Quite complicated to implement/describe.

Sampling from a distribution We have a uniform distribution, how do we sample from An exponential distribution? Other continuous distributions? A Poisson distribution?

Exponential distribution Time between radioactive decays. Distance a photon travels before an interaction. Mean 1/, variance 1/ Probability density function (pdf) (Wikipedia) Cumulative distribution function (cdf)

Sampling from the exponential distribution Sample u from the uniform distribution on [0,1).

Sampling from the exponential distribution Sample u from [0,1). Locate u on the y-axis of the exponential distribution cdf. u

Sampling from the exponential distribution Sample u from [0,1). Locate u on y-axis. Find the x value that corresponds to u. u x

Sampling from the exponential distribution Sample u from [0,1). Locate u on y-axis. Find x = F-1(u). u x

Sampling from an invertible continuous distribution Sample u from the unit interval. Find x = F-1(u).

Other sampling methods for continuous distributions Approximate F-1(u), e.g., as a piecewise linear function. Table lookups are fast! Approximate => bias. Acceptance-rejection method. AKA rejection method, accept-reject method, rejection sampling.

Acceptance-rejection To sample from a pdf f(x): Choose pdf g(x) and constant c such that c*g(x) ≥ f(x) for all x www.mathworks.com

Acceptance-rejection To sample from f(x): Choose g(x) and c: c*g(x) ≥ f(x) for all x. Generate a random number v from g(x). Generate a random number u from the uniform distribution on (0,1). v

Acceptance-rejection To sample from f(x): Choose g(x) and c: c*g(x) ≥ f(x) for all x. Generate v from g(x). Generate u from uniform distribution. If c*u ≤ f(v)/g(v) accept v else reject v and go to 2.

Acceptance-rejection To sample from f(x): Choose g(x) and c: c*g(x) ≥ f(x) for all x. Generate v from g(x). Generate uniform u. If c*u ≤ f(v)/g(v) accept v else reject, go to 2. The average number of iterations is c.

Acceptance-rejection Sampling from a normal distribution. While the cdf is invertible, the resulting formula is computationally inefficient. Generally sampling is done using the Box-Muller or Ziggurat algorithms. Use a library function! Acceptance-rejection also be used to remove the bias from an approximation/table lookup sampling method.

Sampling from a normal distribution Gaussian, bell curve. Everything is normal. Central limit theorem: the sum of a large number of independent random variables is approximately normally distributed. Generally sampled using the acceptance-rejection method. Use a library function! pdf cdf (Wikipedia)

Poisson distribution Discrete probability distribution. {0,1,2…} (non-negative integer) result. Mean = variance =  Probability mass function (Wikipedia) Cumulative density function

Poisson distribution Distribution for: how many light bulbs will burn out in a month? Large building. Maintenance department immediately replaces burned out bulb. Choose  = the average number that burn out in a month How many mathematicians does it take to change a light bulb? In earlier work, Haynor[1] has shown that one mathematician can change a light bulb. (www.clipartof.com)

Poisson distribution Other examples: Number of radioactive decays. Number of bugs discovered in a program. Number of calls to a call center. Number of scintillation photons. How many mathematicians does it take to change a light bulb? None. It's left to the reader as an exercise. (www.clipartof.com)

Sampling from Poisson distributions Use a library function! Use the exponential distribution. Let T be the time period, set t = 0, k = 0. Sample tk from the exponential distribution. t = t + tk, k = k + 1; If t < T, go to 2. Return (k - 1). For  large approximate using a normal distribution. How many quantum physicists does it take to change a light bulb? They can't. If they know where the socket is, they cannot locate the new bulb. (www.clipartof.com)

Keeping track of results Tally (score, bin, histogram) the quantities we are interested in, e.g.: Number of light bulbs replaced by month; Time to failure for a product.

Building a simulation Often a single ‘event’ in a simulation will require sampling from many different pdfs, some many times, and be tallied in many ways.

Building a simulation For example, a nuclear physics simulation might model the time between decays the decay process the paths of photons and particles the energy deposited during tracking and any secondary particles created thereby the detection electronics… and tally energy, position, and type of detected particles.

Take away Simulation a key tool for analytically intractable problems. Currently the Mersenne Twister is a good choice of random number generator. Random sampling for functions: cdfs are analytically invertible; use library functions if available; acceptance-rejection method; piecewise approximation. Four key distributions: uniform, exponential, normal, Poisson.

References J.T. Bushberg, The essential physics of medical imaging, Lippincott Williams & Wilkins, 2002. K.P. George et al, Brain Imaging in Neurocommunicative Disorders, in Medical speech-language pathology: a practitioner's guide, ed. A.F. Johnson, Thieme, 1998. D.E. Heron et al, FDG-PET and PET/CT in Radiation Therapy Simulation and Management of Patients Who Have Primary and Recurrent Breast Cancer, PET Clin, 1:39–49, 2006. E.G.A. Aird and J. Conway, CT simulation for radiotherapy treatment planning, British J Radiology, 75:937-949, 2002. R. McGarry and A.T. Turrisi, Lung Cancer, in Handbook of Radiation Oncology: Basic Principles and Clinical Protocols, ed. B.G. Haffty and L.D. Wilson, Jones & Bartlett Publishers, 2008. R. Schmitz et al, The Physics of PET/CT Scanners, in PET and PET/CT: a clinical guide, ed. E. Lin and A. Alavi, Thieme, 2005. W.P. Segars and B.M.W. Tsui, Study of the efficacy of respiratory gating in myocardial SPECT using the new 4-D NCAT phantom, IEEE Transactions on Nuclear Science, 49(3):675-679, 2002. V.W. Stieber et al, Central Nervous System Tumors, in Technical Basis of Radiation Therapy: Practical Clinical Applications, ed. S.H. Levitt et al, Springer, 2008. P. Suetens, Fundamentals of medical imaging, Cambridge University Press, 2002. www.wofford.org/ecs/ScientificProgramming/MonteCarlo/index.htm www.shodor.org/interactivate/activities/buffon www.impactscan.org/slides/impactcourse/introduction_to_ct_in_radiotherapy