control variatessas.uwaterloo.ca/~dlmcleis/s906/slides200-250.pdf · 2004. 9. 29. · control...

51
CONTROL VARIATES Suppose there is another function g(u) that resembles f(u) but simpler for which I can compute the integral. Use it to improve the Monte Carlo integration of f. = + + = n i i i U g U f n du g(u du g(u du u g f(u du g(u du f(u 1 1 0 1 0 1 0 1 0 1 0 )) ( ) ( ( 1 ) is Estimator Carlo. Monte using , difference the term, second the estimate and ) first term for the e known valu the Use )] ( - ) [ ) )

Upload: others

Post on 21-May-2021

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CONTROL VARIATESsas.uwaterloo.ca/~dlmcleis/s906/slides200-250.pdf · 2004. 9. 29. · Control Variate • function g=GG(u) % control variate for callopt2. % this function integrates

CONTROL VARIATES• Suppose there is another function g(u) that

resembles f(u) but simpler for which I can compute the integral. Use it to improve the Monte Carlo integration of f.

∑∫

∫∫∫

=

−+

+=

n

iii UgUf

ndug(u

dug(u

duugf(udug(uduf(u

1

1

0

1

0

1

0

1

0

1

0

))()((1)

isEstimator Carlo. Monte using ,difference the term,second theestimate and

) first term for the eknown valu theUse

)](-)[))

Page 2: CONTROL VARIATESsas.uwaterloo.ca/~dlmcleis/s906/slides200-250.pdf · 2004. 9. 29. · Control Variate • function g=GG(u) % control variate for callopt2. % this function integrates

Control variates

