Stochastic Simulation

Similar documents
IEOR E4703: Monte-Carlo Simulation

UQ, STAT2201, 2017, Lectures 3 and 4 Unit 3 Probability Distributions.

continuous rv Note for a legitimate pdf, we have f (x) 0 and f (x)dx = 1. For a continuous rv, P(X = c) = c f (x)dx = 0, hence

Reliability and Risk Analysis. Survival and Reliability Function

Importance Sampling for Option Pricing. Steven R. Dunbar. Put Options. Monte Carlo Method. Importance. Sampling. Examples.

Random Variables Handout. Xavier Vilà

INDIAN INSTITUTE OF SCIENCE STOCHASTIC HYDROLOGY. Lecture -5 Course Instructor : Prof. P. P. MUJUMDAR Department of Civil Engg., IISc.

The Normal Distribution

10. Monte Carlo Methods

Hand and Spreadsheet Simulations

STAT 825 Notes Random Number Generation

Chapter 3 Common Families of Distributions. Definition 3.4.1: A family of pmfs or pdfs is called exponential family if it can be expressed as

IEOR 165 Lecture 1 Probability Review

6. Continous Distributions

Generating Random Variables and Stochastic Processes

Posterior Inference. , where should we start? Consider the following computational procedure: 1. draw samples. 2. convert. 3. compute properties

ELEMENTS OF MONTE CARLO SIMULATION

Chapter 2: Random Variables (Cont d)

Computer labs. May 10, A list of matlab tutorials can be found under

Auction theory. Filip An. U.U.D.M. Project Report 2018:35. Department of Mathematics Uppsala University

Lesson Plan for Simulation with Spreadsheets (8/31/11 & 9/7/11)

4-2 Probability Distributions and Probability Density Functions. Figure 4-2 Probability determined from the area under f(x).

Review for Final Exam Spring 2014 Jeremy Orloff and Jonathan Bloom

2. The sum of all the probabilities in the sample space must add up to 1

STOR Lecture 15. Jointly distributed Random Variables - III

Continuous random variables

Exam M Fall 2005 PRELIMINARY ANSWER KEY

Normal Distribution. Definition A continuous rv X is said to have a normal distribution with. the pdf of X is

Advanced Financial Economics Homework 2 Due on April 14th before class

Statistical Computing (36-350)

The Normal Distribution

ECE 340 Probabilistic Methods in Engineering M/W 3-4:15. Lecture 10: Continuous RV Families. Prof. Vince Calhoun

Week 1 Quantitative Analysis of Financial Markets Probabilities

4-1. Chapter 4. Commonly Used Distributions by The McGraw-Hill Companies, Inc. All rights reserved.

Chapter 2. Random variables. 2.3 Expectation

Write legibly. Unreadable answers are worthless.

NEWCASTLE UNIVERSITY SCHOOL OF MATHEMATICS, STATISTICS & PHYSICS SEMESTER 1 SPECIMEN 2 MAS3904. Stochastic Financial Modelling. Time allowed: 2 hours

Ch4. Variance Reduction Techniques

Review. Binomial random variable

INDIAN INSTITUTE OF SCIENCE STOCHASTIC HYDROLOGY. Lecture -26 Course Instructor : Prof. P. P. MUJUMDAR Department of Civil Engg., IISc.

Welcome to Stat 410!

Slides for Risk Management

Chapter 6. Importance sampling. 6.1 The basics

Chapter 4: Commonly Used Distributions. Statistics for Engineers and Scientists Fourth Edition William Navidi

Lecture 23. STAT 225 Introduction to Probability Models April 4, Whitney Huang Purdue University. Normal approximation to Binomial

For more information about how to cite these materials visit

A GENERAL FORMULA FOR OPTION PRICES IN A STOCHASTIC VOLATILITY MODEL. Stephen Chin and Daniel Dufresne. Centre for Actuarial Studies

Bivariate Birnbaum-Saunders Distribution

Generating Random Numbers

Monte Carlo and Empirical Methods for Stochastic Inference (MASM11/FMS091)

Overview. Transformation method Rejection method. Monte Carlo vs ordinary methods. 1 Random numbers. 2 Monte Carlo integration.

STAT Chapter 4/6: Random Variables and Probability Distributions

Results for option pricing

