Overview of Monte Carlo Simulation, Probability Review and Introduction to Matlab



Similar documents
5. Continuous Random Variables

Generating Random Variables and Stochastic Processes

Generating Random Variables and Stochastic Processes

Math 461 Fall 2006 Test 2 Solutions

The Monte Carlo Framework, Examples from Finance and Generating Correlated Random Variables

Variance Reduction Methods I

e.g. arrival of a customer to a service station or breakdown of a component in some system.

Lecture 8. Confidence intervals and the central limit theorem

1 Sufficient statistics

Lecture 7: Continuous Random Variables

Department of Mathematics, Indian Institute of Technology, Kharagpur Assignment 2-3, Probability and Statistics, March Due:-March 25, 2015.

Joint Exam 1/P Sample Exam 1

The Exponential Distribution

Practice problems for Homework 11 - Point Estimation

For a partition B 1,..., B n, where B i B j = for i. A = (A B 1 ) (A B 2 ),..., (A B n ) and thus. P (A) = P (A B i ) = P (A B i )P (B i )

Notes on Continuous Random Variables

Lecture 6: Discrete & Continuous Probability and Random Variables

Generating Random Numbers Variance Reduction Quasi-Monte Carlo. Simulation Methods. Leonid Kogan. MIT, Sloan , Fall 2010

Section 5.1 Continuous Random Variables: Introduction

Statistics 100A Homework 7 Solutions

Binomial lattice model for stock prices

Simulating Stochastic Differential Equations

IEOR 6711: Stochastic Models I Fall 2012, Professor Whitt, Tuesday, September 11 Normal Approximations and the Central Limit Theorem

Probability and Statistics Prof. Dr. Somesh Kumar Department of Mathematics Indian Institute of Technology, Kharagpur

Principle of Data Reduction

Aggregate Loss Models

CHAPTER 6: Continuous Uniform Distribution: 6.1. Definition: The density function of the continuous random variable X on the interval [A, B] is.

Math 431 An Introduction to Probability. Final Exam Solutions

6.041/6.431 Spring 2008 Quiz 2 Wednesday, April 16, 7:30-9:30 PM. SOLUTIONS

LogNormal stock-price models in Exams MFE/3 and C/4

Lecture Notes 1. Brief Review of Basic Probability

Maximum Likelihood Estimation

Definition: Suppose that two random variables, either continuous or discrete, X and Y have joint density

Exponential Distribution

Chapter 2: Binomial Methods and the Black-Scholes Formula

Discrete Mathematics and Probability Theory Fall 2009 Satish Rao, David Tse Note 18. A Brief Introduction to Continuous Probability

2. Discrete random variables

Summary of Formulas and Concepts. Descriptive Statistics (Ch. 1-4)

Monte Carlo Methods in Finance

Lecture 3: Continuous distributions, expected value & mean, variance, the normal distribution

A Uniform Asymptotic Estimate for Discounted Aggregate Claims with Subexponential Tails

Normal distribution. ) 2 /2σ. 2π σ

3. Monte Carlo Simulations. Math6911 S08, HM Zhu

Probability Generating Functions

MASSACHUSETTS INSTITUTE OF TECHNOLOGY 6.436J/15.085J Fall 2008 Lecture 5 9/17/2008 RANDOM VARIABLES

Probability density function : An arbitrary continuous random variable X is similarly described by its probability density function f x = f X

Random variables P(X = 3) = P(X = 3) = 1 8, P(X = 1) = P(X = 1) = 3 8.

Introduction to Probability

ECE302 Spring 2006 HW5 Solutions February 21,

MULTIVARIATE PROBABILITY DISTRIBUTIONS

Chapter 9 Monté Carlo Simulation

Important Probability Distributions OPRE 6301

Chapter 4 Lecture Notes

What is Statistics? Lecture 1. Introduction and probability review. Idea of parametric inference

FEGYVERNEKI SÁNDOR, PROBABILITY THEORY AND MATHEmATICAL

SF2940: Probability theory Lecture 8: Multivariate Normal Distribution

UNIT I: RANDOM VARIABLES PART- A -TWO MARKS

Options 1 OPTIONS. Introduction

MAS108 Probability I

Math 151. Rumbos Spring Solutions to Assignment #22