small. is difference of variance)( toclose is )(When ))((var))()(( varif cruden better tha is This

))()((varn1

))()((1)

isEstimator

11

111

11

1

1

0

UfUgUfUgUf

UgUf

VARIANCE

UgUfn

dug(un

iii

<−

−+ ∑∫=

Page 3: CONTROL VARIATESsas.uwaterloo.ca/~dlmcleis/s906/slides200-250.pdf · 2004. 9. 29. · Control Variate • function g=GG(u) % control variate for callopt2. % this function integrates

Control Variate

• function g=GG(u)% control variate for callopt2.% this function integrates to 2*(.53)^3+.53^2/2u=max(0,u-.47);g=6*u.^2+u;

quadratic. isit since integrate easy to is This.47. if 0)(

47. if )47.(6)47.()( form theoffunction a triedI

2

≤=>−+−=

uuguuuug

Page 4: CONTROL VARIATESsas.uwaterloo.ca/~dlmcleis/s906/slides200-250.pdf · 2004. 9. 29. · Control Variate • function g=GG(u) % control variate for callopt2. % this function integrates

Function GG(u) and fn(u)

• Only need to estimate the area between the curves by Monte Carlo

Page 5: CONTROL VARIATESsas.uwaterloo.ca/~dlmcleis/s906/slides200-250.pdf · 2004. 9. 29. · Control Variate • function g=GG(u) % control variate for callopt2. % this function integrates

Performance of Control Variate• u= rand(1,500000);• F=fn(u);• G=GG(u);• est=2*(.53)^3+.53^2/2+(F-G);• mean(est)• var(est)/length(est)• (mean= 0.4616 var= 2.93e-008)• Efficiency compared with crude 8.7e-007

ratio=30 (equivalent to 15 million crude!)

Page 6: CONTROL VARIATESsas.uwaterloo.ca/~dlmcleis/s906/slides200-250.pdf · 2004. 9. 29. · Control Variate • function g=GG(u) % control variate for callopt2. % this function integrates

Control Variates II

. ] ))(()([1))((

. ] ))()(()([1 i.e. form, thisof terms

ofmean sample a usecan we] ))()(()([ since and parameter theestimate wish toWe

.))(var(

)cov by given parameter Slope

)))(( where

variable.random error"" zeromean a is , ))()(()(on regressionlinear a using eapproximatcan wee,alternativan As

itself. gy necessarilnot is g using f ion toapproximat best"" The

1

1

1

0

=

=

−+=

−−

−−=

=

==

+−+=

n

iii

n

iiii

UgUfn

UgE

UEgUgUfn

UEgUgUfE

Ug(f(U),g(U)

duf(uUfE

UEgUgUfg(U)f(U)

ββ

β

βθθ

β

θ

εεβθ

Page 7: CONTROL VARIATESsas.uwaterloo.ca/~dlmcleis/s906/slides200-250.pdf · 2004. 9. 29. · Control Variate • function g=GG(u) % control variate for callopt2. % this function integrates

).( and )(between t coefficienn correlatio

wherer-1

1by given is efficiency theso

) )(1var()1() ] ))(()([1))((var(

estimator control thisof variance that theshow easy to isIt

.)(1g(U) where)]()([

)]()([)]()([

.covariance and variancesampleby covariance and variancereplacing toequivalent slope, ofestimator

regression by theit replace weunknown,usually is sinceHowever 1.ifVariateControlearlier the toidentical is This

2

1

2

1

1

_____

1

___2

1

______

^

ii

n

ii

n

iii

n

iin

ii

n

iii

UgUfr

Ufn

rUgUfn

UgE

UgnUgUg

UgUgUfUf

=

−=−+

=−

−−=

=

∑∑

∑∑

==

=

=

=

ββ

β

ββ

Page 8: CONTROL VARIATESsas.uwaterloo.ca/~dlmcleis/s906/slides200-250.pdf · 2004. 9. 29. · Control Variate • function g=GG(u) % control variate for callopt2. % this function integrates

Example of Control Variate II

• x=10*rand(1,500000);• f=10*x./(2+x.^.25); g=x; C=cov([f' g']);• beta=C(1,2)/C(2,2); EG=5;• est=beta*EG+f-beta*g;• mean(est); var(est)/length(est)• (mean= 14.000011 var= 1.8e-007)• var(f)/500000= 2.8160e-004• Eff=622 (equivalent to 311 million crude)

.5)10())(( that Note

.)( variatecontrol asconsider .2

10

and U[0,10]is where))(()x(2

x Find

4/1

10

01/4

==

=+

=

=+∫

UEXgE

xxg)x(

xf(x)

XXfEdx

Page 9: CONTROL VARIATESsas.uwaterloo.ca/~dlmcleis/s906/slides200-250.pdf · 2004. 9. 29. · Control Variate • function g=GG(u) % control variate for callopt2. % this function integrates

Stratified Sample

• Consider choosing one point in interval [0,a] and another in the interval [a,1]

∫∫∫∫∫

=+=−+−+=

−+−+=−+−+=−

−+−+=

−+

1

0

1

0

1

0

1

0

2121

11

21

1

0

21

)())))1()1()

)1(()1()(()))1(()1()(()(?1, ts Why weight U[0,1].independen are , where

))1(()1()(Let

be? weights theshould What .)( estimate to

points twoat thesefunction theof average weighteda usingConsider [a,1].in is )1( and a][0,in is

duufduf(uduf(uduuaf(aaduf(aua

UaaEfaaUfaEUaafaaUafEEaaUU

UaafaaUaf

duuf

UaaaU

a

aST

ST

θ

θ

Page 10: CONTROL VARIATESsas.uwaterloo.ca/~dlmcleis/s906/slides200-250.pdf · 2004. 9. 29. · Control Variate • function g=GG(u) % control variate for callopt2. % this function integrates

Weights in a stratified sample

• The weights attached to a given stratum (interval, region) are proportional to the length of the interval (or volume of region).

• We may allow many observations in a given stratum and apply weight to the stratum mean.

Page 11: CONTROL VARIATESsas.uwaterloo.ca/~dlmcleis/s906/slides200-250.pdf · 2004. 9. 29. · Control Variate • function g=GG(u) % control variate for callopt2. % this function integrates

General stratified sample

• Choose

stratum. of or volume) (area, length, toalproportion weightmean, stratum theof AVERAGE WEIGHTEDUse

i. stratumover ddistributeuniformly is where)(1result theaverage and stratum

over ddistributeuniformly points, random at function theEvaluate,...2,1, stratum from

1∑=

=

=

in

jijij

ii

i

i

VVfn

AV

in

miin

Page 12: CONTROL VARIATESsas.uwaterloo.ca/~dlmcleis/s906/slides200-250.pdf · 2004. 9. 29. · Control Variate • function g=GG(u) % control variate for callopt2. % this function integrates

Variance of Stratified Sample

+

+

i i

ijii

iiii

nVf

xx

AVxx

))(var()(

:estimator Sample Stratified of Variance

)(:Estimator

21

1

Page 13: CONTROL VARIATESsas.uwaterloo.ca/~dlmcleis/s906/slides200-250.pdf · 2004. 9. 29. · Control Variate • function g=GG(u) % control variate for callopt2. % this function integrates

Performance of stratified sample

• Example. We chose a=.7 and sampled 100,000 on [0,0.7] and another 100,000 on [0.7,1].

• a=.7;• F=a*fn(a*rand(1,500000))+(1-a)*fn(a+(1-a)*rand(1,500000));• mean(F) % =0.4608)• var(F)/length(F) % =9.18e-008

• Compare with Crude with n=1000000. Variance= 4.3e-007 ; Efficiency around 5.

Page 14: CONTROL VARIATESsas.uwaterloo.ca/~dlmcleis/s906/slides200-250.pdf · 2004. 9. 29. · Control Variate • function g=GG(u) % control variate for callopt2. % this function integrates

Optimal sample sizes for stratified sample

sample.y preliminar a from estimated ))((var(

))((var()(

toalproportion size sample optimal

then),( interval theis i stratum if Sodeviation standard stratum the(b)

length) interval (e.g. stratum theof size the(a) toalproportion is stratumeach in size sample optimal The

1

11

1

iii

iiiii

i

ii

xxUxf

xxUxfxx

n

xx

−+

−+−

+

++

+

Page 15: CONTROL VARIATESsas.uwaterloo.ca/~dlmcleis/s906/slides200-250.pdf · 2004. 9. 29. · Control Variate • function g=GG(u) % control variate for callopt2. % this function integrates

The function “stratified”

• function [est,v,n]=stratified(x,nsample)• % input x=vector of strata (e.g. x=[0 .25 .5 .75 1] and nsample=sample

size • est=0; n=[]; m=length(x);• for i=1:m-1 %preliminary simulation of 10000 to optimize sample

size• v= var(fn(unifrnd(x(i),x(i+1),1,1000));• n=[n (x(i+1)-x(i))*sqrt(v)];• end• n=floor(nsample*n/sum(n)); % these are stratum sample sizes • v=0;• for i=1:m-1• F=fn(unifrnd(x(i),x(i+1),1,n(i)));• est=est+(x(i+1)-x(i))*mean(F);• v=v+var(F)*(x(i+1)-x(i))^2/n(i);• end

Page 16: CONTROL VARIATESsas.uwaterloo.ca/~dlmcleis/s906/slides200-250.pdf · 2004. 9. 29. · Control Variate • function g=GG(u) % control variate for callopt2. % this function integrates

Stratified Sample with more strata, optimal sample size

• Try 4 strata [0 .55] ,[.55 .8],[.8 .94],[.94,1] with optimal sample sizes – 32717 78703 46420 42158

• [est,v,n]=stratified([0 .55 .80 .94 1],500000)• estimator 0.4617 variance= 3.7e-008• Efficiency now around 24 times that of

Crude. Try also:• [est,v,n]=stratified([.47 .62 .75 .87 .96 1],500000)(var=1.4e-8)

Page 17: CONTROL VARIATESsas.uwaterloo.ca/~dlmcleis/s906/slides200-250.pdf · 2004. 9. 29. · Control Variate • function g=GG(u) % control variate for callopt2. % this function integrates

Conditioning as a Variance Reduction Tool

• Example: suppose we wish to find the area of a region, say the area under the graph of a function h(x).

• Crude Monte Carlo: Find a probability density function g(x) such that

cxh

xcgxh

xh

UXcgYxgXxcgYX

xxhxcg

iiii

ii

)(under area)(under area)(under area

)( ofgraph theunder also are which points theseof proportion The

.)( and )( p.d.f. has :)( ofgraph under the ddistributeuniformly ),(

points random generateThen . allfor )()(

=→

=

Page 18: CONTROL VARIATESsas.uwaterloo.ca/~dlmcleis/s906/slides200-250.pdf · 2004. 9. 29. · Control Variate • function g=GG(u) % control variate for callopt2. % this function integrates

Conditioning (II)

• Leads to the estimator:

riance?smaller vawith estimator unbiasedan give always thisDoesold. theofn expectatio lconditiona theby takingestimator new thisobtained We

)()(1

)()(]|[

estimator ealternativan Consider

say ,))((points ofnumber Total

hunder pointsNumber c

111

^

11

^

∑∑∑

∑∑

===

==

===

=≤=×

=

n

i i

in

i i

ii

n

ii

n

ii

n

iii

XgXh

nXcgXh

ncXZE

nc

Co

ZncXhYI

nc

CR

θ

θ

Page 19: CONTROL VARIATESsas.uwaterloo.ca/~dlmcleis/s906/slides200-250.pdf · 2004. 9. 29. · Control Variate • function g=GG(u) % control variate for callopt2. % this function integrates

Some Properties of Conditional Expectation

∑∑==

≤=

n

iii

n

ii

ii

ZncXZE

nc

XZE

E

X

XY

YEXYEE

11

i

^

^

first n thebetter tha is ]|[

estimator second theand ))|(var()var(Z Therefore

riance.smaller va with typicallyestimator, unbiasedanother is then thisX)|(

computecan we variablerandom somefor andestimator unbiasedan is IF

. offunction a is ifonly and ifequality with var(Y)X])|Var(E[Y .2

)(]}|[{ .1

θ

θ

Page 20: CONTROL VARIATESsas.uwaterloo.ca/~dlmcleis/s906/slides200-250.pdf · 2004. 9. 29. · Control Variate • function g=GG(u) % control variate for callopt2. % this function integrates

Example of Conditioning: Estimating pi

)|(4n expectatio lconditiona with then4

estimator crude theCompare .)1()V|E(Z

and 4

E(Z) then )1(Z

if and [0,1],on uniform ),( generate weIf

11

2/12

22

i

n

ii

n

ii VZE

nZ

V

VUI

VU

∑∑==

−=

=≤+=π

u=rand(2,200000); z= 4*(sum(u.^2)<1); theta1=mean(z); var(z)/length(z)

z2=4*sqrt(1-u(2,:).^2); theta2=mean(z2); var(z2)/length(z2)

Efficiency gain is about 3.3

Page 21: CONTROL VARIATESsas.uwaterloo.ca/~dlmcleis/s906/slides200-250.pdf · 2004. 9. 29. · Control Variate • function g=GG(u) % control variate for callopt2. % this function integrates

Combining conditioning and stratified sample

=

=

+−−=

−=

n

i

i

n

ii

nVi

nni

ni

Vn

duu

1

2/12

1

2/12

1

0

2/12

))1(1(4 isResult .,...,2,1),,n1-i(

intervaleach in n observatio one with sample stratified a use weif What .)1(4

estimatorn expectatio lconditiona theusing )1(4

estimated We

π

n=500000; u=rand(1,n); w=((0:(n-1))+u)/n;

z3= 4*sqrt(1-w.^2); theta3=mean(z3) ; pi-theta3

Accurate to 8 decimals!

Page 22: CONTROL VARIATESsas.uwaterloo.ca/~dlmcleis/s906/slides200-250.pdf · 2004. 9. 29. · Control Variate • function g=GG(u) % control variate for callopt2. % this function integrates

IMPORTANCE SAMPLING

• Idea: Why not weight observations in different parts of the sample space differently?

• e.g. interested in behaviour of a communication system or network under heavier than usual loads. Generate simulation under heavy loads and adjust the results for the difference.

Page 23: CONTROL VARIATESsas.uwaterloo.ca/~dlmcleis/s906/slides200-250.pdf · 2004. 9. 29. · Control Variate • function g=GG(u) % control variate for callopt2. % this function integrates

Importance Sampling• Can I increase the probability of the samples

that most effect my estimator without creating bias?

• Use importance sampling when: – we want to find – We can find a probability density function

such that it is easy to generate random variables with this probability density function and g is roughly proportional to f so that f(u)/g(u) is reasonably close to constant.

∫ duuf )()(ug

Page 24: CONTROL VARIATESsas.uwaterloo.ca/~dlmcleis/s906/slides200-250.pdf · 2004. 9. 29. · Control Variate • function g=GG(u) % control variate for callopt2. % this function integrates

Importance II• to find an appropriate importance sampling

distribution, start with a function g similar to f that is non-negative and easily integrated. Then multiply this function by a constant to obtain a p.d.f. Then:

. of c.d.f. theis where)( exampleFor ).(function density

yprobabilit with generated are variablerandom the where)()(1

using estimate thereforeshould We).(function density y probabilit having variablerandom a is Where

])()([)(

)()()(

1

1IM

ZGUGZzg

ZZgZf

n

zgZZgZfEdzzg

zgzfduuf

ii

i

n

i i

i

=

=

=

===

∫ ∫

θ

θ

θ

Page 25: CONTROL VARIATESsas.uwaterloo.ca/~dlmcleis/s906/slides200-250.pdf · 2004. 9. 29. · Control Variate • function g=GG(u) % control variate for callopt2. % this function integrates

Variance of Importance sample Estimator

])()()(var[1)(

).( p.d.f. t,independen with )()()(1

isestimator The ).( p.d.f. has where])()(

)([)]([

use ),( p.d.f. has where)]([ estimate togenerally More

))()(var(1)(

).( p.d.f.t with independen where)()(1

)()()()(

IM

1IM

IM

1IM

i

ii

i

n

i i

ii

i

i

i

n

i i

i

ZgZfZh

nVar

zgZZgZfZh

n

zgZZgZf

ZhEXhE

xfXXhEZgZf

nVar

zgZZgZf

n

dzzgzgzfduuf

=

=

=

=

=

==

∫ ∫

=

=

θ

θ

θ

θ

θ

Page 26: CONTROL VARIATESsas.uwaterloo.ca/~dlmcleis/s906/slides200-250.pdf · 2004. 9. 29. · Control Variate • function g=GG(u) % control variate for callopt2. % this function integrates

Example: importance sampling

• Find• Crude: u=rand(1,200000);

– mean(u.^1.6.*exp(-u)) % =0.1916var(u.^1.6.*exp(-u))/200000 %=6.7676e-008

• Importance:

0.19113. around is value trueThe .1

0

6.1∫ − dxex x

. where 2.61

n1

)()(1

)( and )( .10for 6.2)(

6.2/1n

1i1

6.2/116.26.1

iiZ

n

i i

iIM UZe

ZgZf

n

UUGxxGxxxg

i ===

==<<=

==

∑∑θ

Page 27: CONTROL VARIATESsas.uwaterloo.ca/~dlmcleis/s906/slides200-250.pdf · 2004. 9. 29. · Control Variate • function g=GG(u) % control variate for callopt2. % this function integrates

Importance sampling example

• u=rand(1,200000);• theta_IM=exp(-u.^(1/2.6))./2.6;• mean(theta_IM)• var(theta_IM)/200000 %= 9.3300e-009• (about 7 times as efficient as crude)

Page 28: CONTROL VARIATESsas.uwaterloo.ca/~dlmcleis/s906/slides200-250.pdf · 2004. 9. 29. · Control Variate • function g=GG(u) % control variate for callopt2. % this function integrates

Importance Sampling in Option Pricing example

• For the call option, try and approximate f with a linear function starting at (.47,0).

density. sampling importance thefrom generates 53.47.)(

12.7 so ])47.[(2

)( c.d.f.

p.d.f. a is thisso choose we where)47.()(

1

2

ZUUG

kxkxG

kxkxg

+=

=−=

−=

+

+

Why not use a density function (e.g. a quadratic density) that more closely approximates the function f?

Page 29: CONTROL VARIATESsas.uwaterloo.ca/~dlmcleis/s906/slides200-250.pdf · 2004. 9. 29. · Control Variate • function g=GG(u) % control variate for callopt2. % this function integrates

Matlab Code for Importance Sample. Stock Option Example.

• function [est,v]=importance(f,g,Ginv,u)• %runs a simulation on the function 'f" using importance density "g"(both

character strings) and inverse c.d.f. "Ginverse“• e.g. [est,v]=importance('fn','importancedens','Ginverse',rand(1,200000));• % outputs all estimators (use mean(est)) and variance of estimator.• % IM is the inverse cf of the importance distribution c.d.f. • IM= eval(strcat(Ginv,'(u)')); %=.47+.53*sqrt(U);• %IMdens is the density of the importance sampling distribution at IM• IMdens=eval(strcat(g,'(IM)')); %2*(IM-.47)/(.53)^2;• FN=eval(strcat(f,'(IM)'));• est=FN./IMdens; % mean(est) provides the estimator• v=var(FN./IMdens)/length(IM); % this is the variance of the estimator• ********************************************************************• %GIVES mean(est)= 0.4614 v = 6.4329e-008• EFFICIENCY GAIN OVER CRUDE IS AROUND 35.

Page 30: CONTROL VARIATESsas.uwaterloo.ca/~dlmcleis/s906/slides200-250.pdf · 2004. 9. 29. · Control Variate • function g=GG(u) % control variate for callopt2. % this function integrates

Exponential tilting and importance sampling: Estimating the probability of

rare eventsSuppose we wish to estimate an extreme quantile such as VAR 99.9% .

Then we need to estimate the probability that a random variable exceeds some large value. i.e. when

sampling. importance

use then andfunction density a is that thissochosen is where)()(

function density y probabilit (tilted)different aunder variablesrandomt independen as generate weif What . exceed willsums theof fewon very distributi under this

simulation econduct th weIf mean. sample ingcorrespond by the estimate is and )}({

is This ).(function density y probabilit have all

variablesrandomt independenfor where

10

10

11010

kxfkexg

Xa

aSIExfX

XSaS

tx

i

i

ii

=

>

=> ∑=

Page 31: CONTROL VARIATESsas.uwaterloo.ca/~dlmcleis/s906/slides200-250.pdf · 2004. 9. 29. · Control Variate • function g=GG(u) % control variate for callopt2. % this function integrates

.ely approximat choose so /)(

that so 1/-1 tChoose .ely approximat is that so choose when wesmall

isestimator sample importance theof varianceThe ? of best value theisWhat .p.d.f )l(exponentiat with independen are where

})({})({})()(

)({

isestimator sample importance The .1

1 valueexpected

hasit p.d.f. thisfrom generate weIfon.distributi lexponentiaanother ... p.d.f. afunction thismakesthat

multiple theis thissince )1(1)(

ison distributi tiltedThen the .)( that suppose exampleFor

1

11111

)1(

1

a/nnaZE

aZt

Z

eaZIEeaZIEZgZf

aZIE

t

X

teek

xg

exf

i

n

ii

i

Ztn

ii

ntZn

i

n

ii

n

i it

in

ii

i

txxtxt

x

n

ii

i

θθ

θ

θθ

θθ

θ

==

=

>=>=>

−=

−×==

=

∑∏∑∏∑

=

∑−

=

====

−−−

=

Page 32: CONTROL VARIATESsas.uwaterloo.ca/~dlmcleis/s906/slides200-250.pdf · 2004. 9. 29. · Control Variate • function g=GG(u) % control variate for callopt2. % this function integrates

Matlab Code for Example, a=22.6, n=10

• N=500000• X=exprnd(1,10,N); • est1=(sum(X)>22.6);• mean(est1) % 0.001• var(est1) % 8.8e-004Using Importance sampling• Z=exprnd(2.5,10,N);• S=sum(Z); theta=2.5• est2=theta^10*exp(-(1-1/theta)*S).*(S>22.6);• mean(est2) % =0.001• var(est2) % 5.5e-6, and SE about 0.000003• EFFICIENCY GAIN FROM IMPORTANCE SAMPLING IS ABOUT

180.

Page 33: CONTROL VARIATESsas.uwaterloo.ca/~dlmcleis/s906/slides200-250.pdf · 2004. 9. 29. · Control Variate • function g=GG(u) % control variate for callopt2. % this function integrates

Common Random Numbers: estimating a difference

• Suppose we wish to estimate the difference between two systems or values: e.g.– Estimate the slope of a function at a point– Estimate the difference in performance

between two pieces of equipment– Estimate the difference between a call

option price for r=0.05 and r=0.06.

Page 34: CONTROL VARIATESsas.uwaterloo.ca/~dlmcleis/s906/slides200-250.pdf · 2004. 9. 29. · Control Variate • function g=GG(u) % control variate for callopt2. % this function integrates

Importance Sampling, Tilting and the Saddlepoint

Approximation

then )},{exp(lnfunction generatingcumulant has X and point at the

X of function density proability theeapproximat wish to weIf this...achieve toas soon distributi original theiltingConsider t

O(1/n). toaccurate ision approximat normal theand zero is correction the,at that Notice

ion.approximatfunction density normal usual theis ),;( and ,)( and /)( where

)}/1(]3[6

1){,;(

form the takes variablesrandom i.i.d. ofmean sample theoffunctiondensity y probabilit theofExpansion Edgeworth The

2

3

32

XtEK(t)x

f(x)

xxn

XExnz

nOzzn

xn

=

=

−=−=

+−+

µσµ

µκσµ

κσµ

Page 35: CONTROL VARIATESsas.uwaterloo.ca/~dlmcleis/s906/slides200-250.pdf · 2004. 9. 29. · Control Variate • function g=GG(u) % control variate for callopt2. % this function integrates

Saddlepoint(cont)

.)(' where,)("2

1

is )( ion toapproximat nt)(saddlepoi theTherefore)("2

1))("),('),('( is

density theion toapproximatEdgeworth The ).(" variance theandx

ismean the)(' that so choose weif so )('by given mean has )()(density the

)(

)(

xKeK

xfK

KKKn

fK

xKKxfexf

xK

Kx

=

=

==

θθπ

θπθθθ

θθθθ

θθ

θ

θθθ

Page 36: CONTROL VARIATESsas.uwaterloo.ca/~dlmcleis/s906/slides200-250.pdf · 2004. 9. 29. · Control Variate • function g=GG(u) % control variate for callopt2. % this function integrates

Two steps of saddlepoint

• Saddlepoint approximation has two steps– Tilt the original density so that mean of tilted

distribution is around the point of interest x– Use the normal approximation to the tilted

distribution.• Importance sampling from the tilted

density avoids the second step.

Page 37: CONTROL VARIATESsas.uwaterloo.ca/~dlmcleis/s906/slides200-250.pdf · 2004. 9. 29. · Control Variate • function g=GG(u) % control variate for callopt2. % this function integrates

Tilting and large deviations (Robert and Casella p 132)

)(~])[ln(

Then .)('such that is again where)()(

small. very isy probabilit when this][ e.g. sums. partial

ofon distributiaof taileconcern thresults deviations Large

xIxSP

xKKxxI

xSP

n

n

−>

=−=

>

n1

Put Theorem. sCramer'

θθθθ

Page 38: CONTROL VARIATESsas.uwaterloo.ca/~dlmcleis/s906/slides200-250.pdf · 2004. 9. 29. · Control Variate • function g=GG(u) % control variate for callopt2. % this function integrates

Student presentation 11. Importance Sampling (Robert and

Casella 85-87)• Suppose X as the student t distribution with 12

degrees of freedom. Estimate

using crude Monte Carlo and imporance sampling and various choices of the importance distribution including Cauchy, U[0,1/2.1], and normal distribution. Which do you prefer and why?

⎟⎟⎠

⎞⎜⎜⎝

⎛≥

−+)0(

)3(1 2

5

XIXXE

Page 39: CONTROL VARIATESsas.uwaterloo.ca/~dlmcleis/s906/slides200-250.pdf · 2004. 9. 29. · Control Variate • function g=GG(u) % control variate for callopt2. % this function integrates

Reducing Variance when estimating the difference of Expected values

.antithetic of Opposite).( ),(

... and generate touniform SAME theuse weif covariance large a arrangecan we

functions gincreaseinboth are )(),( functionsWhen large. is ))(),(cov( if small is thisand

))(),(cov(2)](var[)](var[)]()(var[Then ly.respective and

functionson distributi cumulative have , where))(())((

estimate wish to wegeneralIn

11

21

21

212121

21

UFYUFX

eiYX

YhXhYhXh

YhXhYhXhYhXhFF

YXYhEXhE

YX

YX

−− ==

−+=−

Page 40: CONTROL VARIATESsas.uwaterloo.ca/~dlmcleis/s906/slides200-250.pdf · 2004. 9. 29. · Control Variate • function g=GG(u) % control variate for callopt2. % this function integrates

Theorem: Common and Antithetic Random Numbers

)1( ),(

:numbers random antithetic use when we and)( ),(

i.e. numbers, randomcommon use when we is))(),(cov(

covariance then thely,respective and functionson distributi cumulativegiven have ,

that sconstraint theSubject to functions. decreasingbothor increasingboth are )(),( Suppose

11

11

21

21

UFYUFX

minimizedUFYUFX

maximizedYhXh

FFYX

yhxh

YX

YX

YX

−==

==

−−

−−

:Theorem

Page 41: CONTROL VARIATESsas.uwaterloo.ca/~dlmcleis/s906/slides200-250.pdf · 2004. 9. 29. · Control Variate • function g=GG(u) % control variate for callopt2. % this function integrates

Comparing estimators for Call Option Pricing Example

• script9

Page 42: CONTROL VARIATESsas.uwaterloo.ca/~dlmcleis/s906/slides200-250.pdf · 2004. 9. 29. · Control Variate • function g=GG(u) % control variate for callopt2. % this function integrates

Combining Monte Carlo Estimators

• If I have many MC estimators, with/without various variance reduction techniques, which should I choose?

Page 43: CONTROL VARIATESsas.uwaterloo.ca/~dlmcleis/s906/slides200-250.pdf · 2004. 9. 29. · Control Variate • function g=GG(u) % control variate for callopt2. % this function integrates

Combining Estimators

• Suppose I have m unbiased estimators all of the same parameter

• Put these estimators in a vector Yθ

m.length of )(1,1,...,1vector therepresents 1 where1)E( that so )',...,( 21 θ== YYYYY m

Any linear combination of these estimators with coefficients that add to one is also an unbiased estimator of the parameter

Which such linear combination is best?θ

Page 44: CONTROL VARIATESsas.uwaterloo.ca/~dlmcleis/s906/slides200-250.pdf · 2004. 9. 29. · Control Variate • function g=GG(u) % control variate for callopt2. % this function integrates

Best linear combination of estimators.

).,cov(. of matrix covariance

theof inverse theis whereand toalproportion is

and 1 where isn combinatiolinear best The :A. estimating of jobbest

thedoes estimators theseofn combinatiolinear What :Q

1

1

i

jiij

-m

jiji

iii

YYVYV

VCCb

bYb

=

=

=

∑∑

=

θ

Page 45: CONTROL VARIATESsas.uwaterloo.ca/~dlmcleis/s906/slides200-250.pdf · 2004. 9. 29. · Control Variate • function g=GG(u) % control variate for callopt2. % this function integrates

Estimating Covariance

__

1

,

)()(1

1

by Estimate:covariance sample usingmatrix covariance- varianceestimatemay we

of valuesreplicated are 21, e.g. s,simulation (from ,estimators theseof t valuesindependenmany have When we

jjkiik

n

k

ij

iij

YYYYn

V

Y,...,n,jYn

−−−

=

∑=

Page 46: CONTROL VARIATESsas.uwaterloo.ca/~dlmcleis/s906/slides200-250.pdf · 2004. 9. 29. · Control Variate • function g=GG(u) % control variate for callopt2. % this function integrates

Theorem on Optimal Linear Combination of estimators

.1'1

1'

isestimator resulting theof varianceThe ones. oftor column vec theis 1 Here .'1)1'1(

by given is vector the where

form theof 1,2,...mi, estimators ofn combinatiolinear The)Estimators ofn CombinatioLinear (Best :

11

111'1

−−

−−−

=

=

=

=

VbVb

mVVb

bYb

YTheorem

m

iii

i

Page 47: CONTROL VARIATESsas.uwaterloo.ca/~dlmcleis/s906/slides200-250.pdf · 2004. 9. 29. · Control Variate • function g=GG(u) % control variate for callopt2. % this function integrates

Example: combining the estimators of the call option

price

stratabetween antithetic ,stratified)16.1(16.)37.47(.37.

strata.between common U strata,within antithetic uses and [.84,1] and [.47,.84] into stratified is This

)]16.1()16.84(.[216.

)]37.84(.)37.47(.[237.0

c)(antitheti ))53.1()53.47(.(253.0

:estimators following heConsider t

3

2

1

UfUfY

UfUf

UfUfY

UfUfY

−++=

−+++

−++=

−++=

Page 48: CONTROL VARIATESsas.uwaterloo.ca/~dlmcleis/s906/slides200-250.pdf · 2004. 9. 29. · Control Variate • function g=GG(u) % control variate for callopt2. % this function integrates

Example: (cont)

)1 so rescaled- of rows theof sum the

toalproportion is ( .11'1

1by given is vector thewhere

isn combinatiolinear best The . matrix covariance theand

estimators individual Obtain the . of valuesfor repeatedly thisDo uniform. same the

using ,... estimators five all of valuessimulated Generate

sampling) e(importanc 53.47. where)()(

)47.(])47.[(6)( where

variate)(control )]()([)(

1

11

5

1

51

5

2

4

=

=

+==

−+−=

−+=

−−

=

++

i

iii

bV

bVV

bb

YbV

Un

YY

UZZgZfY

uuug

UgUfduugY

Page 49: CONTROL VARIATESsas.uwaterloo.ca/~dlmcleis/s906/slides200-250.pdf · 2004. 9. 29. · Control Variate • function g=GG(u) % control variate for callopt2. % this function integrates

MATLAB function OPTIMAL• function [o,v,b,t1]=optimal(U)• % generates optimal linear combination of five estimators and outputs • % average estimator and variance. • t1=cputime;• Y1=(.53/2)*(fn(.47+.53*U)+fn(1-.53*U)); t1=[t1 cputime];• Y2=.37*.5*(fn(.47+.37*U)+fn(.84-.37*U))+.16*.5*(fn(.84+.16*U)+fn(1-

.16*U));• t1=[t1 cputime];• Y3=.37*fn(.47+.37*U)+.16*fn(1-.16*U); t1=[t1 cputime];• intg=2*(.53)^3+.53^2/2; Y4=intg+fn(U)-GG(U); t1=[t1

cputime];• Y5=importance('fn','importancedens','Ginverse',U); t1=[t1

cputime];• X=[Y1' Y2' Y3' Y4' Y5'];• mean(X)• V=cov(X); Z=ones(5,1); C=inv(V); b=C*Z/(Z'*C*Z);• o=mean(X*b); % this is mean of the optimal linear combinations• t1=[t1 cputime];• v=1/(Z'*V1*Z); • t1=diff(t1); % these are the cputimes of the various estimators.

Page 50: CONTROL VARIATESsas.uwaterloo.ca/~dlmcleis/s906/slides200-250.pdf · 2004. 9. 29. · Control Variate • function g=GG(u) % control variate for callopt2. % this function integrates

Results for option pricing• [o,v,b]=optimal(rand(1,100000))• Estimators = 0.4619 0.4617 0.4618 0.4613 0.4619

• o = 0.46151 % best linear combination (true value=0.46150)

• v = 1.1183e-005 %variance per uniform input• b’ = -0.5503 1.4487 0.1000 0.0491 -0.0475

Page 51: CONTROL VARIATESsas.uwaterloo.ca/~dlmcleis/s906/slides200-250.pdf · 2004. 9. 29. · Control Variate • function g=GG(u) % control variate for callopt2. % this function integrates

Efficiency of Optimal Linear Combination

• Efficiency gain based on number of uniform random numbers 0.4467/0.00001118 or about 40,000.

• However, one uniform generates 5 estimators requiring 10 function evaluations.

• Efficiency based on function evaluations approx 4,000

• A simulation using 500,000 uniform random numbers ; 13 seconds on Pentium IV (2.4 Ghz) equivalent totwenty billion simulations by crude Monte Carlo.