Lecture Note 8 of Bus 41202, Spring 2017: Stochastic Diffusion Equation & Option Pricing

Bias Reduction Using the Bootstrap

Central Limit Theorem (CLT) RLS

Expected Utility And Risk Aversion

Lecture 10: Point Estimation


Tutorial 11: Limit Theorems. Baoxiang Wang & Yihan Zhang bxwang, April 10, 2017

PROBABILITY. Wiley. With Applications and R ROBERT P. DOBROW. Department of Mathematics. Carleton College Northfield, MN

Math489/889 Stochastic Processes and Advanced Mathematical Finance Homework 5

14.30 Introduction to Statistical Methods in Economics Spring 2009

18.05 Problem Set 3, Spring 2014 Solutions

Monte Carlo Methods for Uncertainty Quantification

Queens College, CUNY, Department of Computer Science Computational Finance CSCI 365 / 765 Fall 2017 Instructor: Dr. Sateesh Mane.

Chapter 6: Point Estimation

Random Samples. Mathematics 47: Lecture 6. Dan Sloughter. Furman University. March 13, 2006

1 Auctions. 1.1 Notation (Symmetric IPV) Independent private values setting with symmetric riskneutral buyers, no budget constraints.

CHOICE THEORY, UTILITY FUNCTIONS AND RISK AVERSION

1 Rare event simulation and importance sampling

Expected Value and Variance

CS 237: Probability in Computing

Monte Carlo and Empirical Methods for Stochastic Inference (MASM11/FMSN50)

1 Geometric Brownian motion

Basic notions of probability theory: continuous probability distributions. Piero Baraldi

IEOR E4703: Monte-Carlo Simulation

Commonly Used Distributions

Favorite Distributions

Building Consistent Risk Measures into Stochastic Optimization Models

Chapter 4 Continuous Random Variables and Probability Distributions

MATH 476/567 ACTUARIAL RISK THEORY FALL 2016 PROFESSOR WANG

Exam STAM Practice Exam #1

Homework Assignments

Discrete Random Variables and Probability Distributions. Stat 4570/5570 Based on Devore s book (Ed 8)

STA258H5. Al Nosedal and Alison Weir. Winter Al Nosedal and Alison Weir STA258H5 Winter / 41

Lecture Notes 6. Assume F belongs to a family of distributions, (e.g. F is Normal), indexed by some parameter θ.

Lecture 7: Computation of Greeks

Control Improvement for Jump-Diffusion Processes with Applications to Finance

MATH 142 Business Mathematics II

Chapter 2 ( ) Fall 2012

Risk Measurement in Credit Portfolio Models

Definition 9.1 A point estimate is any function T (X 1,..., X n ) of a random sample. We often write an estimator of the parameter θ as ˆθ.

Simulation Wrap-up, Statistics COS 323

Math 361. Day 8 Binomial Random Variables pages 27 and 28 Inv Do you have ESP? Inv. 1.3 Tim or Bob?

Numerical valuation for option pricing under jump-diffusion models by finite differences

Solving the Black-Scholes Equation

(Practice Version) Midterm Exam 1

Describing Uncertain Variables

Approximating random inequalities with. Edgeworth expansions

Transcription:

Stochastic Simulation APPM 7400 Lesson 5: Generating (Some) Continuous Random Variables September 12, 2018 esson 5: Generating (Some) Continuous Random Variables Stochastic Simulation September 12, 2018 1 / 1

Generating Continuous Random Variables Suppose that X is a continuous random variable with cdf F (x). esson 5: Generating (Some) Continuous Random Variables Stochastic Simulation September 12, 2018 2 / 1

Generating Continuous Random Variables Suppose that X is a continuous random variable with cdf F (x). Furthermore, suppose that you can invert F. esson 5: Generating (Some) Continuous Random Variables Stochastic Simulation September 12, 2018 2 / 1

Generating Continuous Random Variables Suppose that X is a continuous random variable with cdf F (x). Furthermore, suppose that you can invert F. If U unif (0, 1), the random variable F 1 (U) has the same distribution as X! esson 5: Generating (Some) Continuous Random Variables Stochastic Simulation September 12, 2018 2 / 1

Generating Continuous Random Variables Proof: P(F 1 (U) x) esson 5: Generating (Some) Continuous Random Variables Stochastic Simulation September 12, 2018 3 / 1

