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

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

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

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

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

Monte Carlo Methods for Uncertainty Quantification

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

CPSC 540: Machine Learning

Monte Carlo Simulations in the Teaching Process

CPSC 540: Machine Learning

Chapter 2 Uncertainty Analysis and Sampling Techniques

Strategies for Improving the Efficiency of Monte-Carlo Methods

Lecture outline. Monte Carlo Methods for Uncertainty Quantification. Importance Sampling. Importance Sampling

10. Monte Carlo Methods

Introduction to Sequential Monte Carlo Methods

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

IEOR E4703: Monte-Carlo Simulation

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

Statistical Computing (36-350)

ELEMENTS OF MONTE CARLO SIMULATION

Write legibly. Unreadable answers are worthless.

Back to estimators...

Version A. Problem 1. Let X be the continuous random variable defined by the following pdf: 1 x/2 when 0 x 2, f(x) = 0 otherwise.

15 : Approximate Inference: Monte Carlo Methods

F19: Introduction to Monte Carlo simulations. Ebrahim Shayesteh

Computer Exercise 2 Simulation

Limit Theorems for the Empirical Distribution Function of Scaled Increments of Itô Semimartingales at high frequencies

Ch4. Variance Reduction Techniques

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

Bivariate Birnbaum-Saunders Distribution

ROM SIMULATION Exact Moment Simulation using Random Orthogonal Matrices

Slides for Risk Management

Homework Assignments

Chapter 6. Importance sampling. 6.1 The basics

Equity correlations implied by index options: estimation and model uncertainty analysis

Using Monte Carlo Integration and Control Variates to Estimate π

Math489/889 Stochastic Processes and Advanced Mathematical Finance Homework 5

Homework Problems Stat 479

Hand and Spreadsheet Simulations

ECO220Y Continuous Probability Distributions: Normal Readings: Chapter 9, section 9.10

MATH3075/3975 FINANCIAL MATHEMATICS TUTORIAL PROBLEMS

Two hours. To be supplied by the Examinations Office: Mathematical Formula Tables and Statistical Tables THE UNIVERSITY OF MANCHESTER

Math Option pricing using Quasi Monte Carlo simulation

Financial Risk Forecasting Chapter 7 Simulation methods for VaR for options and bonds

The Use of Importance Sampling to Speed Up Stochastic Volatility Simulations

**BEGINNING OF EXAMINATION** A random sample of five observations from a population is:

IEOR E4703: Monte-Carlo Simulation

Monte Carlo Methods. Matt Davison May University of Verona Italy

MAS3904/MAS8904 Stochastic Financial Modelling

6. Continous Distributions

Chapter 5. Continuous Random Variables and Probability Distributions. 5.1 Continuous Random Variables

GENERATION OF STANDARD NORMAL RANDOM NUMBERS. Naveen Kumar Boiroju and M. Krishna Reddy

Probability. An intro for calculus students P= Figure 1: A normal integral

Numerical Simulation of Stochastic Differential Equations: Lecture 2, Part 2

Exam in TFY4275/FY8907 CLASSICAL TRANSPORT THEORY Feb 14, 2014

Course information FN3142 Quantitative finance

Stochastic Simulation

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

Monte Carlo Methods for Uncertainty Quantification

IEOR E4703: Monte-Carlo Simulation

History of Monte Carlo Method

STOR Lecture 15. Jointly distributed Random Variables - III

Sample Size for Assessing Agreement between Two Methods of Measurement by Bland Altman Method

Lecture 8. The Binomial Distribution. Binomial Distribution. Binomial Distribution. Probability Distributions: Normal and Binomial

2.1 Mathematical Basis: Risk-Neutral Pricing

Class 16. Daniel B. Rowe, Ph.D. Department of Mathematics, Statistics, and Computer Science. Marquette University MATH 1700

Chapter 7 Sampling Distributions and Point Estimation of Parameters

Lecture 6: Chapter 6

Homework: Due Wed, Feb 20 th. Chapter 8, # 60a + 62a (count together as 1), 74, 82

Strategies for High Frequency FX Trading

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

Homework: Due Wed, Nov 3 rd Chapter 8, # 48a, 55c and 56 (count as 1), 67a

