Introduction to simulation and Monte Carlo A simulation is an experiment, usually conducted on a computer, involving the use of random numbers.. A random number stream is a sequence of s
Trang 1Simulation and Monte Carlo
With applications in finance and MCMC
J S Dagpunar
School of Mathematics University of Edinburgh, UK
Trang 3Simulation and Monte Carlo
Trang 5Simulation and Monte Carlo
With applications in finance and MCMC
J S Dagpunar
School of Mathematics University of Edinburgh, UK
Trang 6West Sussex PO19 8SQ, England Telephone +44 1243 779777 Email (for orders and customer service enquiries): cs-books@wiley.co.uk
Visit our Home Page on www.wiley.com
All Rights Reserved No part of this publication may be reproduced, stored in a retrieval system or transmitted
in any form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except under the terms of the Copyright, Designs and Patents Act 1988 or under the terms of a licence issued by the Copyright Licensing Agency Ltd, 90 Tottenham Court Road, London W1T 4LP, UK, without the permission
in writing of the Publisher Requests to the Publisher should be addressed to the Permissions Department, John Wiley & Sons Ltd, The Atrium, Southern Gate, Chichester, West Sussex PO19 8SQ, England, or emailed to permreq@wiley.co.uk, or faxed to +44 1243 770620.
Designations used by companies to distinguish their products are often claimed as trademarks All brand names and product names used in this book are trade names, service marks, trademarks or registered trademarks of their respective owners The Publisher is not associated with any product or vendor mentioned in this book This publication is designed to provide accurate and authoritative information in regard to the subject matter covered It is sold on the understanding that the Publisher is not engaged in rendering professional services If professional advice or other expert assistance is required, the services of a competent professional should be sought.
Other Wiley Editorial Offices
John Wiley & Sons Inc., 111 River Street, Hoboken, NJ 07030, USA
Jossey-Bass, 989 Market Street, San Francisco, CA 94103-1741, USA
Wiley-VCH Verlag GmbH, Boschstr 12, D-69469 Weinheim, Germany
John Wiley & Sons Australia Ltd, 42 McDougall Street, Milton, Queensland 4064, Australia
John Wiley & Sons (Asia) Pte Ltd, 2 Clementi Loop #02-01, Jin Xing Distripark, Singapore 129809 John Wiley & Sons Canada Ltd, 6045 Freemont Blvd, Mississauga, ONT, Canada L5R 4J3
Wiley also publishes its books in a variety of electronic formats Some content that appears in print may not
be available in electronic books.
Library of Congress Cataloging in Publication Data
British Library Cataloguing in Publication Data
A catalogue record for this book is available from the British Library
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)
Typeset in 10/12pt Times by Integra Software Services Pvt Ltd, Pondicherry, India
Printed and bound in Great Britain by Antony Rowe Ltd, Chippenham, Wiltshire
This book is printed on acid-free paper responsibly manufactured from sustainable forestry
in which at least two trees are planted for each one used for paper production.
Trang 7To the memory of Jim Turner, Veterinary surgeon, 1916–2006
Trang 9Contents
Trang 104.3 Bivariate normal density 63
Trang 11Contents ix
7.6 Simulating a G/G/1 queueing system using the three-phase method 146
8.2 Markov chains and the Metropolis–Hastings (MH) algorithm 159
8.4 Single component Metropolis–Hastings and Gibbs sampling 165
Trang 13The intention is that this be a practical book that encourages readers to write andexperiment with actual simulation models The choice of programming environment,Maple, may seem strange, perhaps even perverse It arises from the fact that at Edinburghall mathematics students are conversant with it from year 1 I believe this is true of manyother mathematics departments The disadvantage of slow numerical processing in Maple
is neutralized by the wide range of probabilistic, statistical, plotting, and list processingfunctions available A large number of specially written Maple procedures are available
on the website accompanying this book (www.wiley.com/go/dagpunar_simulation) Theyare also listed in the Appendices.1
The content of the book falls broadly into two halves, with Chapters 1 to 5 mostlycovering the theory and probabilistic aspects, while Chapters 6 to 8 cover three applicationareas Chapter 1 gives a brief overview of the breadth of simulation All problems at theend of this chapter involve the writing of Maple procedures, and full solutions are given
in Appendix 1 Chapter 2 concerns the generation and assessment of pseudo-randomnumbers Chapter 3 discusses three main approaches to the sampling (generation) ofrandom variates from distributions These are: inversion of the distribution function, theenvelope rejection method, and the ratio of uniforms method It is recognized that manyother methods are available, but these three seem to be the most frequently used, andthey have the advantage of leading to easily programmed algorithms Readers interested
in the many other methods are directed to the excellent book by Devroye (1986) or anearlier book of mine (Dagpunar, 1988a) Two short Maple procedures in Appendix 3allow readers to quickly ascertain the efficiency of rejection type algorithms Chapter 4deals with the generation of variates from standard distributions The emphasis is onshort, easily implemented algorithms Where such an algorithm appears to be fasterthan the corresponding one in the Maple statistics package, I have given a listing inAppendix 4 Taken together, I hope that Chapters 3 and 4 enable readers to understandhow the generators available in various packages work and how to write algorithms fordistributions that either do not appear in such packages or appear to be slow in execution.Chapter 5 introduces variance reduction methods Without these, many simulations areincapable of giving precise estimates within a reasonable amount of processing time.Again, the emphasis is on an empirical approach and readers can use the procedures in
1 The programs are provided for information only and may not be suitable for all purposes Neither the author nor the publisher is liable, to the fullest extent permitted by law, for any failure of the programs to meet the user’s requirements or for any inaccuracies or defects in the programs.
Trang 14Appendix 5 to illustrate the efficacy of the various designs, including importance andstratified sampling.
Chapters 6 and 8, on financial mathematics and Markov chain Monte Carlo methodsrespectively, would not have been written 10 years ago Their inclusion is a result ofthe high-dimensional integrations to be found in the pricing of exotic derivatives and inBayesian estimation In a stroke this has caused a renaissance in simulation In Chapter 6, Ihave been influenced by the work of Glasserman (2004), particularly his work combiningimportance and stratified sampling I hope in Sections 6.4.2 and 6.5 that I have provided amore direct and accessible way of deriving and applying such variance reduction methods
to Asian and basket options Another example of high-dimensional integrations arises
in stochastic volatility and Section 6.6 exposes the tip of this iceberg Serious financialengineers would not use Maple for simulations Nevertheless, even with Maple, it isapparent from the numerical examples in Chapter 6 that accurate results can be obtained
in a reasonable amount of time when effective variance reduction designs are employed
I also hope that Maple can be seen as an effective way of experimenting with variousmodels, prior to the final construction of an efficient program in C++ or Java, say TheMaple facility to generate code in, say, C++ or Fortran is useful in this respect.Chapter 7 introduces discrete event simulation, which is perhaps best known tooperational researchers It starts with methods of simulating various Markov processes,both in discrete and continuous time It includes a discussion of the regenerative method
of analysing autocorrelated simulation output The simulation needs of the operationalresearcher, the financial engineer, and the Bayesian statistician overlap to a certain extent,but it is probably true to say that no single computing environment is ideal for allapplication fields An operational researcher might progress from Chapter 7 to make use
of one of the powerful purpose-built discrete event simulation languages such as SimscriptII.5 or Witness If so, I hope that the book provides a good grounding in the principles
of simulation
Chapter 8 deals with the other burgeoning area of simulation, namely Markov chainMonte Carlo and its use in Bayesian statistics Here, I have been influenced by the
works of Robert and Casella (2004) and Gilks et al (1996) I have also included several
examples from the reliability area since the repair and maintenance of systems is anotherarea that interests me Maple has been quite adequate for the examples discussed in thischapter For larger hierarchical systems a purpose-built package such as BUGS is theanswer
There are problems at the end of each chapter and solutions are given to selectedones A few harder problems have been designated accordingly In the text and problems,numerical answers are frequently given to more significant figures than the data wouldwarrant This is done so that independent calculations may be compared with the onesappearing here
I am indebted to Professor Alastair Gillespie, head of the School of Mathematics,Edinburgh University, for granting me sabbatical leave for the first semester of the2005–2006 session I should also like to acknowledge the several cohorts of simulationstudents that provided an incentive to write this book Finally, my thanks to Angie forher encouragement and support, and for her forbearance when I was not there
Trang 15beta 1 A random variable that is beta distributed with p.d.f f x=
+ x−11− x −1/ 1≥ x ≥ 0, where > 0
> 0
binomial n p A binomially distributed random variable
≥ 0 Standard Brownian motion
c.d.f Cumulative distribution function
CovfX Y The covariance of X and Y where f x y is the joint p.d.f./p.m.f
of X and Y (the subscript is often dropped)
Exp A r.v that has the p.d.f f x= e− x x≥ 0, where > 0
EfX The expectation of a random variable X that has the p.d.f or p.m.f
f (the subscript is often dropped)
fXx The p.d.f or p.m.f of a random variable X (the subscript is often
dropped)
FXx The c.d.f of a random variable X
FXx Complementary cumulative distribution function = 1 − FXx gamma A gamma distributed r.v with the p.d.f f x= x−1e− x/
i.i.d Identically and independently distributed
negbinom k p A negative binomial r.v with the p.d.f f x∝ px1− pk x=
p.d.f Probability density function
Poisson A r.v distributed as a Poisson with the p.m.f f x= xe−x/x! x =
0 1 , where > 0
P X < x Probability that the random variable X is less than x
P X= x Probability that a (discrete) random variable equals x
1 This can also refer to the distribution itself This applies to all corresponding random variable names in this list.
Trang 16support f ∈ f x = 0
U 0 1 A continuous r.v that is uniformly distributed in the interval (0, 1).VarfX The variance of a random variable X that has the p.d.f or p.m.f f
(the subscript is often dropped)
v.r.r Variance reduction ratio
Weibull A Weibull distributed random variable with the p.d.f f x=
x−1e− ... some parameters of
interest in the original problem, system, or population
Simulation and Monte Carlo: With applications in finance and MCMC< /small> J S Dagpunar... care is needed in selecting an appropriate
recurrence, to make the sequence appear random.
Simulation and Monte Carlo: With applications in finance and MCMC< /small>... ‘shift’ and ‘return’ keys to obtain a fresh line withinthe procedure The procedure terminates with a semicolon and successful entry of theprocedure results in the code being ‘echoed’ in blue