Generating Continuous Random Variables Proof: P(F 1 (U) x) = P(U F (x)) F non-decreasing F 1 non-decreasing esson 5: Generating (Some) Continuous Random Variables Stochastic Simulation September 12, 2018 3 / 1

Generating Continuous Random Variables Proof: P(F 1 (U) x) = P(U F (x)) = F (x) F non-decreasing cdf of unif(0,1) F 1 non-decreasing esson 5: Generating (Some) Continuous Random Variables Stochastic Simulation September 12, 2018 3 / 1

Generating Continuous Random Variables Proof: P(F 1 (U) x) = P(U F (x)) = F (x) = P(X x) F non-decreasing F 1 non-decreasing cdf of unif(0,1) definition of F esson 5: Generating (Some) Continuous Random Variables Stochastic Simulation September 12, 2018 3 / 1

Generating Continuous Random Variables Example: Generating exponential rate λ r.v. s: pdf: f (x) = λe λx, x 0 esson 5: Generating (Some) Continuous Random Variables Stochastic Simulation September 12, 2018 4 / 1

Generating Continuous Random Variables Example: Generating exponential rate λ r.v. s: pdf: f (x) = λe λx, x 0 cdf: F (x) = x 0 λe λu du = 1 e λx, x 0 esson 5: Generating (Some) Continuous Random Variables Stochastic Simulation September 12, 2018 4 / 1

Generating Continuous Random Variables Example: Generating exponential rate λ r.v. s: pdf: f (x) = λe λx, x 0 cdf: F (x) = x 0 λe λu du = 1 e λx, x 0 F 1 (x) = 1 λ ln(1 x) esson 5: Generating (Some) Continuous Random Variables Stochastic Simulation September 12, 2018 4 / 1

Generating Continuous Random Variables Example: Generating exponential rate λ r.v. s: pdf: f (x) = λe λx, x 0 cdf: F (x) = x 0 λe λu du = 1 e λx, x 0 F 1 (x) = 1 λ ln(1 x) Now plug in a uniform! esson 5: Generating (Some) Continuous Random Variables Stochastic Simulation September 12, 2018 4 / 1

Generating Continuous Random Variables Results: (100,000 values, λ = 3.5) Density 0.0 0.5 1.0 1.5 2.0 2.5 3.0 0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 sample Lesson 5: Generating (Some) Continuous Random Variables Stochastic Simulation September 12, 2018 5 / 1

Generating Continuous Random Variables The Standard Normal Distribution: f (x) = 1 2π e 1 2 x2, < x < Lesson 5: Generating (Some) Continuous Random Variables Stochastic Simulation September 12, 2018 6 / 1

Generating Continuous Random Variables The Standard Normal Distribution: f (x) = 1 2π e 1 2 x2, < x < There is no closed form expression for the cdf! Lesson 5: Generating (Some) Continuous Random Variables Stochastic Simulation September 12, 2018 6 / 1

Generating Continuous Random Variables The Box-Muller Transformation: Let U 1 and U 2 be independent unif (0, 1) r.v. s. Lesson 5: Generating (Some) Continuous Random Variables Stochastic Simulation September 12, 2018 7 / 1

Generating Continuous Random Variables The Box-Muller Transformation: Let U 1 and U 2 be independent unif (0, 1) r.v. s. Then X 1 = 2 ln U 1 cos(2πu 2 ) is normally distributed with mean 0 and variance 1. Lesson 5: Generating (Some) Continuous Random Variables Stochastic Simulation September 12, 2018 7 / 1

Generating Continuous Random Variables The Box-Muller Transformation: Let U 1 and U 2 be independent unif (0, 1) r.v. s. Then X 1 = 2 ln U 1 cos(2πu 2 ) is normally distributed with mean 0 and variance 1. So is X 2 = 2 ln U 1 sin(2πu 2 ) Lesson 5: Generating (Some) Continuous Random Variables Stochastic Simulation September 12, 2018 7 / 1

Generating Continuous Random Variables The Box-Muller Transformation: Let U 1 and U 2 be independent unif (0, 1) r.v. s. Then X 1 = 2 ln U 1 cos(2πu 2 ) is normally distributed with mean 0 and variance 1. So is X 2 = 2 ln U 1 sin(2πu 2 ) and X 1 and X 2 are independent! Lesson 5: Generating (Some) Continuous Random Variables Stochastic Simulation September 12, 2018 7 / 1

