Pré-visualização parcial do texto
Baixe Stochastic Simulation by Brian D. Ripley e outras Notas de estudo em PDF para Cultura, somente na Docsity!
Stochastic Simulation BRIAN D. RIPLEY Professor of Statistics University of Strathelyde Glasgow, Scotland JOHN WILEY & SONS New York » Chichester + Brisbane e Toronto « Singapore Copyright O 1987 by John Wiley & Sons, Inc AM rights reserved. Published simultaneonsly in Canada. Reproduction or translation of any part of this work beyond that permitted by Section 107 or 108 of the 1976 United States Copyright Act without the permission of the copyright owner is unlawful. Requests for permission or further information should be addressed to the Permissions Department, John Wiley & Sons, Inc Library of Congress Cataloging in Publication Data: Ripley, Brian D., 1952- Stochastic simulation. (Wiley series in probability and mathematical statistics. Applied probability and statistics, TSSN 0271-6356) Includes index. 1. Digital computer simulation. 2. Stochastic processes, I. Title. H. Series. QA76.9.C65R57 1987 001.434 86-15728 TSBN 0-47]-81884-4 Printed and bound im the United States of America 1098765 vi PREFACE more complex algorithms. These are referençed but, in general, not de- scribed in detail. The coverage of methods was comprehensive at the time of writing. Even statisticians often fail to treat simulations seriously as experiments. Even more is possible in the way of design since the randomness was intro- duced by the experimenter and hence is under his or her complete control. Such techniques are described in Chapter 5 under the heading of “variance reduction.” A general knowledge of the statistical design of experiments is helpful here and essential to a competent practitioner of simulation. The analysis of the output of many simulation experiments, for example queueing systems, is also more complicated than many users suppose, although not as difficult as the literature makes out! This topic is discussed in Chapter 6. Chapter 7 discusses many novel uses of simulation. It can be used, for example, in optimizing designs of integrated circuits and in fundamentally new ideas in statistical inference. The literature on simulation is vast, and 1 have made no attempt to cite comprehensively. There are several published bibliographies, but a lot of the work has been superseded or is misleading. The exercises vary considerably in difficulty. Some are routine exercises in developing algorithms from generai theory or in providing illustrative examples. Others are of an open-ended nature; they suggest experiments to be done and demand access to a computer (although the humblest personal computer would suffice). Simulation has long been a cinderetla subject, particularly in statistics. Thope this book shows that it raíses fascinating mathematical and statistical problems that demand attention. BRIAN D. RIPLEY Glasgow Oetober 1986 Acknowledgments Lam indebted to everyone who has taught me about simulation or has been prepared to share their experiences with me, in particular, Anthony Atkinson and Luc Devroye. The manuscript was typed with great efficiency by Lynne Westwood. The figures were produced on equipment funded by the Science and Engineering Research Council. B.D.R. vii Contents 1 Aims of Simulation 1.1 The Tools, 2 1.2 Models, 2 1.3 Simulation as Experimentation, 4 14 Simulation in Inference, 4 15 Examples, 5 1.6 Literature, 12 1.7 Convention, 12 Exercises, 13 2 Pseudo-Random Numbers 2.1 History and Philosophy, 14 22 Congruential Generators, 20 2.3 Shift-Register Generators, 26 24 Lattice Structure, 33 2.5 Shuffling and Testing, 42 2.6 Conclusions, 45 2.7 Proofs, 46 Exercises, 50 3 Random Variables 3.1 Simple Examples, 54 3.2 General Principles, 59 3.3 Discrete Distributions, 7! 34 Continuous Distributions, 81 3.5 Recommendations, 91 Exercises, 92 14 53 x CONTENTS 4 Stochastic Models 9% 4.1 Order Statistics, 96 4.2 Multivariate Distributions, 98 4.3 Poisson Processes and Lifetimes, 100 4.4 Markov Processes, 104 4.5 Gaussian Processes, 105 4.6 Point Processes, 10 4.7 Metropolis! Method and Random Fields, 113 Exercises, 116 5 Variance Reduction 118 5.1 Monte-Carto Integration, 119 5.2 Importance Sampling, 122 5.3 Control and Antithetic Variates, 123 54 Conditioning, 134 5.5 Experimental Design, 137 Exercises, 139 6 Output Analysis 142 6.1 The Initial Transient, 146 6.2 Batching, 150 6.3 Time-Series Methods, 155 6.4 Regenerative Simulation, 157 6.5 A Case Study, 161 Exercises, 169 7 Uses of Simulation 170 7.1 Statistical Inference, 171 7.2 Stochastic Methods in Optimization, 178 7.3 Systems of Linear Equations, 186 7.4 Quasi-Monte-Carlo Integration, 189 7.5 Sharpening Buffon's Needle, 193 Exercises, 198 References 200 Stochastic Simulation CHAPTER 1 Aims of Simulation The terminology of our subject can be confusing, with some authors insisting on shades of meaning that do not have widespread agreement. À dictionary definition of “to simulate” is Feign,..., pretend to be, act like, resemble, wear the guise of, mimic, ... imitate conditions of (situation etc.) with model, for convenience or training... Concise Oxford Dictionary, 1976 ed. In everyday usage “simulated” has a derogatory ring, but the value of simu- lators in training pilots is also recognized. In its technical sense simulation involves using a model to produce results, rather than experiment with the real system under study (which may not yet exist). For example, simulation is used to the explore the extraction of oil from an oil reserve. If the model has a stochastic element, we have stochastic simulation, the subject of this monograph. Another term, the Monte-Carlo method, arose during World War II for stochastic simulations of models of atomic collisions (branching processes). Sometimes it is used synonymously with stochastic simulation, but sometimes it carries a more specialized meaning of “doing something clever and sto- chastic with simulation.” This may involve simulating a different system from that under study, perhaps even using a stochastic model for a deter- ministic system (as in Monte-Carlo integration). We will not use Monte Carlo except in the conventional terms “Monte-Carlo integration” and “Monte-Carlo test” Simulation can have many aims, which makes it impossible to give uni- versal guidelines to good practice. Tocher (1963) wrote one of the first texts on the subject. His title was The Art of Simulation, and simulation is still an art despite a much greater understanding of the simulator's toolkit. The aim of this volume is to display those tools in their most useful form with guid- ance about their use. 2 AIMS OF SIMULATION 1.1. THE TOOLS The first thing needed for a stochastic simulation is a source of random- ness. This is often taken for granted but is of fundamental importance. Regrettably many of the so-called random functions supplied with the most widespread computers are far from random, and many simulation studies have been invalidated as a consequence. Digital computers cannot easily be interfaced to a truly random phenom- enon such as the electronic noise in a diode. All random functions in common use are in fact pseudo-random, which is to say that they are deterministic, but mimic the properties of a sequence of independent uniformly distributed random variables. Their essence is unpredictability. Consider for example the following sequence 13,8,1,2,11,14,7,12,13,12,17,2,11,10,3,... Jt is generated by a simple deterministic rule, but no one had guessed what the rule was or what the next number is at the time of writing. (Exercise 1.1 will give the game away, but try to guess first.) The algorithms commonly used are similar, and much mathematical analysis has gone into the question of how well they do mimic a random sequence. Only occasionally does one want independent, uniformiy distributed random variables. However, they are a useful source of randomness that can be turned into anything else. Chapters 3 and 4 consider tools to make samples of all the standard distributions and stochastic processes from this source of randomness. Simulation for us is about sampling from stochastic models. Too much emphasis has been placed in the literature on producing the samples and too little on what is done with those samples. Any stochastic simulation involves observing a random phenomenon and so is a statistical experiment. Statisticians, even experts in the design of experiments, are notoriously bad at designing their own experiments! There is even more scope for designing a simulation experiment than a real one, for the randomness and the model are under our complete control. Thus techniques for the design and analysis of simulation experiments are important tools and still an under-researched area. 1.2. MODELS A stochastic simulation is of a model, and the aims of simulation are closely connected to those of modeling. So, why model? Within the scope of sta- stistics and operations research we can usefully identify two principal 4 AIMS OF SIMULATION performed with the aid of a slide rule (a mechanical device to perform multi- plications and evaluate standard functions) and a table of random numbers. Nowadays (1984/5) desktop computers are further revolutionizing the ease of mathematical experimentation. 1.3. SIMULATION AS EXPERIMENTATION We have stressed that simulation is experimental mathematics and that simulation studies should be designed carefully, a process often termed variance reduction in this field. Their classification as experiments also has repercussions for the reporting of simulation studies. It is essential that enough details are given for the experiments to be repeated and the results checked. Hoaglin and Andrews (1975) gave some standards on reporting which seem to have been followed only exceptionally. In view of the pre- ceding warnings on the deficiencies of certain pseudo-random-number generators, it is important to report the generator used. Good design is the key to reducing the cost of the study when this is neces- sary. The cost of generating random variables and sampling from stochastic models is usually a tiny part of the cost of the study, so the main aim should be to make best use of a small number of replications. The analysis of simulation experiments also needs care, because the observations may not be independent. This can either occur deliberately as part of the design or because one is simulating a stochastic process through time. (The problems of analyzing observations of a simulated stochastic process apply equally to observing real processes, but this is done much less intensely.) Chapter 6 considers various ways to include dependence in the analysis or to select independent sets of observations. 1.4. SIMULATION IN INFERENCE Simulation has recently become popular as part of statistical inference. The advantages are again the need to make fewer approximations, although interpretation may be more difficult. Monte-Carlo tests compare the data with simulated data from the supposed model. The similarity of real and simulated data provides a test of goodness-of-fit. Bootstrap methods re- sample from the data, using the data as a reference distribution to assess the variability or bias of an estimator. Both are discussed in Chapter 7. EXAMPLES 5 1.5, EXAMPLES Checking Distribution Theory “Student” (1908) when deriving his 1 distribution carried out a small simu- lation experiment. He had 3000 physical measurements on humans which were known to be approximately normally distributed, These were shuffled and divided into 750 sets of (X,, X,, X3, X4). From each sample of size four the é statistic was calculated, giving 750 realizations to compare with the theoretical density. (This was done for each of two measurements.) We can repeat this experiment with very much less effort. Figure 1.1 shows a simple BASIC program to do so. The 750 numbers can be compared with a + distribution in any way we choose. Perhaps the simplest thing to do is to compare some moments with their population values. Each run of this program on a BBC microcomputer took 130 sec. (Appendix À gives details of the computers used in this work.) Simulation is often useful to check theoretical calculations. For example, the author was asked to check the solution to Sylvester's problem (Kendall 10 DIM X(4) 20 FOR 1%=1 TO 750 30 FOR J%=1 TO 3 STEP 2 40 U=2-RND(1)-1 50 V=2*RND(1)-1 BO W= UU + Voy 70 1F W > 1 THEN 40 80 C=SOR((-2"LN(W)) AN) 90 X(J%) = C-U 100 X(J% 41) = C*y 110 NEXT J% 140 SUM = SUM +X(J%) 150 NEXT J% 160 XBAR = SUM;4 190 SUM = SUM + (X(J%) — XBAR)” 2 200 NEXT J% 210 S=SOR(SUM/3) 220 T=SOR(4)XBAR/S 230 PRINT T 240 NEXT 1% Figure 1.1. A BASIC program to repeat Student's simulations. The function RND(1) teturns a pseudo-random number. Lines 40 to 100 code algorithm 3.9 to produce normal variates. EXAMPLES 7 Table 1,1. Results from Figure 1.2 n CNT outof Rã Time (min) 10 516 10,000 103 15 516 10.000 227 20 509 10.000 405 This experiment was run overnight on a personal computer and so was free. Nevertheless we should still consider whether we could have obtained more information from the experiment. [In fact we onty used the fact that at least one or no pairs (x, x) had n(n — Ndtx, v) < 1.907, so we could have stopped searching as soon as one was found.) Clearly we couid have checked other percentage points with the same data, Could we make use of the actual values of T? One possibility is to assume that the taíl of the distribution of T isexponential ofunknown mean 2.” !, and to estimate P(T > 1.907) =" 19074 for an estimate 2 of 2, say obtained from the observations with T > 1. Exercise 1.4 shows that this idea is worthwhile oniy in the extreme tail. Comparing Estimators Andrews et al. (1972) report a large simulation experiment that used variance reduction very effectively. Consider a location-parameter estimation problem: Estimate 0in f(x — B)lxe Rj fromxç..., x The density / is symmetric and is similar to the normal density. The idea is to find estimators that perform well across a wide class of possible densities f Some obvious estimators of 6 are the sample mean and the sample median, and a trimmed mean (the mean of all except the r largest and r smallest values). Let T(x) be such an estimator. Ail the estimators considered were location equivariant (x; > x; + « implies T> T + c) and many were scale equivariant (x; — sx; implies T > sT). Our examples are both location and scale equivariant. The key to the variance reduction was that all simulations were done for f belonging to the so-called normal/independent family. That is, / is the density of X = Z/S, where Z = N(0, 1) and S > O is independent of Z. Consider first conditioning on S, = s,,...,S, = 5, Then X, = N(O, 1/52), 8 AIMS OF SIMULATION and suitable statistics for the (X;) are X and $ where 54 - EX Ls g3 = Et — yst = n-1 Define C, = (X; — X)/S. Then for a location and scale equivariant estimator T, T(x) = X + sT(e) The point here is that T(c) is much less variable than T(x). We will assume T is unbiased, so EMT) = 8. Consider EMT-9PIC=eS=s]=»(e,s) say, so the expectation is merely over the location and scale of the sample, a 2 and S are independent, with X = N(8, 1/Es7) and (n— 1)S2 = y2.,. Thus v(e,s) = ELX — 0 + ST(OP = EX — 02 + E(X — O)ST(o) + ESYT(? where all expectations are conditional on C = c,S =s. Finally, var(T) = +TICZ ] ss and this is found by a simulation experiment as an average over many samples (X,,..., X,) ofthe random variables, Almost no more work is needed than in calculating T(X), but the estimate of var(T) obtained is much more accurate (see Table 1.2). The essence of this transformation is to average analytically over as much of the variation as possible. The assumption on / is slightly restrictive, but includes Student's t distribution as well as the Cauchy, Laplace, and con-