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

Similar documents
Convergence of Random Processes

Computer intensive statistical methods Lecture 1

Introduction to Machine Learning CMU-10701

Monte Carlo Methods. Part I: Introduction

2008 Winton. Review of Statistical Terminology

Review of Statistical Terminology

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

1 Backward and Forward Error

WeBWorK, Problems 2 and 3

1.4 Techniques of Integration

Sampling exactly from the normal distribution

To: Professor Paul McCudden 9/3/15 Dr. John Sepikas

8.1 Solutions of homogeneous linear differential equations

26, 24, 26, 28, 23, 23, 25, 24, 26, 25

BEST TESTS. Abstract. We will discuss the Neymann-Pearson theorem and certain best test where the power function is optimized.

Differentiation by taking logarithms

Intelligent Systems I

First and Last Name: 2. Correct The Mistake Determine whether these equations are false, and if so write the correct answer.

Generating Random Variables

MAS1302 Computational Probability and Statistics

Simulation. Version 1.1 c 2010, 2009, 2001 José Fernando Oliveira Maria Antónia Carravilla FEUP

Reduction of Variance. Importance Sampling

Taking Derivatives. Exam II Review - Worksheet Name: Math 1131 Class #31 Section: 1. Compute the derivative of f(x) = sin(x 2 + x + 1)

One important way that you can classify differential equations is as linear or nonlinear.

Substitutions and by Parts, Area Between Curves. Goals: The Method of Substitution Areas Integration by Parts

Great Theoretical Ideas in Computer Science

1.10 Continuity Brian E. Veitch

Monte Carlo programs

Predicates, Quantifiers and Nested Quantifiers

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

M155 Exam 2 Concept Review

Generating the Sample

Computer projects for Mathematical Statistics, MA 486. Some practical hints for doing computer projects with MATLAB:

Experiments in Periodicity

Math 221 Notes on Rolle s Theorem, The Mean Value Theorem, l Hôpital s rule, and the Taylor-Maclaurin formula. 1. Two theorems

MITOCW ocw f07-lec39_300k

Support for UCL Mathematics offer holders with the Sixth Term Examination Paper

Monte Carlo Methods for Computation and Optimization (048715)

Machine Learning. Probability Basics. Marc Toussaint University of Stuttgart Summer 2014

Transformation of Probability Densities

Week 3: Reductions and Completeness

Probability Distributions

Monte Carlo Simulations

6.0 INTRODUCTION TO DIFFERENTIAL EQUATIONS

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

Introduction to Discrepancy Theory

DIFFERENTIATION AND INTEGRATION PART 1. Mr C s IB Standard Notes

Contraction Mappings Consider the equation

Monte Carlo Integration

MONTE CARLO METHOD. Reference1: Smit Frenkel, Understanding molecular simulation, second edition, Academic press, 2002.

Math Practice Exam 3 - solutions

Notes on Computer Systems for Solving Symbolic Equations

#29: Logarithm review May 16, 2009

Homework Solutions: , plus Substitutions

Bell-shaped curves, variance

Markov Chain Monte Carlo The Metropolis-Hastings Algorithm

Today: Fundamentals of Monte Carlo

MITOCW ocw f99-lec01_300k

ISyE 3044 Fall 2015 Test #1 Solutions

We consider the problem of finding a polynomial that interpolates a given set of values:

SYDE 112, LECTURE 7: Integration by Parts

MATH 105: PRACTICE PROBLEMS FOR CHAPTER 3: SPRING 2010

Introduction to Differentials

MATH 124. Midterm 2 Topics

MATH20411 PDEs and Vector Calculus B

Math 480 The Vector Space of Differentiable Functions

MATH 250 TOPIC 13 INTEGRATION. 13B. Constant, Sum, and Difference Rules

Solving Quadratic & Higher Degree Equations

Limit. Chapter Introduction

Math 233. Directional Derivatives and Gradients Basics