Generating Continuous Random Variables So far, we have ways to simulate normal random variables random variables for which we have a closed-form invertible cdf Lesson 5: Generating (Some) Continuous Random Variables Stochastic Simulation September 12, 2018 8 / 1

Generating Continuous Random Variables So far, we have ways to simulate normal random variables random variables for which we have a closed-form invertible cdf If neither of these apply to your simulation problem, move on to the next algorithm. Lesson 5: Generating (Some) Continuous Random Variables Stochastic Simulation September 12, 2018 8 / 1

Generating Continuous Random Variables So far, we have ways to simulate normal random variables random variables for which we have a closed-form invertible cdf If neither of these apply to your simulation problem, move on to the next algorithm. It requires that you be able to uniformly bound the target pdf by an integrable function. Lesson 5: Generating (Some) Continuous Random Variables Stochastic Simulation September 12, 2018 8 / 1

Generating Continuous Random Variables So far, we have ways to simulate normal random variables random variables for which we have a closed-form invertible cdf If neither of these apply to your simulation problem, move on to the next algorithm. It requires that you be able to uniformly bound the target pdf by an integrable function. If you can t do that, move on to the next algorithm... there is no catch-all procedure so we d better build up a big arsenal of simulation techniques! Lesson 5: Generating (Some) Continuous Random Variables Stochastic Simulation September 12, 2018 8 / 1

Generating Continuous Random Variables : (due to von Neumann) esson 5: Generating (Some) Continuous Random Variables Stochastic Simulation September 12, 2018 9 / 1

Generating Continuous Random Variables : want to simulate a r.v. X with pdf f (due to von Neumann) Lesson 5: Generating (Some) Continuous Random Variables Stochastic Simulation September 12, 2018 9 / 1

Generating Continuous Random Variables : (due to von Neumann) want to simulate a r.v. X with pdf f need to find another function g so that g(x) f (x) x Lesson 5: Generating (Some) Continuous Random Variables Stochastic Simulation September 12, 2018 9 / 1

Generating Continuous Random Variables : (due to von Neumann) want to simulate a r.v. X with pdf f need to find another function g so that g(x) f (x) x normalize g to a pdf h(x) = 1 c g(x) where c = g(x) dx Lesson 5: Generating (Some) Continuous Random Variables Stochastic Simulation September 12, 2018 9 / 1

The Algorithm: Lesson 5: Generating (Some) Continuous Random Variables Stochastic Simulation September 12, 2018 10 / 1

The Algorithm: generate Y with pdf h Lesson 5: Generating (Some) Continuous Random Variables Stochastic Simulation September 12, 2018 10 / 1

The Algorithm: generate Y with pdf h generate U unif (0, 1) (indep of Y ) Lesson 5: Generating (Some) Continuous Random Variables Stochastic Simulation September 12, 2018 10 / 1

The Algorithm: generate Y with pdf h generate U unif (0, 1) (indep of Y ) if U f (Y )/g(y ), accept Y, set X = Y (Done!) Lesson 5: Generating (Some) Continuous Random Variables Stochastic Simulation September 12, 2018 10 / 1

The Algorithm: generate Y with pdf h generate U unif (0, 1) (indep of Y ) if U f (Y )/g(y ), accept Y, set X = Y (Done!) otherwise, reject Y, return to Lesson 5: Generating (Some) Continuous Random Variables Stochastic Simulation September 12, 2018 10 / 1

Proof: (discrete case) esson 5: Generating (Some) Continuous Random Variables Stochastic Simulation September 12, 2018 11 / 1

Proof: (discrete case) Let X be the value produced by this algorithm esson 5: Generating (Some) Continuous Random Variables Stochastic Simulation September 12, 2018 11 / 1

Proof: (discrete case) Let X be the value produced by this algorithm We will show that P(X = x) = f (x) where f is the target density. esson 5: Generating (Some) Continuous Random Variables Stochastic Simulation September 12, 2018 11 / 1

Proof: (discrete case) Let X be the value produced by this algorithm We will show that P(X = x) = f (x) where f is the target density. Let N be the number of trials until a success? Lesson 5: Generating (Some) Continuous Random Variables Stochastic Simulation September 12, 2018 11 / 1

