Simulation and Monte Carlo With applications in finance and MCMC J. S. Dagpunar School of Mathematics University of Edinburgh, UK Simulation and Monte Carlo b 21 2006 il /S i ffi b 21 2006 il /S ii ffi Simulation and Monte Carlo With applications in finance and MCMC J. S. Dagpunar School of Mathematics University of Edinburgh, UK b 21 2006 il /S iii ffi Copyright©2007 JohnWiley&SonsLtd,TheAtrium,SouthernGate,Chichester, WestSussexPO198SQ,England Telephone (cid:2)+44(cid:3)1243779777 Email(forordersandcustomerserviceenquiries):[email protected] VisitourHomePageonwww.wiley.com AllRightsReserved.Nopartofthispublicationmaybereproduced,storedinaretrievalsystemortransmitted inanyformorbyanymeans,electronic,mechanical,photocopying,recording,scanningorotherwise,except underthetermsoftheCopyright,DesignsandPatentsAct1988orunderthetermsofalicenceissuedbythe CopyrightLicensingAgencyLtd,90TottenhamCourtRoad,LondonW1T4LP,UK,withoutthepermission inwritingofthePublisher.RequeststothePublishershouldbeaddressedtothePermissionsDepartment, JohnWiley&SonsLtd,TheAtrium,SouthernGate,Chichester,WestSussexPO198SQ,England,or [email protected],orfaxedto(cid:2)+44(cid:3)1243770620. Designationsusedbycompaniestodistinguishtheirproductsareoftenclaimedastrademarks.Allbrandnames andproductnamesusedinthisbookaretradenames,servicemarks,trademarksorregisteredtrademarksof theirrespectiveowners.ThePublisherisnotassociatedwithanyproductorvendormentionedinthisbook. Thispublicationisdesignedtoprovideaccurateandauthoritativeinformationinregardtothesubjectmatter covered.ItissoldontheunderstandingthatthePublisherisnotengagedinrenderingprofessionalservices.If professionaladviceorotherexpertassistanceisrequired,theservicesofacompetentprofessionalshouldbe sought. OtherWileyEditorialOffices JohnWiley&SonsInc.,111RiverStreet,Hoboken,NJ07030,USA Jossey-Bass,989MarketStreet,SanFrancisco,CA94103-1741,USA Wiley-VCHVerlagGmbH,Boschstr.12,D-69469Weinheim,Germany JohnWiley&SonsAustraliaLtd,42McDougallStreet,Milton,Queensland4064,Australia JohnWiley&Sons(Asia)PteLtd,2ClementiLoop#02-01,JinXingDistripark,Singapore129809 JohnWiley&SonsCanadaLtd,6045FreemontBlvd,Mississauga,ONT,CanadaL5R4J3 Wileyalsopublishesitsbooksinavarietyofelectronicformats.Somecontentthatappearsinprintmaynot beavailableinelectronicbooks. LibraryofCongressCataloginginPublicationData BritishLibraryCataloguinginPublicationData AcataloguerecordforthisbookisavailablefromtheBritishLibrary ISBN-13:978-0-470-85494-5(HB) 978-0-470-85495-2(PB) ISBN-10:0-470-85494-4(HB) 0-470-85495-2(PB) Typesetin10/12ptTimesbyIntegraSoftwareServicesPvt.Ltd,Pondicherry,India PrintedandboundinGreatBritainbyAntonyRoweLtd,Chippenham,Wiltshire Thisbookisprintedonacid-freepaperresponsiblymanufacturedfromsustainableforestry inwhichatleasttwotreesareplantedforeachoneusedforpaperproduction. b 21 2006 il /S i ffi To the memory of Jim Turner, Veterinary surgeon, 1916–2006 b 21 2006 il /S ffi b 21 2006 il /S i ffi Contents Preface xi Glossary xiii 1 Introduction to simulation and Monte Carlo 1 1.1 Evaluating a definite integral 2 1.2 Monte Carlo is integral estimation 4 1.3 An example 5 1.4 A simulation using Maple 7 1.5 Problems 13 2 Uniform random numbers 17 2.1 Linear congruential generators 18 2.1.1 Mixed linear congruential generators 18 2.1.2 Multiplicative linear congruential generators 22 2.2 Theoretical tests for random numbers 25 2.2.1 Problems of increasing dimension 26 2.3 Shuffled generator 28 2.4 Empirical tests 29 2.4.1 Frequency test 29 2.4.2 Serial test 30 2.4.3 Other empirical tests 30 2.5 Combinations of generators 31 2.6 The seed(s) in a random number generator 32 2.7 Problems 32 3 General methods for generating random variates 37 3.1 Inversion of the cumulative distribution function 37 3.2 Envelope rejection 40 3.3 Ratio of uniforms method 44 3.4 Adaptive rejection sampling 48 3.5 Problems 52 4 Generation of variates from standard distributions 59 4.1 Standard normal distribution 59 4.1.1 Box–Müller method 59 4.1.2 An improved envelope rejection method 61 4.2 Lognormal distribution 62 viii Contents 4.3 Bivariate normal density 63 4.4 Gamma distribution 64 4.4.1 Cheng’s log-logistic method 65 4.5 Beta distribution 67 4.5.1 Beta log-logistic method 67 4.6 Chi-squared distribution 69 4.7 Student’s t distribution 69 4.8 Generalized inverse Gaussian distribution 71 4.9 Poisson distribution 73 4.10 Binomial distribution 74 4.11 Negative binomial distribution 74 4.12 Problems 75 5 Variance reduction 79 5.1 Antithetic variates 79 5.2 Importance sampling 82 5.2.1 Exceedance probabilities for sums of i.i.d. random variables 86 5.3 Stratified sampling 89 5.3.1 A stratification example 92 5.3.2 Post stratification 96 5.4 Control variates 98 5.5 Conditional Monte Carlo 101 5.6 Problems 103 6 Simulation and finance 107 6.1 Brownian motion 108 6.2 Asset price movements 109 6.3 Pricing simple derivatives and options 111 6.3.1 European call 113 6.3.2 European put 114 6.3.3 Continuous income 115 6.3.4 Delta hedging 115 6.3.5 Discrete hedging 116 6.4 Asian options 118 6.4.1 Naive simulation 118 6.4.2 Importance and stratified version 119 6.5 Basket options 123 6.6 Stochastic volatility 126 6.7 Problems 130 7 Discrete event simulation 135 7.1 Poisson process 136 7.2 Time-dependent Poisson process 140 7.3 Poisson processes in the plane 141 7.4 Markov chains 142 7.4.1 Discrete-time Markov chains 142 7.4.2 Continuous-time Markov chains 143