Math 416/516: Stochastic Simulation

Chapter 7: Point Estimation and Sampling Distributions

Chapter 7 presents the beginning of inferential statistics. The two major activities of inferential statistics are

Central Limit Theorem, Joint Distributions Spring 2018

IEOR E4703: Monte-Carlo Simulation

Yao s Minimax Principle

. (i) What is the probability that X is at most 8.75? =.875

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

Exact Sampling of Jump-Diffusion Processes

Generating Random Numbers

Hints on Some of the Exercises

MATH 3200 Exam 3 Dr. Syring

Point Estimation. Stat 4570/5570 Material from Devore s book (Ed 8), and Cengage

SAQ KONTROLL AB Box 49306, STOCKHOLM, Sweden Tel: ; Fax:

2 Control variates. λe λti λe e λt i where R(t) = t Y 1 Y N(t) is the time from the last event to t. L t = e λr(t) e e λt(t) Exercises

Characterization of the Optimum

Practice Exercises for Midterm Exam ST Statistical Theory - II The ACTUAL exam will consists of less number of problems.

Sublinear Time Algorithms Oct 19, Lecture 1

Math Computational Finance Double barrier option pricing using Quasi Monte Carlo and Brownian Bridge methods

Monte Carlo Methods for Uncertainty Quantification

Loss Simulation Model Testing and Enhancement

Central Limit Theorem (CLT) RLS

IEOR E4602: Quantitative Risk Management

Data Analysis and Statistical Methods Statistics 651

Exam M Fall 2005 PRELIMINARY ANSWER KEY

What was in the last lecture?

Final Exam Key, JDEP 384H, Spring 2006

ECE 295: Lecture 03 Estimation and Confidence Interval

FREDRIK BAJERS VEJ 7 G 9220 AALBORG ØST Tlf.: URL: Fax: Monte Carlo methods

Transcription:

Monte Carlo and Empirical Methods for Stochastic Inference (MASM11/FMS091) Magnus Wiktorsson Centre for Mathematical Sciences Lund University, Sweden Lecture 3 Importance sampling January 27, 2015 M. Wiktorsson Monte Carlo and Empirical Methods for Stochastic Inference, L3 (1)