Proof: (discrete case) Let X be the value produced by this algorithm We will show that P(X = x) = f (x) where f is the target density. Let N be the number of trials until a success? Q: Is N a geometric random variable? Lesson 5: Generating (Some) Continuous Random Variables Stochastic Simulation September 12, 2018 11 / 1

Proof: (discrete case) Let X be the value produced by this algorithm We will show that P(X = x) = f (x) where f is the target density. Let N be the number of trials until a success? Q: Is N a geometric random variable? A: Yes! Success probability? Lesson 5: Generating (Some) Continuous Random Variables Stochastic Simulation September 12, 2018 11 / 1

Proof: (discrete case) Consider the joint probability P(X = x, N = n) We will write down an expression for this and then marginalize out the N. Lesson 5: Generating (Some) Continuous Random Variables Stochastic Simulation September 12, 2018 12 / 1

P(X = x, N = n) = P (n 1 failures, ) U n 1 > f (y n 1) g(y n 1 ), Y n = x, U n f (x) g(x) Lesson 5: Generating (Some) Continuous Random Variables Stochastic Simulation September 12, 2018 13 / 1

P(X = x, N = n) = P (n 1 failures, ) U n 1 > f (y n 1) g(y n 1 ), Y n = x, U n f (x) g(x) ( ) indep = P(n 1 failures) P Y n = x, U n f (x) g(x) Lesson 5: Generating (Some) Continuous Random Variables Stochastic Simulation September 12, 2018 13 / 1

P(X = x, N = n) = P (n 1 failures, ) U n 1 > f (y n 1) g(y n 1 ), Y n = x, U n f (x) g(x) ( ) indep = P(n 1 failures) P Y n = x, U n f (x) g(x) ( ) ident = P(n 1 failures) P Y = x, U f (x) g(x) Lesson 5: Generating (Some) Continuous Random Variables Stochastic Simulation September 12, 2018 13 / 1

So, P(X = x) = n=1 P(X = x, N = n) esson 5: Generating (Some) Continuous Random Variables Stochastic Simulation September 12, 2018 14 / 1

So, P(X = x) = n=1 P(X = x, N = n) ( = P Y = x, U f (x) g(x) ) n=1 P(n 1 failures) esson 5: Generating (Some) Continuous Random Variables Stochastic Simulation September 12, 2018 14 / 1

So, P(X = x) = n=1 P(X = x, N = n) ( = P ( = P Y = x, U f (x) g(x) Y = x, U f (x) g(x) ) n=1 P(n 1 failures) ) [blah (no x s)] esson 5: Generating (Some) Continuous Random Variables Stochastic Simulation September 12, 2018 14 / 1

So, P(X = x) = n=1 P(X = x, N = n) ( = P ( = P Y = x, U f (x) g(x) Y = x, U f (x) g(x) ( indep = P(Y = x) P U f (x) g(x) ) n=1 P(n 1 failures) ) [blah (no x s)] ) [blah (no x s)] esson 5: Generating (Some) Continuous Random Variables Stochastic Simulation September 12, 2018 14 / 1

So, P(X = x) = n=1 P(X = x, N = n) ( = P ( = P Y = x, U f (x) g(x) Y = x, U f (x) g(x) ( indep = P(Y = x) P U f (x) g(x) = h(x) f (x) g(x) [blah (no x s)] ) n=1 P(n 1 failures) ) [blah (no x s)] ) [blah (no x s)] (since f (x) g(x)) esson 5: Generating (Some) Continuous Random Variables Stochastic Simulation September 12, 2018 14 / 1

So, P(X = x) = h(x) f (x) g(x) [blah (no x s)] esson 5: Generating (Some) Continuous Random Variables Stochastic Simulation September 12, 2018 15 / 1

So, P(X = x) = h(x) f (x) g(x) [blah (no x s)] = 1 f (x) c g(x) g(x) [blah (no x s)] esson 5: Generating (Some) Continuous Random Variables Stochastic Simulation September 12, 2018 15 / 1

So, P(X = x) = h(x) f (x) g(x) [blah (no x s)] = 1 f (x) c g(x) g(x) [blah (no x s)] = 1 c f (x) [blah (no x s)] esson 5: Generating (Some) Continuous Random Variables Stochastic Simulation September 12, 2018 15 / 1