1.1 Introduction, and Review of Probability Theory Random Variable, Range, Types of Random Variables CDF, PDF, Quantiles...

MATH 10: Elementary Statistics and Probability Chapter 5: Continuous Random Variables

2WB05 Simulation Lecture 8: Generating random variables

Chapter 3: DISCRETE RANDOM VARIABLES AND PROBABILITY DISTRIBUTIONS. Part 3: Discrete Uniform Distribution Binomial Distribution

STAT 315: HOW TO CHOOSE A DISTRIBUTION FOR A RANDOM VARIABLE

Lecture 5 : The Poisson Distribution

Martingale Pricing Applied to Options, Forwards and Futures

SF2940: Probability theory Lecture 8: Multivariate Normal Distribution

6 PROBABILITY GENERATING FUNCTIONS

M/M/1 and M/M/m Queueing Systems

The sample space for a pair of die rolls is the set. The sample space for a random number between 0 and 1 is the interval [0, 1].

Section 6.1 Joint Distribution Functions

STAT 830 Convergence in Distribution

PSTAT 120B Probability and Statistics

Basics of Statistical Machine Learning

MATH4427 Notebook 2 Spring MATH4427 Notebook Definitions and Examples Performance Measures for Estimators...

MASSACHUSETTS INSTITUTE OF TECHNOLOGY 6.436J/15.085J Fall 2008 Lecture 14 10/27/2008 MOMENT GENERATING FUNCTIONS

A LOGNORMAL MODEL FOR INSURANCE CLAIMS DATA

Math 425 (Fall 08) Solutions Midterm 2 November 6, 2008

1 Prior Probability and Posterior Probability

Arbitrage-Free Pricing Models

Statistics 100A Homework 8 Solutions

Chapter 3 RANDOM VARIATE GENERATION

The Black-Scholes-Merton Approach to Pricing Options

Master s Theory Exam Spring 2006

Probability Calculator

INSURANCE RISK THEORY (Problems)

ST 371 (IV): Discrete Random Variables

Brownian Motion and Stochastic Flow Systems. J.M Harrison

Numerical Methods for Option Pricing

Monte Carlo Simulation

Sums of Independent Random Variables

The Black-Scholes pricing formulas

Exam MFE Spring 2007 FINAL ANSWER KEY 1 B 2 A 3 C 4 E 5 D 6 C 7 E 8 C 9 A 10 B 11 D 12 A 13 E 14 E 15 C 16 D 17 B 18 A 19 D

An Introduction to Basic Statistics and Probability

Review of Basic Options Concepts and Terminology

Lecture 8: More Continuous Random Variables

Some special discrete probability distributions

Hedging Illiquid FX Options: An Empirical Analysis of Alternative Hedging Strategies

Transcription:

Monte Carlo Simulation: IEOR E4703 Fall 2004 c 2004 by Martin Haugh Overview of Monte Carlo Simulation, Probability Review and Introduction to Matlab 1 Overview of Monte Carlo Simulation 1.1 Why use simulation? To understand complex stochastic systems To control complex stochastic systems Such systems are often too complex to be understood and / or controlled using analytic or numerical methods Analytical Methods can examine many decision points at once but limited to simple models Numerical Methods can handle more complex models but still limited often have to repeat computation for each decision point Simulation can handle very complex and realistic systems but has to be repeated for each decision point Examples Telecommunications networks Financial markets Weather forecasting Revenue Management Insurance Engineering Statistics Before using simulation, we first need to build a mathematical model of the system