This exam is closed book and closed notes. (You will have access to a copy of the Table of Common Distributions given in the back of the text.

Physics 403 Monte Carlo Techniques

numerical analysis 1

A special rule, the chain rule, exists for differentiating a function of another function. This unit illustrates this rule.

(x 3)(x + 5) = (x 3)(x 1) = x + 5. sin 2 x e ax bx 1 = 1 2. lim

Probability Exercises. Problem 1.

Section 4.7 Scientific Notation

Stochastic modelling in Mathematical Biology

Spring 2017 Midterm 1 04/26/2017

Solving Quadratic & Higher Degree Equations

Why does pi keep popping up? Undergraduate Colloquium, October 2007 I. Definitions and Archimedes. II. Digits and some silliness (and Ramanujan)

Instructor (Brad Osgood)

Does randomness solve problems? Russell Impagliazzo UCSD

Math 234 Exam 3 Review Sheet

MITOCW watch?v=fxlzy2l1-4w

Math 111 lecture for Friday, Week 10

TAYLOR POLYNOMIALS DARYL DEFORD

Mathematical Background. e x2. log k. a+b a + b. Carlos Moreno uwaterloo.ca EIT e π i 1 = 0.

1 4 r q. (9.172) G(r, q) =

1) [16 points] The light intensity of a particular light source (not an ideal blackbody) is given by the equation. p = - iħ d (2.

Investigating Limits in MATLAB

Test for Increasing and Decreasing Theorem 5 Let f(x) be continuous on [a, b] and differentiable on (a, b).

Monte Carlo Sampling

Integration, Separation of Variables

MACHINE LEARNING INTRODUCTION: STRING CLASSIFICATION

Last Time. x + 3y = 6 x + 2y = 1. x + 3y = 6 y = 1. 2x + 4y = 8 x 2y = 1. x + 3y = 6 2x y = 7. Lecture 2

PROBABILITY VITTORIA SILVESTRI

This exam is closed book and closed notes. (You will have access to a copy of the Table of Common Distributions given in the back of the text.

Understanding Decimal Addition

11.5. The Chain Rule. Introduction. Prerequisites. Learning Outcomes

Transcription:

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

Random numbers Any one who considers arithmetical methods of producing random digits is, of course, in a state of sin. [John Von Neumann] 2

The Monte Carlo method? No text book definition, but here is an attempt: Using random numbers (hence reference to the Monte Carlo casino) to solve problems, typically without known solutions and/or of high dimensionality 3

Calculating Pi 4

Calculating Pi Many problems and calculations can be done using random numbers. In this example, it is the estimate of pi, which is the target. Recipe: Find min and max in both x and y. Generate uniform random numbers (x,y) in these ranges. Accept x, if y < f(x). Reject x, if y > f(x). 5

Challenge How to produce random numbers according to an arbitrary PDF from uniform number? 6

Transformation method We have uniformly distributed random numbers r. We want random numbers x according to some distribution. Can we find a function x(r), such that r (uniformly distributed numbers) will be transformed into the desired distribution f(x)? Well, maybe It turns out, that this is only possible, if one can (in this order): Integrate f(x), and then Invert F(x) As this is rare, this method can not often be used by itself. However, in combination with the Hit-and-Miss method, it can pretty much solve all problems. 7

Transformation method So the recipe can be summarised as follows: Steps: Ensure that the PDF is normalised! Integrate f(x) to get F(x) with the definite integral: Invert F(x) F (x) = Z x 1 f(x 0 )dx 0 Now you can generate random numbers, x, according to f(x), by choosing x = F -1 (u), where u is a random uniform number. 8

Transformation method: Example Consider an exponential distribution: f(x) = λ exp(-λx), x [0, ] Is it normalised? Yes Can we integrate f(x) to find F(x)? Yes F(x) = 1 exp( λx), x [0, ] Can we invert F(x) to find F -1 (x)? Yes F 1 (p) = log(1 p) / λ, p [0,1] This is a classic example of how to use the transformation method. Note that the exponential distribution is not bounded upwards in x. This formula was actually used in the very first exercise (central limit theorem), where some of you noticed it. 9

Accept-Reject method (Von Neumann method) If the PDF we wish to sample from is bounded both in x and y, then we can use the Accept-Reject method to select random numbers from it, as follows: Pick x and y uniformly without in the range of the PDF. If y is below PDF(x), then accept x. The main advantage of this method is its simplicity, without requiring invertible integral. Given modern computers, one does not care much about efficiency. However, it requires boundaries! 10

Accept-Reject method: Example (Von Neumann method) Consider an exponential distribution: f(x) = (1 + sin(x))/2$, x [0,2$] Can we integrate f(x) to find F(x)? Yes F(x) = (x cos(x))/2$, x [0,2$] Can we invert F(x) to find F -1 (x)? No!!! So transformation method doesn t work! However, the function is bounded in both x and y, and so by generating pairs of random uniform numbers (u,v) in the corresponding x- and y-range, we can get random numbers according to f(x), if we accept those for which f(u) < v. Function: f(x) = (1 + sin(x)) / 2π Y-axis 0.3 0.25 0.2 0.15 0.1 0.05 0 0 1 2 3 4 5 6 X-axis 11

Accept-Reject method: Example (Von Neumann method) Consider an exponential distribution: f(x) = (1 + sin(x))/2$, x [0,2$] Can we integrate f(x) to find F(x)? Yes F(x) = (x cos(x))/2$, x [0,2$] Can we invert F(x) to find F -1 (x)? No!!! So transformation method doesn t work! However, the function is bounded in both x and y, and so by generating pairs of random uniform numbers (u,v) in the corresponding x- and y-range, we can get random numbers according to f(x), if we accept those for which f(u) < v. Illustration of Accept-Rejection method for PDF: f(x) = (1 + sin(x)) / 2π Y-axis 0.3 0.25 0.2 0.15 0.1 0.05 0 0 1 2 3 4 5 6 X-axis 12

Dimensionality of problems For simple low dimensionality problems, (possibly) numerical integrals are the fastest solution. However, with increasing complexity, the Monte Carlo method wins : Monte Carlo method: 1 p N Numerical (e.g. trapizoidal rule): 1 N 2/d The Monte Carlo method is also easier to get uncertainties from, and usually quicker to implement. Monte Carlo is simply a great tool for testing/giving insight/integrating into almost all experimental situations. Use it! 13

History of the Monte Carlo The first thoughts and attempts I made to practice [the Monte Carlo Method] were suggested by a question which occurred to me in 1946 as I was convalescing from an illness and playing solitaires. The question was what are the chances that a Canfield solitaire laid out with 52 cards will come out successfully? After spending a lot of time trying to estimate them by pure combinatorial calculations, I wondered whether a more practical method than "abstract thinking" might not be to lay it out say one hundred times and simply observe and count the number of successful plays. This was already possible to envisage with the beginning of the new era of fast computers [ ]. Later [in 1946], I described the idea to John von Neumann, and we began to plan actual calculations. [Stanisław Ulam, co-inventer of the hydrogen bomb] Stanisław Ulam is probably best known for realising that electronic computers made it practical to apply statistical methods to functions without known solutions, and as computers have developed, the Monte Carlo method has become a ubiquitous and standard approach to many problems. [Wikipedia on Stanislaw Ulam] 14