So, P(X = x) = h(x) f (x) g(x) [blah (no x s)] = 1 f (x) c g(x) g(x) [blah (no x s)] = 1 c f (x) [blah (no x s)] Sum both sides over x: P(X = x) = x x { } 1 f (x) [blah (no x s)] c esson 5: Generating (Some) Continuous Random Variables Stochastic Simulation September 12, 2018 15 / 1

P(X = x) = x x { } 1 f (x) [blah (no x s)] c Lesson 5: Generating (Some) Continuous Random Variables Stochastic Simulation September 12, 2018 16 / 1

P(X = x) = x x { } 1 f (x) [blah (no x s)] c { } 1 1 = 1 [blah (no x s)] c Lesson 5: Generating (Some) Continuous Random Variables Stochastic Simulation September 12, 2018 16 / 1

P(X = x) = x x { } 1 f (x) [blah (no x s)] c { } 1 1 = 1 [blah (no x s)] c { 1 c } [blah (no x s)] = 1 Lesson 5: Generating (Some) Continuous Random Variables Stochastic Simulation September 12, 2018 16 / 1

P(X = x) = x x { } 1 f (x) [blah (no x s)] c { } 1 1 = 1 [blah (no x s)] c { 1 c } [blah (no x s)] = 1 P(X = x) = f (x) Lesson 5: Generating (Some) Continuous Random Variables Stochastic Simulation September 12, 2018 16 / 1

Example: Simulate X Γ(2, 3) esson 5: Generating (Some) Continuous Random Variables Stochastic Simulation September 12, 2018 17 / 1

Example: Simulate X Γ(2, 3) Target Density: f (x) = 9xe 3x, x > 0 esson 5: Generating (Some) Continuous Random Variables Stochastic Simulation September 12, 2018 17 / 1

Example: Simulate X Γ(2, 3) Target Density: f (x) = 9xe 3x, x > 0 Will try to bound it by a function of the form g(x) = k e 2x. esson 5: Generating (Some) Continuous Random Variables Stochastic Simulation September 12, 2018 17 / 1

Example: Simulate X Γ(2, 3) Target Density: f (x) = 9xe 3x, x > 0 Will try to bound it by a function of the form g(x) = k e 2x. ke 2x 9xe 3x = e 3x (ke x 9x) esson 5: Generating (Some) Continuous Random Variables Stochastic Simulation September 12, 2018 17 / 1

Example: Simulate X Γ(2, 3) Target Density: f (x) = 9xe 3x, x > 0 Will try to bound it by a function of the form g(x) = k e 2x. ke 2x 9xe 3x = e 3x (ke x 9x) Hmmm... k = 9 will work... f1 0.0 0.5 1.0 1.5 2.0 2.5 3.0 0 1 2 3 4 esson 5: Generating (Some) Continuous Random Variables Stochastic Simulation September 12, 2018 17 / 1 x

Example: Simulate X Γ(2, 3) Target Density: f (x) = 9xe 3x, x > 0 Will try to bound it by a function of the form g(x) = k e 2x. ke 2x 9xe 3x = e 3x (ke x 9x) Hmmm... k = 9 will work...... but we might try to do better since the accept probabilities are of the form f /g. f1 0.0 0.5 1.0 1.5 2.0 2.5 3.0 0 1 2 3 4 esson 5: Generating (Some) Continuous Random Variables Stochastic Simulation September 12, 2018 17 / 1 x

Example: Simulate X Γ(2, 3) esson 5: Generating (Some) Continuous Random Variables Stochastic Simulation September 12, 2018 18 / 1

Example: Simulate X Γ(2, 3) Target Density: f (x) = 9xe 3x, x > 0 esson 5: Generating (Some) Continuous Random Variables Stochastic Simulation September 12, 2018 18 / 1

Example: Simulate X Γ(2, 3) Target Density: f (x) = 9xe 3x, x > 0 Will try to bound it by a function of the form g(x) = 9k e 2x. esson 5: Generating (Some) Continuous Random Variables Stochastic Simulation September 12, 2018 18 / 1

Example: Simulate X Γ(2, 3) Target Density: f (x) = 9xe 3x, x > 0 Will try to bound it by a function of the form g(x) = 9k e 2x. 9ke 2x 9xe 3x = 9e 3x (ke x x) esson 5: Generating (Some) Continuous Random Variables Stochastic Simulation September 12, 2018 18 / 1