Last time: MC output analysis We used the CLT N (τn τ) d. N (0, σ 2 (φ)) to target τ by the approximate two-sided condence interval ( ) σ(φ) σ(φ) τ N λ α/2, τ N + λ α/2. N N In addition, we discussed how to estimate ϕ(τ) for some function ϕ : R R having at hand an estimator τ N of τ. If ϕ C 1 one may prove the CLT d. N (ϕ(τn ) ϕ(τ)) N (0, ϕ (τ) 2 σ 2 (φ)). Consequently, the natural estimator ϕ(τ N ) works ne, at least asymptotically (but suers in general from bias for nite N's). M. Wiktorsson Monte Carlo and Empirical Methods for Stochastic Inference, L3 (2)

Example: Buon's needle Consider a a wooden oor with parallel boards of width d on which we randomly drop a needle of length l, with l d. Let { X = distance from the lower needlepoint to the upper board edge line, θ = angle between the needle and the board edge normal. Then τ = P (needle intersects board edge) = P(X l cos θ) =... = 2l πd. or, equivalently, π = 2l τd. M. Wiktorsson Monte Carlo and Empirical Methods for Stochastic Inference, L3 (3)

Example: Buon's needle (cont.) Since τ = P(needle intersects board edge) = E(1 {X l cos θ} ) can be easily estimated by means of MC, an approximation of π = ϕ(τ) = 2l/(τd) can be obtained via the delta method: 5 4.5 4 π Estimate 3.5 3 2.5 2 1.5 0 100 200 300 400 500 600 700 800 900 1000 Number of samples N M. Wiktorsson Monte Carlo and Empirical Methods for Stochastic Inference, L3 (4)

Last time: pseudo-random number generation We discussed (briey) how to generate pseudo-random, uniformly distributed numbers (U n ) using the linear congruential generator U n = (a U n 1 + c) mod m. Having at hand such U(0, 1)-distributed numbers U, we also looked at how to generate random numbers X from an arbitrary distribution F by means of the inversion method, i.e., by letting X = F (U) = inf{x R : F (x) U}. M. Wiktorsson Monte Carlo and Empirical Methods for Stochastic Inference, L3 (5)

Conditional methods Importance sampling (IS) Let f be a multivariate density on R d. By decomposing f into conditional densities according to f(x 1,..., x d ) = f(x 1 ) d f(x l x 1,..., x l 1 ), the problem of sampling from a multivariate density can be reduced to that of sampling from several univariate densities: draw X 1 f(x 1 ) for l = 2 d do draw X l f(x l X 1,..., X l 1 ) end for return X = (X 1,..., X d ) Trivially, the resulting draw X has the correct distribution f. This method presumes that the conditional densities are easily obtained, which is not always the case. l=2 M. Wiktorsson Monte Carlo and Empirical Methods for Stochastic Inference, L3 (6)

Last time: pseudo-random number generation In many cases we do not know the inverse of F or not even the normalizing constant of the density f. However, if g is another density such that f(x) Kg(x) for all x R d and some constant K <, we may use rejection sampling: repeat draw X g draw U U(0, 1) until U f(x ) Kg(X ) X X return X M. Wiktorsson Monte Carlo and Empirical Methods for Stochastic Inference, L3 (7)

Last time: pseudo-random number generation Theorem (Rejection sampling) The output X of the rejection sampling algorithm is a random variable with density function f. Moreover, the expected number of trials needed before acceptance is K. M. Wiktorsson Monte Carlo and Empirical Methods for Stochastic Inference, L3 (8)

Example Importance sampling (IS) We wish to simulate f(x) = exp(cos 2 (x))/c, x ( π/2, π/2), where c = π/2 π/2 exp(cos2 (z)) dz = πe 1/2 I o (1/2) is the normalizing constant. However, since for all x ( π/2, π/2), f(x) = exp(cos2 (x)) c e c = eπ 1, }{{} c }{{} π K g where g is the density of U( π/2, π/2), we may use rejection sampling where a candidate X U( π/2, π/2) is accepted if U f(x ) Kg(X ) = exp(cos2 (X ))/c = exp(cos 2 (X ) 1). e/c M. Wiktorsson Monte Carlo and Empirical Methods for Stochastic Inference, L3 (9)

prob = @(x) exp((cos(x))^2 1); trial = 1; accepted = false; while ~accepted, Xcand = pi/2 + pi*rand; if rand < prob(xcand), accepted = true; X = Xcand; else trial = trial + 1; end end 0.7 0.6 0.5 0.4 0.3 Histogram of accept reject draws f(x) = exp(cos 2 (x))/c 0.2 0.1 0 2 1.5 1 0.5 0 0.5 1 1.5 2 Figure : Plot of a histogram of 20,000 accept-reject draws together with the true density. The average number of trials was 1.5555( K = e 1/2 /I 0 (1/2) 1.5503). M. Wiktorsson Monte Carlo and Empirical Methods for Stochastic Inference, L3 (10)

Plan of today's lecture Importance sampling (IS) 1 Importance sampling (IS) 2 3 M. Wiktorsson Monte Carlo and Empirical Methods for Stochastic Inference, L3 (11)

We are here Importance sampling (IS) 1 Importance sampling (IS) 2 3 M. Wiktorsson Monte Carlo and Empirical Methods for Stochastic Inference, L3 (12)

Advantages of the MC method The MC method is more ecient than deterministic methods in high dimensions, does in general not require knowledge of the normalizing constant of a density for computing expectations, and handles eciently strange integrands that may cause problems for deterministic methods. 1 h(x) = sin 2 (1/cos(log(1 + 2πx))) 0.9 0.8 0.7 0.6 y = h(x) 0.5 0.4 0.3 0.2 0.1 0 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 x M. Wiktorsson Monte Carlo and Empirical Methods for Stochastic Inference, L3 (13)

Problems with MC integration OK, MC integration looks promising. We may however run into problems if it is hard to sample from f or if the integrand φ and the density f are dissimilar; in this case we will end of with a lot of draws where the integrand is small, and consequently only a few draws will contribute to the estimate. This gives a large variance. 0.7 0.6 φ(x) 0.5 0.4 f(x) 0.3 0.2 0.1 0 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 These problems can often be solved using importance sampling. M. Wiktorsson Monte Carlo and Empirical Methods for Stochastic Inference, L3 (14)

Importance sampling (IS, Ch. 6.4.1) The basis of importance sampling is to take an instrumental density g on X such that g(x) = 0 f(x) = 0 and rewrite the integral as τ = E f (φ(x)) = = where g(x)>0 X φ(x)f(x) dx = φ(x) f(x) g(x) g(x) dx = E g f(x)>0 ( φ(x) f(x) g(x) φ(x)f(x) dx ω : {x X : g(x) > 0} x f(x) g(x) is the so-called importance weight function. ) = E g (φ(x)ω(x)), M. Wiktorsson Monte Carlo and Empirical Methods for Stochastic Inference, L3 (15)

Importance sampling (cont.) We may now estimate τ = E g (φ(x)ω(x)) using standard MC: for i = 1 N do draw X i g end for set τ N N i=1 φ(x i )ω(x i )/N return τ N Here, trivially, V(τ N ) = 1 N V g(φ(x)ω(x)) and we should thus aim at choosing g so that the function x φ(x)ω(x) is close to constant in the support of g. This gives a minimal variance. M. Wiktorsson Monte Carlo and Empirical Methods for Stochastic Inference, L3 (16)

Example: A tricky normal expectation Let X have N (2, 1) distribution and try to compute ( ) τ = E 1 X 0 X exp( X 3 ) = 1 x 0 x exp( x 3 ) N (x; 2, 1) dx, }{{}}{{} =φ(x) =f(x) where N (x; µ, σ 2 ) denotes the density of the normal distribution. 0.7 0.6 φ(x) 0.5 0.4 f(x) 0.3 0.2 0.1 0 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 Here the support of f is signicantly larger than that of φ. M. Wiktorsson Monte Carlo and Empirical Methods for Stochastic Inference, L3 (17)

Example: A tricky normal expectation (cont.) Thus, standard MC will lead to a waste of computational power. Better is to use IS with g being a scale-location-transformed normal-distribution: 1 0.9 0.8 0.7 g(x) 0.6 0.5 0.4 φ(x) f(x) 0.3 0.2 0.1 φ(x)f(x) 0 0 0.5 1 1.5 2 2.5 3 Lecture 3.5 3 4Importance 4.5 sampling 5 January 27, 2 M. Wiktorsson Monte Carlo and Empirical Methods for Stochastic Inference, L3 (18)

Example: A tricky normal expectation (cont.) phi = @(x) (x >= 0).*sqrt(x).*exp( x.^3); mu = 0.8; sigma = 0.4; omega = @(x) normpdf(x,2,1)./normpdf(x,mu,sigma); X = sigma*randn(1,n)+mu; tau = mean(f(x).*omega(x)); 0.13 0.12 0.11 Importance Sampling 0.1 0.09 0.08 0.07 Standard MC 0.06 0.05 0.04 0.03 0 500 1000 1500 M. Wiktorsson Sample size N Monte Carlo and Empirical Methods for Stochastic Inference, L3 (19)

We are here Importance sampling (IS) 1 Importance sampling (IS) 2 3 M. Wiktorsson Monte Carlo and Empirical Methods for Stochastic Inference, L3 (20)

(Ch. 6.4.1) Often f(x) is known only up to a normalizing constant c > 0, i.e. f(x) = z(x)/c, where we can evaluate z(x) = cf(x) but not f(x). Then, as before, τ = E f (φ(x)) = = X cf(x) g(x)>0 φ(x) g(x) g(x)>0 where we are able to evaluate φ(x)f(x) dx = c f(x)>0 φ(x)f(x) dx c f(x)>0 f(x) dx g(x) dx cf(x) g(x) g(x) dx = g(x)>0 g(x)>0 ω : {x X : g(x) > 0} x z(x) g(x). φ(x)ω(x)g(x) dx ω(x)g(x) dx = E g(φ(x)ω(x)), E g (ω(x)) M. Wiktorsson Monte Carlo and Empirical Methods for Stochastic Inference, L3 (21)

(cont.) Thus, having generated a sample X 1,..., X N from g we may estimate the numerator E g (φ(x)ω(x)) as well as the dominator E g (ω(x)) using standard MC: τ = E g(φ(x)ω(x)) E g (ω(x)) 1 N N i=1 φ(x i )ω(x i ) N l=1 ω(x l ) = 1 N N ω(x i ) N l=1 ω(x l }{{ ) φ(x i ). } normalized weight i=1 Note that the denominator yields an estimate of the normalizing constant c: c = E g (ω(x)) 1 N N ω(x l ). l=1 M. Wiktorsson Monte Carlo and Empirical Methods for Stochastic Inference, L3 (22)

Example Importance sampling (IS) We reconsider the density f(x) = exp(cos 2 (x))/c, x ( π/2, π/2), treated last time and estimate its variance as well as the normalizing constant c > 0 using self-normalized IS. Let the instrumental distribution g be the uniform distribution U( π/2, π/2). M. Wiktorsson Monte Carlo and Empirical Methods for Stochastic Inference, L3 (23)

Example (cont.) Importance sampling (IS) z = @(x) exp(cos(x).^2); X = pi/2 + pi*rand(1,n); omega = @(x) pi*z(x); tau = cumsum(x.^2.*omega(x))./cumsum(omega(x)); c = cumsum(omega(x))./(1:n); subplot(2,1,1); plot(1:n,c); Estimated normalizing constant 6 subplot(2,1,2); 5.5 plot(1:n,tau); 5 4.5 4 0 100 200 300 400 500 600 700 800 Sample size N 1.4 Estimated variance 1.2 1 0.8 0.6 0.4 0 100 200 300 400 500 600 700 800 Sample size N M. Wiktorsson Monte Carlo and Empirical Methods for Stochastic Inference, L3 (24)

The weighted sample (X i, ω(x i )) can be viewed as a MC representation of the target distribution f. 0.5 f(x) = exp(cos 2 (x))/c, π/2 < x < π/2 0.07 MC representation 0.45 f(x) 0.06 0.4 0.05 0.35 g(x) 0.04 0.3 0.03 0.25 0.02 0.2 0.01 2 1.5 1 0.5 0 0.5 1 1.5 2 0 2 1.5 1 0.5 0 0.5 1 1.5 2 f(x) IS (X i, ω(x i )) M. Wiktorsson Monte Carlo and Empirical Methods for Stochastic Inference, L3 (25)

We are here Importance sampling (IS) 1 Importance sampling (IS) 2 3 M. Wiktorsson Monte Carlo and Empirical Methods for Stochastic Inference, L3 (26)

HA1: Simulation and Monte Carlo integration HA1 comprises one question on random number generation and two larger questions on IS (one- and two-dimensional problems) containing one subquestion (2(c)) on variance reduction (which we will discuss next time). M. Wiktorsson Monte Carlo and Empirical Methods for Stochastic Inference, L3 (27)

Submission: A written report in PDF format (No MS Word-les). The pair Errol Norqvist and Lillemor Dahlstedt name their report le proj1-dlne.pdf. A printed and stitched copy of the report is given to the lecturer at the very beginning of the lecture on Tuesday 10 Feb. An email containing the report le as well as all your m-les with a le proj1.m that runs your analysis. This email has to be sent to fms091@matstat.lu.se before Tuesday 10 Feb, 15:00:00 (that is, 15 minutes before the beginning of the lecture). Use your STIL-IDs in the subject line of the email. Set the subject line to: Project 1 by STILID1 and STILID2 Late submissions do not qualify for marks higher than 3. M. Wiktorsson Monte Carlo and Empirical Methods for Stochastic Inference, L3 (28)

Instructions on report writing Explain carefully all introduced notation: X =?. Describe/explain the model. The text should be readable without access to the Matlab code; write plain text instead of including Matlab code in the report. Include your solutions in the text; do not write calculations of? can be found in the matlab code, or similar. When referring to the lecture notes or the book, be specic (i.e. refer to Chapter/which lecture). Refer to your gures in the text. Explain colors etc. in the gure captions (a gure caption is almost never to long). Write clear motivations and reasonings when it concerns choice of instrumental distributions etc. M. Wiktorsson Monte Carlo and Empirical Methods for Stochastic Inference, L3 (29)