Overview of Monte Carlo Simulation, Probability Review and Introduction to Matlab 2 1.2 Modelling the System A good model should facilitate a good understanding of the system, either analytically, numerically, or through simulation capture the salient details of the system, omitting factors that are not relevant The steps in modelling identify the system, including the features and state variables that need to be included and those that should be excluded make necessary probabilistic assumptions about state variables and features test these assumptions identify the inputs and initial values of the state variables identify the performance measure that we wish to obtain from the system identify the mathematical relationship between the terminal state variables and the performance measure Solve the model either analytically, numerically or using simulation Example 1 (An Inventory Problem) A retailer sells a perishable commodity and each day he places an order for Q units. Each unit that is sold gives a profit of 60 cents and units not sold at the end of the day are discarded at a loss of 40 cents per unit. The demand, D, on any given day is uniformly distributed on [80, 140]. How many units should the retailer order to maximize expected profit? Solution 1: Use Simulation Let P denote profit. Then Set Q = 80 Generate n replications of D P = { 0.6Q if D Q 0.6D 0.4(Q D) if Q > D For each replication, compute the profit or loss, P i Estimate E[P ] with P i /n Repeat for different values of Q Select the value that gives the biggest estimated profit Solution 2: Solve Analytically! Can write expected profit as E[P ] = 140 Q 0.6Q 60 dx + Q 80 (0.6x 0.4(Q x)) 60 dx Use calculus to find the optimal Q = 116 Analytic solution gives the exact answer and requires far less work than simulation! But this problem is simple and for more complex problems, simulation is often the only option.

Overview of Monte Carlo Simulation, Probability Review and Introduction to Matlab 3 1.3 The Issues in Simulation In this course we will generally assume that the model has been developed and that we have decided to use simulation to analyze the model. A number of questions then arise: What distribution do the random variables have? How do we generate these random variables for the simulation? How do we analyze the output of the simulation? How many simulation runs do we need? How do we improve the efficiency of the simulation? We will answer all of these questions in this course. Consider now the following example where we wish to price Asian options. Example 2 (Pricing Asian Options) Consider a stock whose price at time t is denoted by S t. For a given positive integer, m, the arithmetic mean, A, and the geometric mean, G, are given by A := m j=1 S jt m m Now consider an asset that pays G := m m j=1 S jt m [A K] + := max(a K, 0) at time T. This is a European call option on the arithmetic mean. K is the strike price and is fixed in advance at t = 0. T is the expiration date. Similarly, a call option on the geometric mean has payoff at time T given by [G K] + := max(g K, 0). Finance theory implies that the fair price, C A, of the arithmetic option is given by C A := E Q [e rt (A K) + ] (1) where the expectation in (1) is taken with respect to the risk-neutral probability distribution, Q, and r is the risk-free interest rate. Similarly, the price, C G, of the geometric option is given by C G := E Q [e rt (G K) + ]. We can often compute C G in closed form but this is generally not true of C A. So in order to find C A we could use simulation. How do we do this? Solution 1. Generate random values of S jt for j = 1,..., m m [ ] + 1 m 2. Compute a 1 := m j=1 S jt K m 3. Repeat n times

Overview of Monte Carlo Simulation, Probability Review and Introduction to Matlab 4 4. Estimate given by Questions Ĉ A = e rt (a 1 +... + a n ) n How do we generate sample values of S jt? m How large should n be? How do we assess the quality of ĈA? E[ĈA] =? How do we make the simulation more efficient? Var(ĈA) =? Note that we have assumed that we know the model in this example: The state variables have been identified The goal is to price the option The mathematical relationship between the inputs and outputs have been identified 1.4 Variance Reduction Techniques A particularly important topic is simulation efficiency. In particular we will wish to develop techniques that will improve the efficiency of our simulations and this leads us to variance reduction techniques: 1. Common random numbers 2. Antithetic variates 3. Control variates 4. Conditional expectations 5. Stratified sampling 6. Importance sampling We now give a very brief introduction to and motivation for variance reduction methods. Antithetic Variates S t often assumed to be lognormally distributed i.e. log(s t ) N(µ, σ 2 ) Do we need to generate 2 independent N(µ, σ 2 ) variables in order to generate 2 sample values of S t? Maybe not: if X N(0, 1) then X N(0, 1) How can this help? based upon Var(W + Y ) = Var(W ) + Var(Y ) + 2Cov(W, Y )

Overview of Monte Carlo Simulation, Probability Review and Introduction to Matlab 5 Control Variates Based on the idea of using what you know What do we know in the Asian option example? the price of the call option on the geometric mean! How can this be used? Maybe Ĉ A = ĈA + b(c G ĈG) Why might this work? How do we choose b? Conditional Monte Carlo and Stratified Monte Carlo A very useful formula Var(X) = Var(E[X Y ]) + E[Var(X Y )] Useful for certain variance reduction techniques conditional Monte Carlo simulation stratified Monte Carlo simulation Why? We will see later in the course. Importance Sampling Sometimes it is good to sample from a different distribution! Let X be a random variable with density f(x) Suppose we want to estimate θ = E[h(X)] Let g(x) be another density function Then θ = E[h(X)] = h(x)f(x) dx = h(x)f(x)g(x) g(x) = E g [ h(x)f(x) g(x) ] dx Often very useful for simulating rare events

Overview of Monte Carlo Simulation, Probability Review and Introduction to Matlab 6 2 Probability Review We now review some probability theory. Monte Carlo simulation relies extensively on probability theory so it is very important that you understand this material well. 2.1 Discrete Probability Distributions Example 3 (Binomial Distribution) Say X has a Binomial distribution, or X B(n, p), if ( n P(X = r) = r ) p r (1 p) n r For example, X could be the number of heads in n independent coin tosses, where p = P(head) E[X] = np Var[X] = np(1 p) Assuming we know how to generate random coin tosses, how would we generate a B(n, p) random variable? Example 4 (Geometric Distribution) Say X has a Geometric distribution if P(X = r) = (1 p) r 1 p For example, X could be the number of independent coin tosses required until 1 st head where p = P(head) E[X] = 1/p Var[X] = (1 p)/p 2 Assuming we know how to generate random coin tosses, how would we generate a geometric random variable? Example 5 (Poisson Distribution) Say X has a Poisson(λ) distribution if P(X = r) = λr e λ r! E[X] = λ Var[X] = λ How do we generate a Poisson(λ) random variable? could we use coin tosses?

Overview of Monte Carlo Simulation, Probability Review and Introduction to Matlab 7 2.2 Continuous Probability Distributions We now review some continuous distributions, beginning with the most important distribution in simulation, the uniform distribution. But first, we review some notation and important facts regarding continuous random variables. This also applies to discrete random variables but with integrals replaced by summations. Definition 1 The cumulative distribution function (CDF), F (x), of a rv, X, is defined by F(x) := P(X x). Definition 2 A continuous rv, X, has probability density function (PDF), f(x), if f(x) 0 and x P(X A) = f(y) dy. The CDF and PDF are related by F(x) = x A f(y) dy so that if you differentiate the CDF you obtain the pdf. It is often convenient to observe that P (X (x ɛ 2, x + ɛ ) 2 ) ɛf(x) Definition 3 For a continuous random vector (X, Y ) the joint pdf, f(x, y), is non-negative and satisfies P ((X, Y ) A) = f(x, y) dx dy. A Definition 4 The marginal PDF of Y is given by f Y (y) = f(x, y) dx Definition 5 The conditional PDF of X given Y is given by f x y (x y) = f(x, y) f Y (y) Recall that if X and Y are independent then f(x, y) = f X (x)f Y (y). Example 6 (Uniform Distribution) Say X has the uniform distribution on (a, b) if 1/(b a) x (a, b) f(x) = 0 otherwise where f(x) is the pdf of X Write X U(a, b) E[X] = (a + b)/2 Var[X] = (b a) 2 /12

Overview of Monte Carlo Simulation, Probability Review and Introduction to Matlab 8 Suppose for now we can simulate (i.e. generate) independent and identically (IID) U(0, 1) random variables (rv s). How do we generate a random coin toss with P(Head) = p? Example 7 (Normal Distribution) Say X has a Normal distribution, or X N(µ, σ 2 ), if ( ) 1 f(x) = exp (x µ)2 2πσ 2 2σ 2 E[X] = µ Var[X] = σ 2 How do we generate a normal random variable? Example 8 (Exponential Distribution) Say X has an Exponential(λ) distribution if f(x) = λe λx, x > 0 E[X] = 1/λ Var[X] = 1/λ 2 How do we generate an exponential random variable? Example 9 (Lognormal Distribution) Say X has a Lognormal distribution, or X LN(µ, σ 2 ), if log(x) N(µ, σ 2 ) E[X] = exp(µ + σ 2 /2) not µ! Var[X] = exp(2µ + σ 2 ) (exp(σ 2 ) 1) not σ 2! How do we generate a lognormal random variable? Very important in financial applications Example 10 (Gamma Distribution) Say X has a Gamma(n, λ) distribution if E[X] = n/λ Var[X] = n/λ 2 How do we generate a gamma random variable? f(x) = λe λx (λx) n 1, x > 0 (n 1)!

Overview of Monte Carlo Simulation, Probability Review and Introduction to Matlab 9 2.3 Covariance The covariance of X and Y is defined by Cov(X, Y ) := E [(X µ x )(Y µ y )] Then Var(aX + by ) = a 2 Var(X) + b 2 var(y ) + 2abCov(X, Y ) If X and Y independent, then Cov(X, Y ) = 0 If X 1,..., X n are IID, then ( ) X1 +... + X n Var n = Var(X 1) n Note Cov(X, Y ) = 0 X, Y independent unless, for example, the joint distribution of (X, Y ) is bivariate normal 2.4 Conditional Expectations and Conditional Variances For random variables, X and Y, we have the conditional expectation identity E[X] = E [E[X Y ]] and the conditional variance identity Var(X) = Var(E[X Y ]) + E[Var(X Y )]. These identities, while useful in general, are of particular useful in simulation. Example 11 (A Random Sum of Random Variables) Let W = X 1 + X 2 +... + X n where the X i s are IID and n is also a rv, independent of the X i s. 1. What is E[W ]? Use E[X] = E [E[X Y ]] What is X and what is Y? 2. What is Var(W )? Use Var(X) = Var(E[X Y ]) + E[Var(X Y )] Again, what is X and what is Y? Example 12 (Chickens and Eggs) A hen lays N eggs where N Poisson(λ). Each egg hatches with probability p, independently of the other eggs and N. Let K be the number of chickens. 1. What is E[K N]? 2. What is E[K]? 3. What is E[N K]?

Overview of Monte Carlo Simulation, Probability Review and Introduction to Matlab 10 2.5 Laws of Large Numbers Suppose X 1,..., X n IID with mean µ. Then for any ɛ > 0 ( ) X 1 +... + X n P µ n > ɛ 0 as n this is the Weak Law of Large Numbers see Ross for proof under assumption of finite variances The Strong Law of Large Numbers says X 1 +... + X n lim = µ n n with probability 1. This law will justify our simulation methodology. 2.6 Central Limit Theorem Suppose X 1,..., X n IID with mean µ and finite variances σ 2 Define Then S n := X 1 +... + X n n S n µ σ/ n N(0, 1) Very useful for analyzing simulation output 2.7 The Poisson Process Consider a stochastic process where events (or arrivals) occur at random points in time Let N(t) denote the number of events (or arrivals) that have occurred by time t Assume N(t) has the following properties 1. N(0) = 0 2. number of arrivals in non-overlapping time intervals are independent 3. distribution of number of arrivals in a time interval only depends on length of interval 4. for h > 0 very small, P (N(h) = 1) λh P (N(h) 2) 0 P (N(h) = 0) 1 λh Then say N(t) is a Poisson process with intensity λ Very useful for modelling arrival processes. Good for modelling emission of particles from a radioactive source market crashes or other big events arrival of customers to a queue

Overview of Monte Carlo Simulation, Probability Review and Introduction to Matlab 11 It can be shown that i.e. N(t) is Poisson(λt) P (N(t) = r) = (λt)r e λt r! Let X i be interval between the (i 1) th and i th arrivals also called the i th interarrival time Assumptions imply X i s are IID What is the distribution of X i? P(X 1 > t) = P (N(t) = 0) =...? Later in the course we will review Brownian motion and any other topics from probability theory that we might need. Example 13 (A Teaser) The king comes from a family of 2 children. What is the probability that the other child is his brother? Notation: BG means 1 st child a boy, second child a girl BB means both children are boys etc. What is it we want to compute? 3 Introduction to Matlab Matlab should be available in the computing labs at Columbia. If you wish to purchase it for yourself, then you should purchase the student edition. Make sure you also obtain the Statistics toolbox. The Optimization and Financial toolboxes are often useful as well but we will probably not need them in this course. The easiest way to learn Matlab is by working through examples and you should download one of the many Matlab tutorials that can be found online. They are relatively short and working through them is probably the best way to start. Some online tutorials can be found at http://www.eece.maine.edu/mm/matweb.html A particularly good one by Kermit Sigmon can be found at http://ise.stanford.edu/matlab/matlab-primer.pdf We will use Matlab extensively in this course in lectures and in assignments But you may use other software if you wish