Example: Simulate X Γ(2, 3) Target Density: f (x) = 9xe 3x, x > 0 Will try to bound it by a function of the form g(x) = 9k e 2x. 9ke 2x 9xe 3x = 9e 3x (ke x x) k = e 1 will work... 0.0 0.5 1.0 1.5 2.0 2.5 3.0 0 1 2 3 4 esson 5: Generating (Some) Continuous Random Variables Stochastic Simulation September 12, 2018 18 / 1 x

Example: Simulate X Γ(2, 3) In fact, it will be best (in terms of maximizing the acceptance rate) if we can, with our choice of g, closely mimic the target density f. 0.0 0.5 1.0 1.5 2.0 2.5 3.0 0 1 2 3 4 x esson 5: Generating (Some) Continuous Random Variables Stochastic Simulation September 12, 2018 19 / 1

Example: Simulate X Γ(2, 3) In fact, it will be best (in terms of maximizing the acceptance rate) if we can, with our choice of g, closely mimic the target density f. But, choosing something of the form g(x) = x c 1 e c 2x that will be 0 for x = 0 will result in us having to draw values (for possible acceptance) from a density that is probably at least as difficult to draw from as the original f! 0.0 0.5 1.0 1.5 2.0 2.5 3.0 0 1 2 3 4 x esson 5: Generating (Some) Continuous Random Variables Stochastic Simulation September 12, 2018 19 / 1

Example: Simulate X Γ(2, 3) In fact, it will be best (in terms of maximizing the acceptance rate) if we can, with our choice of g, closely mimic the target density f. We could use a piecewise uniform/exponential... 0.0 0.5 1.0 1.5 2.0 2.5 3.0 0 1 2 3 4 x esson 5: Generating (Some) Continuous Random Variables Stochastic Simulation September 12, 2018 20 / 1

Example: Simulate X Γ(2, 3) In fact, it will be best (in terms of maximizing the acceptance rate) if we can, with our choice of g, closely mimic the target density f. We could use a piecewise uniform/exponential...... but this is probably not worth the trouble. Let s see how fast the algorithm is with g(x) = 9e 1 e 2x. 0.0 0.5 1.0 1.5 2.0 2.5 3.0 0 1 2 3 4 x esson 5: Generating (Some) Continuous Random Variables Stochastic Simulation September 12, 2018 20 / 1

Results: (100,000 values) Density 0.0 0.2 0.4 0.6 0.8 1.0 mean accept time = 1.65627 s.d. = 1.038629 Density 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0 2 4 6 8 10 12 14 0 1 2 3 4 5 Lesson 5: Generating (Some) Continuous Random Variables Stochastic Simulation September 12, 2018 21 / 1

Odds and Ends... Incidentally, how would one draw from this (unnormalized) density: 0.0 0.2 0.4 0.6 0.8 1.0 1.2 f (x) { 9e 2, 0 < x < 0.5 9e 1 e 2x, x 0.5 0 1 2 3 4 Lesson 5: Generating (Some) Continuous Random Variables Stochastic Simulation September 12, 2018 22 / 1

Odds and Ends... Incidentally, how would one draw from this (unnormalized) density: 0.0 0.2 0.4 0.6 0.8 1.0 1.2 could normalize then compute and and invert the piecewise continuous cdf 0 1 2 3 4 Lesson 5: Generating (Some) Continuous Randomx Variables Stochastic Simulation September 12, 2018 23 / 1

Odds and Ends... Incidentally, how would one draw from this (unnormalized) density: 0.0 0.2 0.4 0.6 0.8 1.0 1.2 could normalize then compute and and invert the piecewise continuous cdf could normalize with c, then w.p. 9e 1 /c draw a unif (0, 1) w.p. 1 9e 1 /c draw an exp(rate = 2) and shift it by adding 0.5 0 1 2 3 4 Lesson 5: Generating (Some) Continuous Randomx Variables Stochastic Simulation September 12, 2018 23 / 1

Odds and Ends... Results: (second method candidate draws) Density 0.0 0.2 0.4 0.6 0.8 1.0 0 1 2 3 4 5 6 Lesson 5: Generating (Some) Continuous Random Variables Stochastic Simulation September 12, 2018 24 / 1