Springer Series in Operations Research: Springer Science+Business Media, LLC
Springer Series in Operations Research: Springer Science+Business Media, LLC
Editors:
Peter Glynn Stephen M. Robinson
Discrete-Event Simulation
Modeling, Programming, and Analysis
With 83 Illustrations
, Springer
George S. Fishman
Department of Operations Research
University of North Carolina at Chapel Hill
CB#3180
210 Smith Building
Chapel Hill, NC 27599-3180
USA
[email protected]
Series Editors:
Peter Glynn Stephen M. Robinson
Department of Operations Research Department of Industrial Engineering
Stanford University University of Wisconsin-Madison
Stanford, CA 94305 1513 University Avenue
USA Madison, WI 53706-1572
USA
9 8 7 6 5 4 3 2 1
As tools for scientific inquiry, the methodologies of discrete-event simulation have been with
us for almost 50 years. They enable us to study discrete-event dynamical systems in which de-
lay is an intrinsic feature. Examples easily come to mind in manufacturing, communications
networks, transportation, health-care delivery, and public-sector services.
The methodologies embrace modeling, programming, input-data analysis, pseudo-
random variate generation, output-data analysis, and presentation of results. These 50 years
have seen these topics evolve in content, sophistication, and, most compellingly, accessibility.
In this last regard, the mushrooming PC environment of the past 20+ years has facilitated a
relatively rapid shift of many simulation techniques from concept to practical use. Witness
the many discrete-event simulation software systems available to the would-be simulationist.
Time was when a distinct demarcation existed between modeling and programming.
One laid out the dynamic logic of a system, converted it to executable computer code, and
executed the resulting simulation program. Today, these distinctions are less apparent. Tak-
ing advantage of a highly interactive PC environment available to many, vendors market
simulation software that offers macrostatements or modules that correspond to frequently
encountered modeling constructs, These macrostatements are collections of more elemen-
tary statements in an underlying computer language. Some apply directly to delay modeling;
viii PREFACE
others apply to sampling on a computer; still others streamline data collection and report
preparation. Using these macrostatements effectively merges modeling and programming
activities into a single effort.
In many respects, these developments are welcome. They eliminate much of the
drudgery and delay in getting a simulation program to execute. However, they have draw-
backs. The macro statements cover only a subset of all the dynamic logic that may be needed
to model a system. When no macro statement represents the logic of a particular problem, a
simulationist either has to resort to programming in the underlying language to create a cor-
rect model, or has to create a kluge from existing macro statements, sometimes awkwardly,
to create an equivalence. Most regrettably, a simulationist sometimes merely changes the
model to accommodate the available macrostatements.
Virtually all simulation software systems allow a simulationist to select sampling
distributions from libraries or menus. When the desired distribution is not offered, the
simulationist's only recourse may be to a general-purpose programming language like C.
Alternatively, he/she may choose to use whatever the simulation software offers and ignore
the distribution(s) that the problem setting dictates. While offering options for customizing
reports, automatic assessment of the statistical accuracy of a simulation's output is available
in few simulation software systems.
Since students often learn about discrete-event simulation through a particular soft-
ware's modeling, sampling, analysis, and reporting capabilities, their skills for overcoming
the impediments mentioned above may be severely limited unless they are well versed in
the basic concepts of discrete-event simulation. This book supplies a means for providing
this background. It gives a relatively detailed account of the principal methodologies of
discrete-event simulation. Modeling (Chapter 2), programming (Chapter 4), output analy-
sis (Chapter 6), making sense of the output (Chapter 7), pseudorandom variate generation
(Chapters 8 and 9), and input-data analysis (Chapter 10) are all treated in depth sufficient
to acquaint a would-be simulationist with the central issues.
The book also offers an excursion into the underlying models of data collection (Chap-
ter 3), explaining why using these models leads to sample averages that approximate the values
of unknown system parameters with errors that diminish as the simulation runs for longer
and longer amounts of computing time. It also characterizes these errors when a simulation is
run, more realistically, for a finite computing time and, therefore, a finite sample-path length.
By sensitizing the reader to the presence of error prior to running a simulation program, we
hope to give her/him a better understanding of experimental design considerations, which
are so important for carrying out simulation experiments in a knowledgeable way, and on
which Chapters 4 and 6 touch.
Chapter 5 offers another excursion, this time into the topic of computing time versus
size of problem. To obtain a specified level of statistical accuracy in output sample averages,
discrete-event simulation requires computing time that tends to grow with the size of the
system under study, sometimes superlinearly. If a simulationist is to avoid an excessive
amount of computing, he/she needs to be acquainted with the principal determinants of
this growth. Chapter 5 describes how this growth occurs for several delay models.
PREFACE ix
The book is suitable for advanced undergraduates and graduate students in the man-
agement, mathematical, and physical sciences and in the engineering sciences. A background
in calculus, probability theory, and intermediate statistics is necessary. Familiarity with
stochastic processes considerably eases the study of Chapter 6. Knowledge of a program-
ming language significantly reduces the setup cost in mastering Chapter 4. The book also
serves as a ready reference for professionals who want to acquaint themselves with some
of the deeper issues of discrete-event simulation, such as estimating the accuracy of results
(Chapter 6) and the comparison of results for different scenarios (Chapter 7).
My students at the University of North Carolina at Chapel Hill have served as the test
bed for most of the material in this book. The course assigns Chapter 1 for background
reading on delay systems and as an introduction to discrete-event simulation. Detailed lec-
tures on Chapter 2, followed by selective lectures on sections in Chapter 3, and by rather
complete lectures on Chapter 4, work well to prepare students to do the exercises at the ends
of Chapters 2 and 4. In particular, Chapter 4 uses SIMSCRIPT 11.5 and Arena to illustrate
programming concepts. SIMSCRIPT 11.5 is a full-service programming language (like C)
with a comprehensive collection of macrostatements for discrete-event simulation. Arena
is a highly integrated simulation software system that in addition to providing macrostate-
ments in the SIMAN simulation language allows a user to engage menu-driven software that
performs many ancillary tasks that accompany simulation experimentation. These include
an input-data analyzer, an output-data analyzer, customized report generation, and output
graphical display. Instructors who choose simulation software other than SIMSCRIPT 11.5
or Arena can easily substitute lectures (for those on Chapter 4) on their preferred software.
However, students find intriguing a lecture on the variance-reducing technique known as
common pseudorandom numbers (Section 4.22).
Selective lecturing on Chapter 5 is an eye opener for most students. I customarily focus
on Sections 5.1 through 5.4.5. Lecturing on Chapter 6, especially on Sections 6.1 through 6.8,
with the aid of the LABATCH.2 software, available on the Internet, significantly heightens
the student's ability to assess the accuracy of results. Selective lecturing based on Sections
7.1 through 7.6.1 and, if time permits, on Sections 7.7 through 7.11, creates an awareness
among students that there is much more to output analysis and presentation that looking at
a general-purpose automatically generated report.
Lectures on Sections 8.1 through 8.6 provide the basics of random variate generation.
Examples taken from Sections 8.9 through 8.23 illustrate the concepts. For instance, Section
8.13 offers a good example ofa sophisticated algorithm that has bounded expected computing
time for Gamma sampling. I also lecture on Chapter 9, which addresses pseudorandom
number generation. I like to include Section 9.7, which describes a relatively new type of
pseudorandom number generator that ameliorates many of the limitations of the commonly
employed linear congruential generators. Although this and like generators are not now in
common use, they are a preview of things to come. Chapter 10 describes techniques for input-
data analysis. These can be covered selectively, depending on the types of data available for
classroom analysis.
X PREFACE
Four problems in the modeling exercises at the end of Chapter 2 are carried forward
through programming in Chapter 4, output analysis in Chapter 6, and comparison of results
in Chapter 7. Some problems demand more modeling and programming effort than others,
which require more effort in estimation and interpretation of results. To give students a
sense of satisfaction in solving a simulation problem from beginning to end, I customarily
choose one of the problems in Chapter 2 and assign its corresponding exercises there and
in Chapters 4, 6, and 7. Some exercises in Chapter 8 allow students to gain perspective on
the wide applicability of the methods of Sections 8.1 through 8.6. Others offer hands-on
experience in programming and executing algorithms. Those at the end of Chapter 9 offer
students an opportunity to hone their skills in analyzing pseudorandom number generators.
When I began writing the book in 1990, little did I know that such massive changes
would take place in simulation software during the following decade. I describe many of
these developments while retaining much of the well-established methodologies that have
so well served simulationists in the past. However, space considerations have inevitably led to
a selectivity that reflects my best judgment as to what a simulationist should know. The book
limits its discussion of variance-reducing techniques to those that I have found most useful in
the context of discrete-event simulation. While it addresses various aspects of experimental
design, more on this topic would be beneficial. Although important, the topics of verification
and validation have not made the cut, the rationale being that these are considerations that
apply to virtually every aspect of scientific modeling, not just discrete-event simulation.
More specialized topics, including regenerative simulation and infinitesimal perturbation
analysis, are also omitted. While of considerable conceptual interest, neither of these two
topics can claim to be an intrinsic part of discrete-event simulation as practiced today.
I am grateful to Christos Alexopoulos of Georgia Tech and Jim Henriksen of Wolverine
Software for their helpful comments on parts of the manuscript, and to Russell Cheng, Daryl
Daley, Debasis Mitra, and Les Servi for their direct or indirect help with several of the exer-
cises. Thanks also go to Pierre L'Ecuyer for his assistance in obtaining and operationalizing
software for the combined pseudorandom number generator described in Section 9.7. My
colleagues Vidyadhar Kulkarni, Scott Provan, and Sandy Stidham have all been generous
with their time and counsel, often steering me onto a much more constructive path than
I might have otherwise taken. I am most grateful to them. Thanks go to all my students
of the past decade who have subtly and, occasionally, overtly offered their comments as to
what works and what does not. Kathleen Dulaney, Betty Richmond, and Barbara Meadows
typed sections of this manuscript over the past decade. For their patience with my repeated
modifications and corrections I am again most grateful.
Errata for this book are available at http://www.or. unc.edu/ - gfish .
George S. Fishman
Chapel Hill, North Carolina
August 2000
Contents
Preface vii
1 Simulation in Perspective 1
1.1 Discrete-Event Systems . . . . . 5
1.2 Open- and Closed-Loop Systems 8
1.3 Time Averages . . . . . . . . . . 10
1.3.1 Exceedance Probabilities l3
1.4 Example: Reducing Waiting Time for Photocopying 14
1.5 Example: Increasing Throughput at an Incinerator 19
1.6 Why Discrete-Event Simulation 23
1.6.1 Detail........... 24
1.6.2 Modeling Dangers . . . . . 26
1.7 Technical Attractions of Simulation 26
1.8 Medium for Modeling . . . . . . . 27
1.9 Discrete-Event Simulation Programming Languages 29
1.9.1 Special Features . . . . . . . . 31
1.9.2 Object-Oriented Programming . . . . . . . 31
xii CONTENTS
2 Modeling Concepts 36
2.1 Next-Event Time Advance . . . . . . 39
2.2 Arithmetic and Logical Relationships 40
2.3 Event-Scheduling Approach . 41
2.3.1 Priority Order . . . . . . . . 52
2.4 Process-Interaction Approach . . . . 52
2.5 Active Processes and Passive Resources 57
2.6 Telecommunications Network Modeling 58
2.7 Lessons Learned 62
2.8 Exercises. 64
2.9 References . . . 69
ProtocolB .. . 184
Protocol C .. . 185
5.2 List Processing . 186
5.2.1 Insertion and Deletion 189
5.3 Dynamic Space Management . 190
Algorithm SPACE_FINDER . . 191
Algorithm SPACE-RELEASER . 191
Algorithm SPACE1'INDER* . 194
Algorithm SPACE_RELEASER* 195
5.3.1 Aggregating Record Classes 195
5.3.2 Resizing . . . . . . . . 196
Algorithm SPACE_FINDER** . 197
5.4 Future-Event Set . . . . . . . . 197
5.4.1 Single Linear Event List 199
Efficiency. . . . . . . . . . . . . 201
5.4.2 Multiple Linear Event Lists 201
Scheduling . . . . . . . . 201
Selecting the Next Event . 201
5.4.3 Heaps...... 203
Algorithm SIFTUP(x) . . 204
Algorithm SIFTDOWN(x) 204
Space . . . . . . . . . . . . 205
5.4.4 Henriksen's Algorithm 207
Algorithm H -L . . . . . . . . . . 208
5.4.5 Best FES Manager . . . . 209
5.5 Broadening the Class of Delay Models. 211
Capacitated Travel . . . . . . . . 211
Uncapacitated Travel. . . . . . . . . . 212
5.5.1 Variable Transit Times. . . . . 212
5.5.2 Varying Number of Tasks per Job. 214
5.6 Lessons Learned 216
5.7 Exercises. 216
5.8 References 217
• Modeling concepts for abstracting the essential features of a system into a coherent set
of precedence and mathematical relationships among its elements
• Methods for assessing how well these estimates approximate true, but unknown, system
behavior.
Modeling complex systems has become a way oflife in many fields, most especially in
the engineering, health, management, mathematical, military, social, telecommunications,
and transportation sciences. It provides a relatively low-cost way of gathering information
for decision making. Since the size and complexity of real systems in these areas rarely allow
4 CHAPTER 1. SIMULATION IN PERSPECTIVE
• Executing the code and generating output in response to one or more input scenarios,
some assigning different numerical values to system parameters and others based on
different strategies for dynamically operating the system (Chapter 4)
• Analyzing each output to infer the system behavior that each scenario induces. This
is done by assessing, by means of statistical methods, how well estimates of system
performance measures approximate their true, but unknown, values (Chapter 6)
• Comparing these inferred behaviorial patterns for the different scenarios (Chapter 7).
Knowledge of these topics is essential for an analyst who plans a discrete-event simu-
lation experiment, executes it, and wants to draw conclusions from its experimental results
that can withstand scientific scrutiny. In today's world of readily available software package
that virtually automates simulation modeling and execution, the newcomer to the method-
ology of discrete-event simulation may easily conclude that there is only one way to model
a system and one way to encode it for execution. Indeed, many courses on discrete-event
simulation focus on the features of a particular software package as the critical issues. While
this style of pedagogy may suffice for teaching students how to simulate relatively small
simple problems, it denies them the broader perspective about modeling alternatives and an
awareness of all options available to them. Chapters 2 through 4 offer the reader a broader
view of what is possible.
No methodology within discrete-event simulation has been as neglected as that for
assessing how well sample averages approximate true, but unknown, long-run time av-
erages that characterize system performance. Although some simulation software does
. provide a batch-means capability, the burden is on the user to figure out how to employ
it in a way consistent with good scientific practice. This is not easy. To reduce this bur-
den, Chapter 6 decribes implementable software, LABATCH.2, based on the batch-means
method that with minimal user effort can be applied to simulation output, either during
or after execution, to make this assessment. The software is available on the Internet at
http://www.or. unc.edu/ ---gfish!1abatch.2.html.
The book also addresses:
1.1. DISCRETE-EvENT SYSTEMS 5
• Using empirical data to estimate the values of the input parameters of a simulation
model (Chapter 10).
In practice, dramatic increases in computing time and memory requirements frequently oc-
cur when a simulation user increases the size of the system being modeled. This consequence
often puzzles users, since the cause of these increases is not apparent to them. Our account
of computational complexity provides a reader with an understanding of how these increases
can arise, thus encouraging the choice of modeling techniques that do most to control the
inevitable increase in computing time and memory.
Virtually all simulation software provides for sampling from a finite collection of
continuous and discrete probability distributions. Chapter 8 expands the options open to
the simulationist by describing methods for sampling from selected theoretical and tabled
empirical distributions. It does so with an emphasis on sampling algorithms characterized
by bounded-mean computing times, regardless of the values assigned to the parameters of the
distribution. It also describes algorithms for a wider range of theoretical distributions than
most simulation software offers.
All simulation sampling on computers relies on a source of pseudorandom numbers.
Chapter 9 gives a concise description of the method of generating these numbers found in
most simulation software, the properties of these numbers, and procedures for generating
pseudorandom numbers with improved properties.
Before a simulation experiment can be executed, numerical values must be assigned
to its input parameters. These values come from either expert judgment or the analysis of
empirical data. Chapter 10 provides a concise account of the most essential details of this
data analysis for several environments that arise in simulation modeling.
0 .... ·
•
Figure 1.1 Bus model
The first two descriptors are discrete, whereas bus location is continuous on the circuit
shown in Figure 1.1. However, the number of passengers on the bus can change only when
the bus location assumes one of the five values that uniquely identify the stops. Moreover,
the number waiting at a stop can change only when the bus arrives there or when a new
individual comes to the stop.
Clearly, the sequences of bus arrival times and individual arrival times, together with
bus capacity, determine how many passengers wait at each stop and bus occupancy at each
moment in time. They also determine how long each individual waits for the bus.
Manufacturing plants, inventory systems, distribution systems, communications
networks, transportation networks, health-care delivery systems, as well as many other en-
vironments are amenable to modeling as discrete-event systems. Virtually all measure their
performance in terms of delay, number waiting, throughput, and resource utilization.
Delay denotes time spent waiting for resources. Buffer occupancy denotes number of
items, jobs, or individuals waiting for resources. Number of finished units emerging from
'the system per unit time characterizes throughput, and proportion of time that resources are
busy relative to total time describes resource utilization.
As examples, throughput in a manufacturing setting denotes the number of finished
goods that a factory produces per unit of time, In a telecommunication network, the rate
at which messages pass from sender to receiver constitutes a measure of throughout. The
1.1. DISCRETE-EvENT SYSTEMS 7
number of vehicles that cross a bridge per unit time characterizes throughput in a particular
type of transportation system.
Buffer occupancy denotes the number of items in the system awaiting processing or
service and is sometimes called queue length. Delay denotes the time that these items wait
and alternatively is called waiting time.
Occasionally, system loss rate is an additional performance descriptor. It measures
the rate at which objects leave a system, without successfully completing their purposes,
when they encounter delays exceeding specified tolerances. For example, work-in-process
within a manufacturing system may lose value unless delays between successive steps in the
production process are kept within specific limits. This deterioration, which often arises
because of the properties of materials and the production process, occurs in some forms of
semiconductor wafer fabrication.
In the bus example, passenger waiting times describe delay, number waiting at each
station describes queue length, number of completed passenger trips per unit time describes
throughput, and the ratio oftime-average seat occupancy and seat capacity describes resource
utilization. In this case, the buffer or waiting room at each stop has infinite capacity. However,
in many systems the buffer is finite, thus requiring the modeler to specify explicit rules
for what to do when an arrival occurs to an already-full buffer. More generically, every
discrete-event system embodies at least seven concepts:
• Work
• Resources
• Routing
• Buffers
• Scheduling
• Sequencing
• Performance.
Work denotes the items, jobs, customers, etc. that enter the system seeking service.
Would-be passengers are the work in the bus example. Resources include equipment, con-
veyances, and manpower that can provide the services, for example, the bus in Figure 1.1.
Associated with each unit or batch of work is a route delineating the collection of required
services, the resources that are to provide them, and the order in which the services are to
be performed. For the bus illustration, each passenger uses the bus to move from the stop at
which the passenger gets on to the stop at which he/she gets off.
Buffers are waiting rooms that hold work awaiting service. They may have infinite
capacity, as in the bus example, or may have finite capacity, as occurs at the retransmission
nodes (resources) in a telecommunication network that transmits packets of information.
8· CHAPTER 1. SIMULATION IN PERSPECTIVE
When buffers have finite capacity, explicit rules must be adopted that account for what
happens to arriving work that finds a buffer full.
Scheduling denotes the pattern of availability of resources. For example, suppose there
are two buses in Figure 1.1 and operating costs suggest that both buses be used only during
daily periods of high demand. A schedule would consist of the times at which each bus is to
provide service, taking into consideration time out for maintenance and cleaning.
Sequencing denotes the order in which resources provide services to their waiting work.
It may be in first -come-first -served order; it may be dictated by the amount of work awaiting
the resource or other resources from which it receives or transmits work. Sometimes the rule
for sequencing is called the queueing discipline.
arriVa1--Jl---.~81--------~.81-----------". departure
OJ
arriva1------I~ ~---------~departure
OJ,
departure
arriVal---.----1.~c:f)I-----1.~el-----I.~el-----1.~A/--P--~. departure
Jl fL _________co_ _ _ _ _ _ _ _ _ _ _ _y----'l-p
f---.----~departure
arrival
OJ,
(e) multiple service routes
successful. Figure 1.2e exemplifies a system in which the a proportion q of the arrivals
requires service at stations 1 and 2 and the remaining proportion 1 - q requires service at
stations 1 and 3.
This is merely a microcosm of the many variations that can arise in a service environ-
ment in which each arrival comes equipped with a route through the system that indicates the
10 CHAPTER 1. SIMULATION IN PERSPECTIVE
services it requires, each server selects items for service according to its queueing discipline,
and there exists a schedule giving the time intervals during which each server is available to
do work.
Control over work arrival times distinguishes dosed-loop from open-loop systems.
Figure 1.3 illustrates the dosed-loop concept. A new item arrives for service at the moment
the server completes processing its old work. By enforcing this policy, the system manager
keeps throughput and resource utilization high and queue length and waiting time low. In
particular, queue length and waiting time are necessarily zero in this illustration.
Closed-loop systems characterize many manufacturing, transportation, and telecom-
munications systems with controlled access. In addition to choosing routing, sequencing,
and scheduling policies, the ability to control admission based on the state of the system offers
system managers a valuable tool for high throughput and resource utilization and low system
occupancy and delay. This motivates the study of admission policies presumably designed
to accomplish these objectives. From time to time, we return to this distinction between
open-loop and dosed-loop systems to emphasize the implications of each for discrete-event
simulation.
As mentioned earlier, queue length, waiting time, throughput, and resource utilization all
relate to system performance. To be useful concepts for decision making, we need a way
of summarizing what the output of a simulation run tells us about these phenomena.
Time averages provide a basis for doing this, as we illustrate for the single-server model
in Figure 1.2a.
Assume that the buffer in Figure 1.2a has infinite capacity and arriving items have
infinite patience. For t > s ::: 0 let
arrival departure
and
Suppose that a simulation is run over a time interval (0, t 1and that these phenomena
are observed over the interval (s, t 1, s being a warm-up interval that reduces the influence
of the starting conditions on the behavior ofthe phenomena over (s, tl (Section 6.1) Then
the system has sample average arrival rate
- A(s,t)
A(s, t) := - - ,
t-s
average throughput
-( )._N(s,t)
N s,t .- - - - ,
t-s
Q(s, t) := -
t -
1
s
[t
s
Q(u)du, (1.2)
R(s, t):= -
1 [t B(u)du, (1.3)
t- s s
_ 1
L
N(O,t)
W(s, t) = - - Wi. (1.4)
N(s, t) i=N(O,s)+l
12 CHAPTER 1. SIMULATION IN PERSPECTIVE
If the pattern of arrivals is deterministic at rate A and each item has processing time
I/w, then the system in Figure 1.2a is said to be deterministic and ..1(s, t) ~ A, where
notation "a(t) ~ bas t ~ 00" means that "a(t) converges to b as t grows without bound:'
Moreover, the limiting behaviors of Q(s, t), B(s, t), and W(s, t) depend on A and w. In
particular, as t ~ 00
I
N(s, t) ~ A
Q(s, t) ~ 0
if A < W
B(s, t) ~ Alw
W(s, t) ~ 0
and (1.5)
I
N(s, t) ~ W
Q(s, t) ~ 00
if A> W.
B(s,t) ~ 1
W(s, t) ~ 00
If interarrival times, service times, or both are random and have finite first and second
moments, then the limits (1.5) continue to hold as t ~ 00 with probability one, which
we denote by w.p.1. This characterization merely emphasizes that the limit is attained in
accordance with rules that acknowledge the random behavior inherent in the system.
The condition A < W is necessary for stability, and every queueing system must meet an
analogous condition to keep queue length and waiting time from growing without bound as
time elapses. For example, the multiserver system in Figure 1.2b requires A < WI + ... + Wr>
whereas the k-station system of Figure 1.2c requires A < min(wI' ... , Wk). Since the tester
in Figure I.2d induces total mean service time 1I W + (1 - p) I W + (1 - p)2 I W + ... , the
stability requirement is A < wp, whereas the dual route environment in Figure 1.2e requires
A < WI> qA < W2, and (1 - q)A < W3; or equivalently A <min [WI, wz/q, w3/(1 - q)].
A more general characterization of the systems in Figures I.2a and I.2c reveals the
central role that stability plays in performance. Consider a k-station series system with mi
servers each operating at rate Wi at station i for i = 1, ... , k, and arrival rate A. Let
and assume random interarrival and service times. Then under relatively mild conditions as
t ~ 00, throughput behaves as
whereas sample average queue length (number in system waiting for service) and waiting
time (system delay time) behave as
_ 0(-) if P < 1,
Q(s,f)-+ { I
ooI-P w.p.I,
if P > 1,
and
_ 0(-) if P < 1,
W(s,f)-+ { I
ooI-P w.p.I,
if P > 1,
where the notation O(u(z)) denotes a function {v(z)} for which there exist constants c > 0
and Zo such that v(z) :::: cu(z) for all z 2: zoo
Recall that in an open-loop system items arrive at a rate A (> 0) independent of the
number of items in the system awaiting or receiving service and independent of the status of
all resources. The arrivals may be deterministic; for example, occurring in batches of fixed
size n at times 1/ A, 2/ A, 3/ A, .... Alternatively, they may occur randomly in time with mean
interarrival time 1/ A and random batch size. By contrast, the workload and its distribution
among buffers and servers in a closed-loop system feed into an action space that determines
the arrival pattern.
where FQ and Fw are distribution functions (d.f.s). For example, pr[Q(t) > 0] denotes
the probability that at an arbitrarily selected time f at least one item is waiting for service,
and pr(Wi > 0) denotes the probability that an arbitrarily chosen customer i must wait.
Whereas means characterize central tendency, exceedance probabilities shed light on extreme
behavior, especially as q and w increase.
Suppose that a simulation is run for the time interval (0, fl. Then the sample time
averages
PQ(q, S, t) := - -
1
t - s
[t
s
I(q,oo)(Q(u))du, q > 0, (1.6)
14 CHAPTER 1. SIMULATION IN PERSPECTIVE
and
1
L
N(O,t)
Pw(w, s, t) := - - I(w,oo)(Wi ), w > 0, (1.7)
N(s, t) i=N(O,s)+l
denote the proportion of time (s, t 1that the queue has more than q items and the proportion
of customers who begin service in (s, t 1that wait more than w time units.
Under relatively widely applicable conditions, for fixed s
for each w ~ O. Sections 3.4 and 3.5 discuss these limits in more detail and consider them
when a simulation is run until a fixed number of items enter service. The photocopier
problem in the next section illustrates the use of means and exceedance probabilities.
We next describe several contexts in which simulation is an invaluable aid to discovery,
thus allowing the reader to study the methods in this book with a heightened awareness of
their potential value.
Floor 1
Floor 2
Copiers are also subject to breakdowns requiring repair. When this occurs, the HSL
calls a service that dispatches a repairperson. The concomitant loss of operating time is
known to be a principal contributor to customer delay.
The purpose of studying this system was to evaluate the extent to which modifications
to the operation of this photocopying system could reduce waiting time. A discrete-event
simulation was developed to study the problem (Tzenova 1999). Simulation experiments
were run under several different scenarios, including:
• Replacing old copiers that require frequent repair with new copiers
• Adding new copiers to selected floors
• Moving copiers among floors to be more responsive to the demand pattern
• Each of the above with a 50 percent increase in customer arrivals.
Statistical tests applied to library data revealed significant differences at the 5% level
in arrival rates by floor, time of day, and day of week. Table 1.1 shows a partition into six
groups that captured these differences. Since data limitations prevented a detailed analysis
for the basement and floors 1,2, and 5, they were treated individually as groups 7 through
16 CHAPTER 1. SIMULATION IN PERSPECTIVE
10. Since these arrival rates were notably smaller than those for groups 1 through 6, this
aggregation had no more than a negligible effect on simulation output.
For each scenario, differences in arrival rates by time ofday and day ofweek necessitated
four sets of runs to be executed; namely (off-peak hours, Tuesday), (peak hours, Tuesday),
(off-peak hours, all but Tuesday), and (peak hours, all but Tuesday). For each, sample path
data were collected for 1000 simulated five-day weeks. Omitting data collection during the
warm-up interval reduced the influence of the arbitrarily selected initial conditions in each
simulation run (Section 6.1).
The data were used to estimate:
• Probability of waiting
• Probability of an arriving customer not waiting for service when copiers are busy
plus additional performance measures. The three exceedance probabilities provide a picture
of extreme behavior, whereas the mean reveals central tendency. Figure 1.5a shows point
estimates and approximate 99% confidence intervals for the mean for each group for the
library's current operating policy. The study used the ratio-estimation methodology of Sec-
tion 6.11 with the LABATCH.2 statistical package in Section 6.7 to derive the confidence
intervals. This ratio approach was necessitated by the need to account for random variation
in the number of arrivals in a simulation run for a fixed number of days (Section 3.4). Figure
l.5b displays the corresponding point estimates of the exceedance probabilities.
1.4. EXAMPLE: REDUCING WAITING TIME FOR PHOTOCOPYING 17
6 .50
6.00
III
Q)
1il 5 .50
E
~
Q)
(ij
~
5.00
Q)
~
~
0
0> 4 .50
0>
'0
c:
<0
C 4.00
'0
a..
3.50
3.00
2 3 4 5 6 7 8 9 10
Group number
0.80
II pr(wait>O) _ pr(wait>5) 0 pr(not served)
0.60
c:
0
1:
0
a. 0.40
e
a..
0.20
0.00
2 3 4 5 6 7 8 9 10
Group number
350
2'"
ClI
.§ 300
iii
Q)
tij
2:
.s
Q)
250
<I-
0>
0>
"C
<:
I
E'" 200
'0
CI...
150
100
2 3 4 5 6 7 8 9 10
Group number
040
<:000
o
1:
o
Co
e
CI... 020
010
000
2 3 4 5 6 7 8 9 10
Group n umber
Among all scenarios considered, scenario 11, which replaced the four photocopiers
with the highest failure rate, led to the most substantial reductions in waiting time. These
were on the busiest floors, 3 and 4, which comprise Groups 1 through 6. Figure 1.6a shows
the means, and Figure 1.6b, the exceedance probabilities. In particular, note that for a given
group the corresponding confidence intervals in Figures l.5a and 1.6a do not overlap, offering
support to the contention that the difference in means is real. Also, note the reduction in
exceedance probabilities, especially for the two busiest floors 3 and 4. While the differences
are to be expected when new equipment replaces old, the real improvement on floors other
than 3 and 4 in Groups 7 through 11 shows the benefit to customers on these floors as well.
These and other alternatives need to be evaluated with regard to the benefit each offers
for the cost of the additional resources they require. Sections 6.11 and 7.6 return to this
example.
availability of storage space at the four sites. Collectively, the four sites have space to store up
to 300 drums, and the ESF has space for 11 drums. As a consequence, waste can be stored on
the campuses only if space is available. Hereafter, we refer to a drum handled by an outside
contractor as lost.
Disposing of waste by outside contractor is considerably more expensive per drum
than disposal at the incinerator complex. Although the need for outside contracting rarely
occurs at the current waste generation rate, this rate is expected to increase in the future. In
anticipation of this growth, the company requested a study to:
• Estimate the volume ofoutside contracting to expect as the amount ofwaste generation
grows in the future
A discrete-event simulation experiment (Ma 1999) was developed and executed for
selected annual waste-generation growth rates. Of particular interest for each growth rate
was It := mean annual number oflost drums. In the notation of Section 1.3, let
4 4
D(s, t):= LAi(s, t) - L Qi(t) - Q'(t) - N(s, t),
i=1 i=1
1 1 '
[I,(r) := -D(s, s + r) = - L D(s +j - 1, s + j),
r r j=1
where data collection begins at year s, thereby diluting the influence of initial conditions
in the simulation (Section 6.1) on the sample-path data. The summation partitions the
sample-path data into increments that serve as the basis for a statistical analysis to assess
how well [1,( r) approximates the unknown It (Section 6.6).
Table 1.2 shows [I,(r) for selected growth rates a. To assess the statistical error in
approximating It(r) by p,(r) due to randomness in drum generation in the simulation, a
1 .5. EXAMPLE: INCREASING THROUGHPUT AT AN INCINERATOR 21
statistical analysis using LABATCH.2 (Section 6.7) gave the approximating .99 confidence
intervals for j.L. That is, fl( T) is a point estimate for j.L, and [L, Uj covers j.L with approximate
probability .99. The difference U - L measures the absolute accuracy of fl(T), and (U -
L)/ fl(T) its relative accuracy. For example, a = .14has (U - L)/ fl(T) = .05, indicating that
the length of the interval is 5% of the sample mean. This suggests a relatively high level of
accuracy. Only a = .06 has a relatively inaccurate point estimate, but the absolute accuracy
measure U - L is tolerable for present purposes.
Figure 1.7 plots the sample mean fl := fl( T) versus a. The graph shows a straight line
as computed by least-squares regression analysis. If 50 lost drums per year were a crucial
number, then the regression line reveals that an annual growth rate of
50 + 19.46
a = 279.9
= 0.248
22 CHAPTER 1. SIMULATION IN PERSPECTIVE
160
140
toCD
>- 120
~
0. __ mean= 19.46+279.9a
rn
E 100 a>.07
2
'C
'lii 80
..Q
'0
~ 60
J:J
E
:::l
I::
as 40
I::
CD
:::1!
20
0
0.1 0.2 0.3 0.4 0.5 0.6 0.7
Growth rate (a)
Figure 1.7 Mean number oflost drums per year vs. waste-generation growth rate
would generate that amount on average in one year. More generally, let
ln1.07
/L(a, t) = -19.46 + 279.9[(1 + a)t - 1], t > lnO + a) , a > 0, (1.9)
To effect this policy, the samples had to be taken from the individual drums at the sites
rather than from a vat at the incinerator after the contents of the drums had been pumped
in. This was deemed worth the effort to eliminate the time delay at the ESF due to waste
remaining in a vat until the results of its assay were available.
7. Permits control over more sources of variation than direct study of a system allows
Except in relatively simple cases, the values of system performance descriptors are un-
known, and determining then remains beyond the capacity of the analytical tools of queueing
24 CHAPTER 1. SIMULATION IN PERSPECTIVE
theory. Discrete-event simulation offers techniques that can approximate the values of these
descriptors to within a remarkably small error. The approximations come from analyses of
data observed on sample paths generated during execution of a simulation program corre-
sponding to the model of interest, usually on a queue-length process {Q(z), s < z < t}
and on a waiting-time process {WN(O,s)+l, .•. , WN(o,t)+d (Section 1.3). This book describes
many of these methods in detail.
Often one creates and executes a simulation of a complex system simply to study
alternatives. How does the system respond to a change in input parameter values? How does
it respond to a change in routing, sequencing, or scheduling rules? Simulation-generated
data often can provide sufficiently accurate answers to these questions, thereby enabling an
investigator to sharpen her/his understanding of the system. Occasionally, interest focuses
on the selection of one of several system configurations that leads to the best performance
with regard to explicitly stated criteria. Carefully constructed and executed simulations of
each system alternative can provide the sample data on which one can apply well-established
statistical tests to detect superior performance (Sections 7.2, 7.5, and 7.6).
Another context in which the benefits of simulation are considerable is in the devel-
opment of optimal or near-optimal policies for system management. This area involves a
partnership between simulation and analytical methods. In many situations one constructs
an analytical model of a system in order to determine an optimal policy, with regard to a
specified criterion, for managing the system. However, the need to simplify the representa-
tion to obtain an analytical solution often removes from the model critical characteristics of
the system that may affect performance. Here, the analyst who has found an optimal policy
for the simplified analytical model ponders the extent to which the policy remains optimal
in the presence of the features suppressed for analytical convenience. Discrete-event simu-
lation can playa vital role in resolving this issue. It enables one to build a (more realistic)
simulation model containing the features in question, first execute it using the analytically
based optimal policy, and then execute it using other management policies that institutional
considerations may suggest. Comparing the simulation results for the different policies en-
ables the simulationist to determine the degree to which the optimal policy prevails over the
institutionally based policies in the more realistic simulation. This joint use of analytical and
simulation methods considerably enhances the value of both methods.
1.6.1 DETAIL
detail offers greater opportunities for studying system response when structural relation-
ships within the model are altered. First, more combinations of structural change can be
considered, and second, more aspects of the response can be studied.
On the other hand, detail generally impedes problem solution. Added detail often
shifts the method for solving a problem from an analytical to a numerical one, thereby
giving up the generality that an analytical solution offers. Detail also increases the cost of
solution. However, the most limiting factor in the use of detail is that we rarely know enough
about the system under study to specify more than a modicum of its characteristics. Every
model must limit detail in some respect. To fill in a system description in place of detail,
one makes assumptions about system behavior. Since one does not want these assumptions
to conflict with the observable behavior of the system, testing them against observation is
desirable whenever possible.
Our earlier remarks stressed the fact that the amount of detail in a model is generally
inversely related to our ability to obtain an analytical solution. However, if the minimal model,
which contains the least detail needed for useful study, is not amenable to analytical solution
and we adopt an approach based on discrete-event simulation, we have the prerogative of
building as much detail into our model as we like without concerning ourselves about the
absence of an analytical solution. It is precisely this descriptive ability that holds the most
attraction for modelers, for the greater the amount of detail, the more realistic the model is
and consequently the closer they expect the results of a simulation run to conform to reality.
However, practice indicates that judicious restraint in regard to detail is often the better
policy. At least three reasons support this assertion:
• To include detail we must devote effort and time to preliminary observation of the
individual characteristics of the system under scrutiny. These actions induce a cost, the
justification for which a modeler has to weigh with respect to her/his objective. This
issue arises in most simulations, and no universal course of action fits all contingencies.
• Additional detail requires more programming, especially for the contingencies that
detail specifies. Moreover, the inclusion of great detail at the outset of a modeling
effort makes the job oflocating the sources of error in the resulting computer program
especially difficult because of the many potential trouble spots.
These sobering remarks provide a useful perspective for evaluating the degree of detail
worth having. Often, a simulationist gets a limited model running first and then introduces
detail where this model provides inadequate answers. This bootstrapping approach makes
26 CHAPTER 1. SIMULATION IN PERSPECTIVE
for a more judicious allocation of a modeler's time and effort and reduces debugging and
computing times and memory requirements.
Although modeling clarifies many relationships in a system, there are at least two
warnings that an investigator should always keep in mind. First, no guarantee exists that the
time and effort devoted to modeling will return a useful result. Occasionally, failure occurs
because the level of resources is too low. More often, however, the simulationist has relied
more on the simulation language and its tools and not enough on ingenuity when the proper
balance between both is the recipe that enhances the probability of success.
The second warning concerns the use of the model to predict beyond its range of
applicability without proper qualification. Being an abstraction, a model inevitably produces
numbers that serve as approximations to the true values of unknown performance measures.
Do these numbers have a tendency to overstate or understate the true values? How close are
the generated values to the true values? Good modeling analysis demands answers to both
these questions. For example, the .99 confidence intervals in Table 1.2 attest to the sample
means (point estimates) being good approximations to the unknown mean number oflost
drums. Most importantly, the answers demarcate the range of applicability of model output.
Neglecting to provide this qualification constitutes one major cause of model misuse in
practice. Chapter 6 addresses the issue of statistical accuracy.
IThe term computer simulation should not be confused with a simulation study of a computer
system. Such studies have become major users of computer simulation.
1 .8 . ME DIU M FOR MOD ELI N G 27
Modeling a system inevitably relies upon some medium to connect the realities of the system
into a collection of abstractions amenable to manipulation for purposes of solution. In
28 CHAPTER 1. SIMULATION IN PERSPECTIVE
physics, partial differential equations are the abstractions that result from applying the
infinitesimal calculus as the medium. Difference equations are often the abstractions that
result from employing the calculus of finite differences to model a dynamical economic
system.
Discrete-event delay systems are also amenable to abstraction using these two media,
and indeed, the analytical derivation of queue-length, waiting time, and resource-utilization
distributions relies crucially on them. As illustration, consider a single-server queueing
system, as in Figure 1.2a, with interarrival times AI, A z, ... and service times B I , B z, ....
Let Wi denote the waiting time in queue for arrival i and suppose the first arrival finds
the queue empty and the server idle. Then it is easily seen that for a first-come-first-served
queueing discipline,
WI = 0,
Wz = (BI - A z)+,
W3 = (Wz + Bz - A3)+,
where
if x :::: 0,
otherwise.
Known as Lindley's formula, this notation incorporates the calculus of finite differences
with one boundary constraint. In principle, this calculus can be used to model a system
with m servers in parallel at a single station but with multiple boundary constraints that
grow exponentially in number with m. Moreover, other queueing disciplines demand more
complicated notation.
Recognizing the limitations of this approach to modeling discrete-event dynamical
systems and aware of the need to adopt modeling conventions that could be easily converted
into executable computer code, early simulation methodologists devised two paradigms for
abstracting these systems. The event-scheduling approach focuses on the moments in time
when state changes occur (Section 2.3). The process-interaction approach focuses on the flow
of each entity through the system (Section 2.4). Both allow for variable updating and flow-
branching, characteristics that epitomize discrete-event delay systems. Both allow a modeler
to create a collection of flowcharts that incorporate all system dynamics needed to write a
simulation program conveniently.
In practice, experienced simulation users rarely turn to explicit flowcharting when
modeling a system. More often, they rely on the constructs available to them within the sim-
ulation programming packages they employ. These constructs implicitly embrace either the
1 .9 . DIs eRE TE - EVE N T S I M U LA T ION PRO G RAM MIN G LAN G U AGE S 29
event-scheduling or process-interaction approach, more often the latter than the former.
Although skipping the flowcharting step saves considerable time for a modeler, the new-
comer to discrete-event simulation cannot possibly develop an appreciation of the options
available to her/him for modeling delay systems by totally omitting a study of the principles
of the event-scheduling and process-interaction approaches. Familiarity with these options
is critical in modeling large complex systems. Indeed, total reliance on language constructs
can occasionally keep the modeler from seeing the simplest way to account for behavior.
Chapter 2 describes these principles in detail.
• Generating reports
adds to a language's appeal, although some languages that provide less than this capability
have managed to survive and prosper.
In today's PC environment, many simulation languages have become embedded in
larger software systems with enhanced features that include the capabilities to:
• Draw icons including all standard CAD objects such as rectangles and ellipses
• Integrate database systems that comply with the Microsoft ODBC standard such as
Dbase, Access, Fox Pro, and Excel
• Allow user-coded inserts in other computer languages such as Visual Basic, C, and
C++.
• Use menus associated with each icon to assign numerical values to parameters
The availability of PC-based simulation systems that provide all or most of these conveniences
has significantly reduced the time and effort for the newcomer to discrete-event simulation
to create an executing program.
In practice, code reuse plays a central role in establishing a workable balance between
programming effort and computational effciency. If a large-scale simulation program is to
be developed and then executed many times, merely with different numerical input, the
investment in programming effort to achieve highly efficient code can be negligible when
amortized over the useful lifetime of the program. By contrast, a study that requires a se-
quence of simulation programs that successively differ in logic in relatively small ways may
call for so much programming effort at each stage using a conventional simulation language
as to discourage one from carrying out the full investigation. In this environment, keeping
programming effort within an acceptable bound becomes the overriding objective. In the
current world of highly interactive computing, this second modality has grown in relative
importance and led to an emphasis on point-click-drag-drop programming in conjunc-
tion with object-oriented programming. Indeed, this concept underlies the icon/menu-driven
environment so commonplace on PCs and workstations.
An object essentially denotes a collection of data structures for storing critical data.
For example, in a network model a message is an object with length, priority, origin, and
destination. In manufacturing, a part is an object whose data include a route identifying
the sequence of processing stations it visits on the way to completion. The data also include
processing times and priorities for service at the stations. Each class of objects is associated
with functions or algorithms that contain recipes for operating on the data stored in instances
32 CHAPTER 1. SIMULATION IN PERSPECTIVE
of the objects. An airport simulation clarifies the meanings of class, object, instance, and
function.
Aircraft form a class, and particular types of aircraft are objects. An individual aircraft
denotes an instance of a particular type (object) of aircraft within the class of aircraft.
Associated with these are the functions oflanding an aircraft, taxiing on a runway, loading
an aircraft with cargo, unloading cargo from an aircraft, loading passengers onto an aircraft,
unloading passengers from an aircraft, refueling an aircraft, and aircraft takeoff. In principle,
programs created to represent the class called aircraft and to compute the functions of
landing, loading, unloading, refueling, and takeoff can be used in many different scenarios
of airport simulation. For example, one simulation may study congestion at an airport
dedicated exclusively to passenger traffic, while another may study capacity limitations at an
air-cargo terminal. Both simulations would use the aircraft class but with different mixes of
types and different utilization of functions.
Ease of programming and program reuse provide the principal motivations for adopt-
ing an object-oriented approach to discrete-event simulation. This is especially true in an
environment where an iconized collection of preprogrammed modules allows a simulation-
ist to construct a simulation model on the monitor's screen with relatively little knowledge
of the components of each module. If results obtained from executing the simulation en-
courage the analyst to consider an amended simulation program, the point, click, drag, and
drop capacities facilitate this modification by assembling a new program on-screen made up
of parts of the old program and new modules taken from the collection of preprogrammed
modules in the displayed collection of icons.
As examples, AutoMod, ProMod, and WITNESS employ objected-oriented pro-
gramming within their modules for manufacturing and materials handling. MedModel
(PROMODEL Corporation) uses object-oriented programming to create its modules within
a health-care delivery system. Other simulation software products use a semblance of the
object-oriented programming approach when constructing conveyors, etc.; but in reality
they do not entirely adhere to the formal rules for this approach to programming. For busi-
ness applications, Technology Economics, Incorporated offers FlowModel, which contains
a preprogrammed collection of business-oriented objects and functions.
This capacity for program reuse and reduced programming effort has limitations.
If the menu of preprogrammed objects and functions does not provide for a particular
application, then either simulating the application cannot be done using this collection, or
else programming is required to effect the simulation. Sometimes this last option results in
relatively awkward use of objects and functions for which they were not originally intended.
To provide a more global setting, CACI offers an object-oriented simulation language called
MODSIM III that allows a user to program her/his own objects and functions.
To regard the term "object" as merely data and a function as merely another word for
subroutine would be an oversimplication. Whereas a subroutine may use global as well as
local data structures for computation, an object must have all its required data stored within
its own local data structure, and a function in an object-oriented environment operates on
these local data. This distinction clearly makes an object and a function less dependent on
1 .9 . DIs eRE TE - EVE N T S I M U L A T ION PRO G RAM MIN G LAN G U AGE 5 33
the overall problem than a subroutine would be, and this offers a considerable advantage in
making changes.
Customarily, a program consists of objects linked together by well-defined connections
(which are themselves objects). Each object is compiled separately, with the underlying sim-
ulation language lurking in the background and usually out of the simulator's consciousness.
When a program requires change, only those objects and connections affected by the change
need to be recompiled. If one thinks of compilation as a process of optimization with regard
to computational efficiency, then this procedure of selective recompilation (suboptimiza-
tion) inevitably results in reduced run-time effciencywhen compared to a globally compiled
(optimized) program. Also, a program consisting of objects requires more space for data
structures than a more traditionally written program would. Nevertheless, proponents of
the object-oriented approach to simulation regard the programming convenience that it
offers as outweighing the penalties incurred by increased space requirements and reduced
computational efficiency.
The concept of object-oriented programming is not new to simulation. SIMULA
(Birtwistle et al. 1973), one of the first simulation programming languages, used the concept.
Moreover, the property of inheritability of attributes, an intrinsic feature of object-oriented
programming, has been a feature of GPSS from its beginning as an IBM programming
product. In particular (e.g., Schriber 1991, p. 368), the SPLIT statement in GPSS creates
a specified number of copies of a process and endows each with the data structures and
functions in the original process. However, each copy executes independently of all remaining
copies. In this way a batch of identical parts entering a job shop can be SPLIT for processing
and later reassembled into a batch using the ASSEMBLE statement of GPSS. The SPLIT
statement allows the spawned instances of the object to be numbered sequentially, if desired,
for easy identification.
Virtually all object-oriented simulation programming languages translate their state-
ments, into C++ statements, which are then compiled into executable code. C++ is an
enhancement of the C programming language endowed with a syntax for object-oriented
programming.
At present, every simulation software product is of one of two forms. Either it embraces
the traditional sequential programming approach reminiscent of FORTRAN and C or it
embraces the object-oriented paradigm as in C++ and JAVA. As to whether this coexistence
will continue or one of these formats will come to dominate remains for the future to reveal.
The Internet has created opportunities for new modes of modeling, programming, and
executing discrete-event simulation. Modules created in the JAVA programming language,
using its object-oriented programming features, reside at accessible websites. Modelers
browse these sites and retrieve off-the-shelf modules that appear to fit the problem at hand.
All this presumes that the browser is using a JAVA-based discrete-event simulation language
possessing all the features delineated in Section 1.9 and that the off-the-shelf modules meet
34 CHAPTER 1. SIMULATION IN PERSPECTIVE
a universally accepted standard that allows their incorporation, without incident, into the
browser's program.
More ambitious modes of web-based simulation are also possible. For example, under
certain conditions, a simulationist could run a web-based simulation program t times in
parallel to generate sample paths for independent replications by distributing the workload
over t distinct computing platforms. Conceptually, this approach reduces elapsed clock time
to obtain results by a factor of t. Alternatively, a web-based simulation program can be used
simultaneously by many users. See Whitman et al. (1998).
1.9.4 NO PROGRAMMING
To make their products less intimidating and thus more appealing to a wider range of
potential users, some vendors have introduced simulation software that attempts to mini-
mize or, if possible, to eliminate user-originated programming. The products encourage a
simulationist to point and click on icons, corresponding to precoded constructs available in
an on-screen template and to drag and drop these constructs into the simulation program
being created, thus reducing the user's time and effort spent programming. The modules
discussed in the last several sections exemplify these precoded blocks.
While noble in concept, the practice has limitations. Most notably, prebuilt constructs
often represent specific environments that are difficult to modify in order to accommodate
the problem at hand. Indeed, it may not be apparent to the simulationist that a misrepre-
sentation of problem logic is about to occur when inserting a prebuilt module into her/his
program. For example, see Section 4.28.
Every introductory course in discrete-event simulation seeks to turn out students ca-
pable of performing discrete-event simulation experiments. Inevitably, this must include the
capability to create and execute programs. However, the programming skill level is prob-
lematical. Catering to the little-or-no programming philosophy tends to produce students
whose knowledge is restricted to the software to which they have been exposed and possibly
to a narrow subset of problems encountered within discrete-event simulation.
A considerably more desirable outcome for the course is to equip each student with
the knowledge of how to model a system and translate the model into executable code in at
least one language and, at the same time, to familiarize them with the breadth and depth
of concepts that they are likely to encounter when asked to work in a language other that
those taught in the course. This book embraces this strategy. While it does offer examples
in particular languages in Chapter 4, our account works best when the instructor uses it in
parallel with an adopted relatively comprehensive discrete-event simulation language such
as GPSS/H, SIMAN, SIMSCRIPT II.s, SLAM, or SLX. It works less well when used with
special-purpose simulation languages that encourage minimal programming.
1 .1 O. REF ERE NeE s 35
1.1 0 REFERENCES
Birtwistle, G., OJ Dahl, B. Myhraug, and K. Nygaard (1973) SIMULA BEGIN, Auerbach,
Philadelphia.
Ma, Xudong (1999). Managing the hazardous liquid waste input to Glaxo Wellcome's
environmental safety facility incinerator, OR350 project, Operations Research
Department, University of North Carolina, Chapel Hill.
Schriber, T.J. (1991). An Introduction To Simulation Using GPSSIH, Wiley, New York.
Swain, J.J. (1999). 1999 Simulation software survey, ORMS Today, 26, 38-51
Tzenova, E. (1999). An analysis of operations for the health sciences library photocopier ser-
vice, OR350 project, Operations Research Department, University of North Carolina,
Chapel Hill.
Whitman, 1., B. Huff, and S. Palaniswamy (1998). Commercial simulation over the web,
1998 Winter Simulation Conference, D.J. Medeiros, E.F. Watson, J.S. Carson, and M.S.
Manivannan, editors, Association for Computing Machinery, New York, 335-341.
CHAPTER 2
1. Translating the qualitative description of a system into a formal abstraction that explicitly
accounts for all logical and mathematical relationships
2. Identifying all parameters of the abstraction that require numerical values as input
4. Estimating the values of all unknown input parameters from available data, expert
opinion, etc.
5. Designing the set of sampling experiments, at least one for each distinct set of values
for the vector of input parameters
7. Incorporating into the code statements for computing time averages of performance
measures during program execution
38 CHAPTER 2. MODELING CONCEPTS
8. Performing the set of sampling experiments by executing the code repeatedly, at least
once for each vector of input-parameter values
9. For each measure of performance, evaluating how well its time average approximates
its unknown long-run average
10. Comparing corresponding sample time averages for each performance measure across
experiments
While this numbering allows for orderly progress from beginning to end, actual practice
may turn out to blur the distinction between steps, rearrange their order, or in some cases,
neglect or pay too little attention to them. For example, the availability of point-click-drag-
drop simulation software entices a simulationist to merge steps 1 and 6, possibly making
her or him oblivious to a wider range of modeling concepts than the selected language
implementation may accommodate. Frequently, the choice of long-run time averages to
estimate in step 3 depends solely on what the programming language automatically makes
available in converting the model to code in step 6. Too often, step 9 is ignored, making any
conclusions based on comparisons across experiments difficult to justify statistically.
This divergence between our idealized list ofsteps and practice stems from the premium
that simulationists often put on their time. There is no doubt that the point-click-drag-drop
option saves time in model development and coding, and produces models and, subse-
quently, code that well approximates many a system. However, relying exclusively on this
option limits the diversity of models that can be formulated, an issue of considerable rele-
vance when the system under study calls for more structure than direct application of this
software can accommodate. To remove a potential impediment, this chapter focuses on
step l. In particular, it presents concepts germane to the construction of a discrete-event
simulation model. Most importantly, it describes two alternative, but logically equivalent,
ways of representing system behavior. Section 2.3 describes the event-scheduling approach
and Section 2.4, the process-interaction approach. Each provides directions for writing a
computer program whose execution simulates system behavior.
Discrete-event simulation has a special vocabulary that we use throughout this book.
Its principal terms include:
System. A collection of objects that interact through time according to specified rules.
Model. An abstract logical and mathematical representation of a system that describes the
relationship among objects in a system.
Entity. An object in a system that requires explicit representation within a model of the system.
For example, servers, customers, and machines all denote objects in a service delay
system.
Attribute. A descriptor of a property of an entity. For example, a server may have a skill attribute
that identifies its skill level and a status attribute that identifies whether it is idle or busy.
2 .1 . N EXT - EVE N TTl MEA D V A NeE 39
Linked List. A collection of records each identified with an entity and chained together
in an order according to values assumed by a particular attribute of each
entity. For example, arriving jobs in a system are entities. If they have to await
service, they may be filed in a list ordered by the value of their arrival-time
attribute.
Reactivation point. An attribute of an event notice associated with a process. It specifies the
location within the process at which execution is to resume.
Future-event set. A linked list containing event notices ordered by desired execution time.
Timing routine. Procedure for maintaining the future-event list set and advancing simulated
time.
Activity. A pair of events, one initiating and the other completing an operation that
transforms the state of an entity. Time elapses in an activity.
The reader has already encountered several of these terms; for example, system and
model. Others, such as the concept of a linked list, are essential for an understanding of how
the computer code for a discrete-event simulation carries out its tasks. Briefly, each record
in a singly linked list has an attribute, called the successor address, that points to the record
that immediately follows it in the list. This facilitates search starting from the first record in
the list, called the header. In addition to a successor address, each record in a doubly linked
list has an attribute, called the predecessor address, that points to the record that immediately
precedes it in the list. Collectively, predecessor and successor addresses allow for search
beginning either at the header or the trailer, the last record in the list. Section 5.2 discusses
the concept oflist processing in more detail. Unless clarity demands otherwise, we hereafter
refer to a doubly linked list simply as a list.
In a discrete-event system, a state change implies that an event occurs. Since the states
of entities remain constant between events, there is no need to account for this inactive time
in our model. Accordingly, virtually all computer simulation programming languages use
the next-event approach to time advance. After all state changes have been made at the time
corresponding to a particular event, simulated time is advanced to the time of the next event,
and that event is executed. Then simulated time is again advanced to the scheduled time of
the next event, and the procedure is repeated. Most importantly, the procedure enables a
simulation to skip over inactive time whose passage in the real world we are forced to endure.
Hereafter, we sometimes refer to simulated time, more concisely, as time.
Although the next -event approach is the most commonly used, the reader should note
from the outset that other methods exist for advancing time and processing events. (e.g.,
Fishman 1973, pp. 38-40 and Pritsker et al. 1997, p. 25) Unfortunately, use of an alternative
necessitates programming it, hence the appeal of the next -event approach, which is a standard
feature of most discrete-event simulation programming languages.
shop with two tasks to be performed. Figure 2.1 shows the arrival and the eventual service
that each task receives. It also shows the relationships that exist among events, processes, and
activities. Collectively, these concepts give rise to three alternative ways of building discrete-
event models. The event-scheduling approach emphasizes a detailed description of the steps
that occur when an individual event takes place. Each type of event naturally has a distinct
set of steps associated with it. The activity-scanning approach emphasizes a review of all
activities in a simulation to determine which can be begun or terminated at each advance
of the clock. The process-interaction approach emphasizes the progress of an entity through
a system from its arrival event to its departure event.
The development of the three concepts is related to the world views adopted by simula-
tion programming languages. Among the major ones, SIMAN, SIMSCRIPT 11.5, and SLAM
offer a user the choice of event scheduling or process interaction, whereas GPSS/H exclu-
sively offers process interaction. While activity scanning is a logically equivalent approach,
it is computationally less efficient for most discrete-event scenarios. Accordingly, we omit
further mention of it.
Process
,,r-------------------------------,
,
:4 Activity 2
I I time
a queueing system, an arrival constitutes an event because it increases the number of items
in the system by one. A departure is also an event because it decreases the number of items in
the system by one. Beginning service and completing service are also events, for each signals a
change in state for one or more resources of the system and a change in status for a particular
item. To illustrate the significance of the event -scheduling approach, we describe an airline
reservation system. We encourage the reader to recognize that the concepts described here
are generic to all simulation modeling based on this approach.
The principal features of the airline reservation model are:
c. No restriction exists on the number of customers that can wait at one time; i.e., an infinite
number of telephone lines exists.
e. If all reservationists are busy when a call occurs, a 9-second recorded message asks that
customer to wait.
f. The airline office has m reservationists. Calls occur at rate A, and intercall times are i.i.d.
random variables that follow the exponential distribution
A > 0, t 2: 0,
denoted by £ (1/ A). The proportion of customers who want a multiple-destination reser-
vation is p, whereas the proportion that desire a single-destination reservation is 1 - p.
Single-destination service times are i.i.d. random variables that follow the exponential
distribution
w > 0, t 2: 0, (2.1)
denoted by £ (1/ w). Multiple-destination service times are i.i.d. random variables that
follow the Erlang distribution
w > 0, t 2: 0, (2.2)
denoted by £2(2/w). The service time of an arbitrarily selected caller is then a random
variable with probability density function (p.d.f.)
Note that a random variable from £2 (2, 1/w) is equivalent to the sum of two independent
random variables, each from £(I/w).
g. The purpose for simulating this system is to compare its performance as the number of
reservationists m grows while A, w, and p remain fixed. In support of this objective it
is of interest to estimate the long-run averages and, more generally, the distributions of
waiting time, number of customers awaiting service, and number of busy reservationists
as the number of reservationists m varies.
<
ONE-DESTINATION
CUSTOMER TYPE
MULTIPLE_DESTINATIONS
<
IDLE
RESERVATIONIST STATUS
BUSY
Customer Reservationist
1. Cali 8. Remove from waiting line
2. Hang up 9. Become busy
3. Begin service 10. Become idle
4. End service
5. Begin recorded message
6. End recorded message
7. File in waiting line
1 6
5 7
CALL END MESSAGE
Figure 2.2
10 Elementary and compound
events
COMPLETION
Figure 2.2 shows the logic flow that enables us to incorporate these elementary events
into three compound events entitled CALL, END-.MESSAGE, and COMPLETION. From
the original description of the problem we see that whenever a call occurs 0), the caller
either begins service (3) if a reservationist is idle, or otherwise begins listening to a 9-second
recorded message (5). If service begins (3), then the reservationist who begins service also
becomes busy (9). While all four of these state changes are elementary events, they differ
in at least one important way: (1) is an unconditional event, whereas (3), (5), and (9) are
conditional events. An unconditional event occurs independently of the current state of the
system, whereas a conditional event occurs only when another event puts the system in a
prescribed state. In particular, (3) and (9) occur at the same time as (1) if and only if a
reservationist is idle; but (5) occurs simultaneously with (1) if and only if all reservationists
are busy. Collectively, the CALL compound event summarizes this behavior.
In a like manner, the END-.MESSAGE compound event summarizes state-change
possibilities whenever a recorded message ends (6), and the COMPLETION compound event
summarizes the elementary events that can occur when a caller completes service (4). Since
the beginning of service (3) coincides with a customer call (1), an end of the recorded message
(6), or a service completion (4), all three CALL, END-.MESSAGE, and COMPLETION events
incorporate the beginning of service representation. Because a customer hangs up (2) upon
service completion (4), this event (2) is modeled as part of the COMPLETION compound
event. Lastly, the idling of a reservationist (10) occurs when either no customers await
service or those that are waiting are listening to the recorded message. Consequently, it is
also modeled as part of the COMPLETION event.
Figure 2.3 defines the symbols used for flowcharting. We usually refer to the symbols as
blocks. The reader should focus attention on the "scheduling" and the "next-event selection"
blocks, since all simulation programming languages contain corresponding special subpro-
grams. If one chooses to program a simulation model in a nonsimulation language, he/she
2 .3 . EVE N T - SC H E D U LIN GAp PRO A C H 45
must write code for both of these subprograms. As the description of the airline reservation
problem evolves, the convenience of having these subprograms available in a simulation
programming language becomes apparent.
At each moment in time, the simulated system is in a particular state. For example,
the system state for the airline reservation problem has entries for:
Note that the first three entries can assume only nonnegative integer values, whereas the last
three assume nonnegative values. That is, the first three are discrete-state variables, whereas
the last three are continuous-state variables. More generally, every simulation has a state
vector some of whose entries are discrete and others of which are continuous.
Selecting the next event for execution and its timing depend crucially upon the entries
in this state vector. As illustration, the remaining time until the next event in the airline
reservation problem is
Moreover, this event is a new call if S = V, the end of a recorded message if Tz = V for some
1 = 1, ... , i, or a completion of service if Tz' = V for some 1 = 1, ... , j. As we presently
show, one rarely has to concern oneself with maintaining this vector explicitly.
Although brief, this description of the airline reservation problem illustrates several
important properties generic to the event-scheduling approach:
wy Flowchart entry
Determine
time of Computation
next CALL
~
T
Subprogram
Scheduling execution
of an event
Decision flow
Selection of next
event for execution
Figure 2.3
Transfer
Flowchart conventions
event set (FES), using a filing protocol that allows retrieval of the records in the order
of desired execution time. The form of this protocol differs among simulation languages
(Section 5.4).
A simulation programming language also provides a timing routine that operates on
the FES to make event execution occur in the desired order and at the desired simulated
times. Figure 2.4 illustrates the concept. The dashed line in the User's Program denotes
elapsed simulated time. To prime the future-event set, the User's Program first schedules
at least one event. Then it transfers control to the timing routine, which selects the event
with the smallest execution time for execution (block 1). By executing an event in block 3
we mean passing control to a block of programmed logic corresponding to the changes
in state that this particular event describes, executing the block, and returning control to
the timing routine in block 4. Note that the event corresponds to a particular instance of
this programmed logic. The act of destroying the event notice (block 4) makes the space it
occupies available for other uses. Rather than destroying the event notice, some simulations
selectively choose to save and reuse the space for a newly created event of the same class.
Doing so eliminates the need to find space for the new event. Section 5.3 addresses this issue.
Note that once the user's program passes control to the timing routine, it remains there,
or at the event it executes (block 3), until the timing routine finds the FES empty (block 5).
Then it terminates the simulation by transferring control back to the user's program (block 6).
This is one of several ways of ending a simulation.
2 Advance simulated
time to desired
execution time
Begin
simulation
5 4
No FES Destroy event
notice
While Figure 2.4 shows how to prime the FES with the initial events that start the
simulation, it provides no explicit account ofhow successive events are scheduled as simulated
time elapses. This scheduling actually occurs within executing events, as we now show. Figure
2.5 shows the steps executed each time a CALL event occurs. Here words in capital letters
denote terms that have meanings particular to our description of the airline reservation
problem. Block 1 denotes the creation of a record of an entity called CUSTOMER. The
record presumably contains space for predefined attributes of the CUSTOMER. In block 2,
TYPE denotes an attribute of CUSTOMER that contains information about whether the
CUSTOMER wants a single- or multiple-destination reservation. This record is a block of
contiguous words in memory that conceptually has the form
providing space for the values of r attributes and two pointers. Since CUSTOMER in the
"
present problem has one attribute TYPE (block 2), r = 1. The fields entitled predecessor
address and successor address are included only if the record is to be chained to a doubly
linked list (Section 5.2). For a singly linked list, only the successor (predecessor) address
is included if the search is to begin from the front (back) of the list. No predecessor and
successor address fields appear if the entity record is not to be linked to a list. For the present
problem, the END..MESSAGE (Figure 2.6) and COMPLETION (Figure 2.7) events make
use of a list called QUEUE that contains records of CUSTOMERs.
7Schedule an 5 4 Schedule
"'--L--l Attempt
END_MESSAGE next
SERVICE
in 9 seconds CALL
Yes
Event
END_
MESSAGE
1
Attempt File
SERVICE CUSTOMER in
QUEUE
Yes
2 3
Remove first
Arrange
CUSTOMER
SERVICE
from QUEUE
Yes
4
Put
RESERVATIONIST
in IDLE mode
Blocks 3 and 4 in Figure 2.5 provide a mechanism for executing the next CALL event.
In particular, block 3 determines when the event occurs, and block 4 creates an event notice
corresponding to the event, assigns the type of event to its class attribute and its desired
execution time to its clock attribute of the event notice, and files this event notice in the
future-event set. In the present case, the class is CALL.
50 CHAPTER 2. MODELING CONCEPTS
2 4 Destroy
Determine 3 Schedule a
record of
service time COMPLETION CUSTOMER
7 PutRESER-
VATIONIST
in BUSY mode
event notice:
predeccessor successor)
(identification, class, clock, attribute 2, ... , attribute T,
address, address '
(2.5)
where the predecessor and successor address fields allow for chaining the record to the FES
and for backward as well as forward searching of the FES.
The steps in blocks 3 and 4 represent bookkeeping procedures essential to all simulation
modeling based on the next-event approach. A study of block 8 indicates why this is so. When
entry into this block occurs, program control transfers to the timing routine. As Figure 2.4
shows, this routine searches the future-event set, selects the first event notice, removes it from
the set, advances time to the desired execution time, and transfers control to the subprogram
corresponding to the event name in the event notice. Execution of the event then occurs.
This variable-time advance procedure skips all the intervening time between events and
concentrates on the next event. Doing so contrasts with fixed-time advance procedures that
increase time in small increments and, at each advance, execute all events that call for
execution at that time.
Returning to Figure 2.5, we observe that the subprogram in block 5 attempts to pro-
vide service to the CUSTOMER. Since attempts at service also occur in other flowcharts,
describing these steps separately, as in Figure 2.8, avoids redundancy. Note the use there of
2.3. EVENT-SCHEDULING ApPROACH 51
another entity called RESERVATIONIST. The decision flow in block 6 of Figure 2.5 indicates
that if no RESERVATIONIST is free, a message indicating a wait is to occur. Notice that
the scheduling in block 7 identifies the time that the message ends as the event execution
time. Doing so enables the END~ESSAGE event (Figure 2.6) to check to see whether a
RESERVATIONIST has become available during the nine seconds. Here scheduling creates
an event notice for an END~ESSAGE and files it in the future event set. Also notice that
entry into block 8 occurs when the CALL event is complete.
Figure 2.6 illustrates the END~ESSAGE event. Block 3 describes a new feature
wherein the record of the CUSTOMER is filed in a list called QUEUE. Although filing
can occur based on any attribute of the CUSTOMER, it is customary to order this list so that
the next available RESERVATIONIST can find the record of the next CUSTOMER for service
first in the list. Often, time of filing is the ordering attribute; however, another attribute may
be the basis for ordering.
The COMPLETION event in Figure 2.7 describes actions that occur whenever a
RESERVATIONIST completes service to a CUSTOMER. The RESERVATIONIST checks
to see whether any CUSTOMERs await service (block 1). Each RESERVATIONIST is an
entity with an attribute STATUS whose value denotes BUSY or IDLE status. When a COM-
pLETIoN occurs this attribute of the corresponding RESERVATIONIST indicates the BUSY
mode. If no one is waiting for service, then block 4 indicates that STATUS should be changed
to IDLE, and simulation continues via selection in block 5.
If at least one CUSTOMER is waiting in the QUEUE, the RESERVATIONIST removes
the record of the first CUSTOMER from the QUEUE (block 2) and service is arranged
via the SERVICE routine (block 3). Whereas the transfers to this routine in the CALL and
END ~ESSAGE events are attempts to get service, here service is assured because of the
availability of the RESERVATIONIST. Also, note that the design of this event eliminates the
need to update STATUS when customers are waiting.
The decision flow in block 1 of the SERVICE routine (Figure 2.8) allows for the
contingency that a RESERVATIONIST is definitely available. Block 2 determines service time.
The scheduling of a COMPLETION in block 3 establishes the time at which a corresponding
COMPLETION event in Figure 2.7 for this RESERVATIONIST is to be executed. Here again
an event notice is created and filed in the future-event set. We now begin to see how crucial
a role this set plays in a simulation.
Block 4 destroys the record of the CUSTOMER entity about to begin service. The
action indicates that each CUSTOMER is a temporary entity, since it can be destroyed (Figure
2.8) as well as created (Figure 2.5). This contrasts with each RESERVATIONIST, which is a
permanent entity for the life of the simulation. The distinction is important, for as Section
4.2 shows, it leads to considerably different programming procedures.
A little thought makes the convenience of using temporary entities apparent. Unless
we destroy CUSTOMER records as they receive service, the number of such records grows
as simulated time elapses. Since each record occupies space in the computer, this growth can
conceivably consume all available space before desired termination of the simulation occurs.
Destroying records that are no longer needed reduces the probability of this occurrence.
52 C HAP TE R 2. MOD EL I N G CON C E PT S
Careful space management can also lead to a reduction in computing time. For sim-
ulation languages that rely on a dynamic space allocator to assign space to records as the
simulation program executes, destroying unneeded records makes the program run more
rapidly. That is, the more space that is available, the faster the space can be found and allo-
cated. Conversely, an accumulation of unpurged, unnecessary records reduces the amount
of space available to the dynamic space allocator and forces it to spend extra computing time
searching for the remaining unallocated space. Section 5.3 returns to this topic.
Note that Figure 2.8 ends with a transfer of control back to the calling event. Although
we may also regard events as subprograms, they have the distinctive feature of always re-
turning control to the timing routine. Throughout this book we maintain this distinction
between a routine and an event.
The airline reservation problem assumes that intercall and service times are continuous
random variables. This implies that if TI and Tz are the random times at which two distinct
events occur, then pr( TI = Tz) = o. However, all computers have finite word size. If TIl and
T22 are the finite-digit representations of TI and Tz, respectively, in a computer executing a
simulation with these two events, then it is possible for Tll = Tzz . That is, pr(Tll = Tu) > o.
If an executing simulation encounters this situation, it needs guidance as to the order
in which it should execute the two or more events scheduled for execution at the same
time. To resolve this issue, we assign a priority to each event class. If event class CALL has a
higher priority than event class COMPLETION, then, when a CALL event has the identical
execution time as a COMPLETION event, the CALL event is executed first. Hereafter, we let
the notation CALL >- COMPLETION denote this priority order. For the airline reservation
problem, we assume CALL >- COMPLETION >- END-11ESSAGE. All simulation languages
provide an explicit means for making these declarations.
It is possible that two or more events within the same event class have identical sched-
uled execution times. When this happens, most simulation programming languages break
the ties by executing events in the order in which they are scheduled. In summary, ties are
broken first by class and then by time scheduled within class.
Before beginning our description, we offer one viewpoint that the reader will find
helpful when weighing the benefits of the two alternative modeling schemes. Whereas the
process-interaction method often appears conceptually simpler to a model builder, this
simplicity usually comes at the expense of less programming control and flexibility than
the event-scheduling approach offers. The truth of this assertion becomes apparent as this
section evolves. For each simulation problem, a model builder who plans to use a general-
purpose simulation language must decide whether or not to opt for conceptual simplicity
or programming control. Considerations that enter this decision include familiarity with
alternative languages, the availability of languages at a user's computing facility, and the
extent to which a particular simulation program product is to be made available to other
potential users with different backgrounds at other computing facilities. Alternatively, sup-
pose that a model builder employs a special-purpose simulation package, as often occurs
in telecommunication and manufacturing simulation. Since most of these special-purpose
packages use the process-interaction approach, the model builder gives up the ability to
choose, presumably in return for the benefit of reduced programming effort.
Process interaction relies on a conceptually different representation of behavior than
event scheduling does. In the event-scheduling approach, an event contains all decision flows
and updating that relate to the change in state that execution of the event requires. Since
time elapses between events, one can regard a simulation as the execution of a sequence
of events ordered chronologically on desired execution times. However, no time elapses
within an event. By contrast, the process-interaction approach, either implicitly or explicitly,
provides a process for each entity in a system. To illustrate this concept, we return to the airline
reservation problem of Section 2.3. Figure 2.9 organizes the elementary events of the problem
into two sequences, one corresponding to the temporary entity CUSTOMER and the other
to the permanent entity RESERVATIONIST. Each generic sequence is called a process, and
dashed lines denote simulated time flow. For example, elementary event 6 (finish nine-second
message) occurs nine seconds after elementary event 5 (begin nine-second message). Each
temporary entity moves through the system and consequently through time. Occasionally,
a temporary entity encounters an impediment to progress and must wait. For example, if
all RESERVATIONISTs (permanent entities) are answering calls when a new CUSTOMER
(temporary entity) materializes, this CUSTOMER must wait for service. The inclusion of
time flow in a process distinguishes this approach from event scheduling. Moreover, it calls for
a more indirect form of computer programming when moving from logic flow to executable
program.
Figures 2.10 and 2.11 depict prototypical representations of these processes. Each
CUSTOMER has an attribute TYPE that identifies whether a single-destination or multiple-
destination reservation is desired. TYPE plays the same role here as in the event-scheduling
approach in Figures 2.4 and 2.7. Note in block 4 of the CUSTOMER procedure that an entry
into the procedure at block 1 is scheduled at a future simulated time. This scheduling sets
the stage for the creation of the next CUSTOMER. This form of scheduling coincides with
that of the event-scheduling approach, which always specifies entry to the first block of a
flowchart. Consequently, block 4 creates an event notice for this entry and files it in the
54 CHAPTER 2. MODELING CONCEPTS
CUSTOMER RESERVATIONIST
Wait
Wait
Wait Wait
future event set for later execution. Block 6 also schedules an event, namely, a completion
of the busy message. Flow then proceeds to block 7, where the CUSTOMER waits until
the message is complete. After the nine seconds for the message elapse, flow continues to
block 8.
The flow through blocks 6 and 7 represents one distinguishing feature of the process-
interaction approach. When the simulation encounters block 6, it creates an event notice and
assigns current simulated time plus nine seconds to its clock attribute as the desired execution
time. This event notice also has a reactivation point attribute to which the scheduling action
assigns a pointer to block 8. Then it files the notice in the future-event set. Flow continues
to block 7, where control returns to the timing routine, which then selects the next event for
execution. Here, block 7 represents a deactivation point. In contrast to the event-scheduling
approach, here entry into a process for execution does not necessarily start at the first block.
Also, time elapses within the CUSTOMER process. The dashed line between blocks 7 and
8 indicates that execution of block 8 occurs at a later time than execution of block 7 does.
This time evolution within a process distinguishes it in a major way from an event where all
computation takes place at the same moment in time.
Since reactivation occurs in a specified number of seconds, the wait in block 7 is
unconditional. However, the wait in block 10 is a conditional one. Here, reactivation at block
2 .4 . PRO C E 5 5 - I N TE RAe T ION A PPRO A C H 55
12 II Activate
13 Destroy Yes
Wait until RESER-
record of
completion VATIONIST
CUSTOMER
now
end of busy
Yes
No 7 Wait until
busy message
ends
12 occurs once a RESERVATIONIST in Figure 2.11 selects the CUSTOMER for service.
At least two alternative modeling representations of a conditional wait occur in practice.
First, a notice that a CUSTOMER is waiting for a RESERVATIONIST may be filed in a list
associated with the RESERVATIONIST process. In Figure 2.10 this list is called QUEUE.
Then, whenever a RESERVATIONIST in Figure 2.11 completes service at block 7, a scan
of the relevant list results in the selection of the next CUSTOMER to receive service. The
notice corresponding to this CUSTOMER is then removed from the list in block 4. If no
CUSTOMER is waiting, the RESERVATIONIST becomes idle in block 3.
If several alternative types of servers exist in a simulation problem, each would have a
distinct representation as a process and each would have a corresponding list on which to store
notices of demands for service. By contrast, a second approach to modeling a conditional
wait has a single list in which to store notices of all service demands, regardless of the type of
server demanded. By aggregating all demands, this alternative reduces the number oflists to
one, thereby reducing space requirements within a program. However, it requires additional
search time on the part of each type of server, who now has to search through a longer list of
56 CHAPTER 2. MODELING CONCEPTS
Process
RESERVA-
TIONIST
notices. Both options are available in most simulation languages, with multiple lists being
the more common approach. Regardless of which option is chosen, we hereafter refer to
these lists as the conditional-event set (CES).
Time also elapses in the RESERVATIONIST process in Figure 2.11. Unlike every in-
stance of the CUSTOMER process, however, each instance of the RESERVATIONIST process
remains in existence during the life of a simulation run. Each RESERVATIONIST has an un-
conditional delay at block 7 and a conditional delay at block 3. Collectively, these reveal the
interaction that occurs between processes. In particular, block 11 in Figure 2.10 signals the
idle RESERVATIONIST in block 3 of Figure 2.3 that service is required, whereas the removal
of a CUSTOMER from the QUEUE in block 4 of Figure 2.11 signals the waiting CUSTOMER
in block 10 of Figure 2.10 that service is about to begin.
In a simulation based on the process-interaction approach, the timing routine does
more work than in one based exclusively on event scheduling. As Figure 2.12 shows, this
extra work arises from the need to manage the conditional event set as well as the future
events list. For conceptual simplicity, this depiction relies on a single CES. Here, block 12 is
equivalent to a scheduling statement, whereas reactivating a process in block 5 is equivalent
to transferring control to a particular instance of a process. Also, after selecting a scheduled
process from the FES in block 3 and executing it in block 5, the timing routine scans the CES
in block 1 to identify any processes whose conditions for continued execution are now met.
If found, it removes these processes, one at a time, from the CES in block 11 and files them
2.5. ACTIVE PROCESSES AND PASSIVE RESOURCES 57
5
Timing Begin Execute process
routine simulation starting at
reactivation
point
12 File process
10 File
inFES with
current time as process
desired ineES
execution time
Produce
summary
statistics
in the FES with current simulated time as the desired execution time (block 12). As with
Figure 2.3, we emphasize that Figure 2.12 describes a prototypical timing routine. Other
designs may exist that manage processes in a different, but logically equivalent, manner.
work to do. In particular, these and like simulation statements do away with the need to
model the RESERVATIONIST process explicitly as in Figure 2.11.
The concept of active processes and passive resources originated with GPSS (Gordon
1969). Its appeal has been so great that virtually every simulation programming language
based on the process-interaction approach embraces it. Section 4.21 illustrates the concept
for SIMSCRIPT 11.5, and Sections 4.24 through 4.25 for SIMAN.
If its appeal is so great, why do we bother to describe the option in which
both CUSTOMER and RESERVATIONIST are active processes? Flexibility is the answer.
Macrostatements such as SEIZE and RELEASE correspond to recipes for performing a mul-
tiplicity of steps in sequence. They serve a constructive purpose, provided that the problem
at hand has a logic flow that corresponds to that in the statements. If it does not, the simula-
tionist has two options, to ignore the difference and take advantage of the macrostatements,
or to write her/his own sequence of statements in the selected language to perform the steps
required in the problem at hand. Our discussion provides this guidance for effecting the
latter option.
(x,
~
----
(Xl
P2 Pk
~ ------~
(X)
0.
(X,
~ 02
changes rate at discrete points in time. The times between changes for a particular source
may be Li.d. random variables, in which case they are sampled from a probability distribution.
Alternatively, they may be deterministic with possibly constant increments. The simplest rate
change structure has Ct j (r) alternating between a low value Ct jO and a high value Ct jl; but
other behavior is possible.
For each buffer i = 1, ... , k, let
Ci := capacity,
Qi (r) := volume occupied at time r,
ri,next := time of next input rate change,
Yi-I := maximal allowable outflow rate from buffer i - I into buffer i,
ifQI(r) =0,
if QI(r) > 0,
and this is the inflow rate to buffer 2. More generally, the outflow rate from buffer i and the
inflow rate to buffer i + 1 for i = 1, .. . , k is
if Qi(r) = 0,
if Qi(r) > O.
and fluid is lost to the system. If r < ri,next and PHI (r) > Pi (r), then buffer i empties at
time
so that Qi (re) = O.
In this system the design parameters are the buffer capacities CI, •.. , Ck and possibly
the maximal outflow rates Yb ... , Yk. Over a simulated time interval [s, t), the sample
average unused capacity
1
B(s, t) = t _ sis
t t; [Ci -
k
Qi(r)] dr
estimate performance. For each buffer i the sample average unused capacity
1 t
Bi(s, t) = t _ sis [Ci - Qi(r)] dr
FULL
EMPTY
Note that at time r, fJI (r) denotes the exogenous rate to buffer 1; for i = 2, ... , k, fJi (r)
denotes the inflow rate to buffer i and the outflow rate for buffer i - I ; and fJH I(r) denotes
the output rate from the network. If, as in some models, controls were applied to outflow
rates, then the twofold definitions of fJ2 (r ), ... , fJk ( r) would not apply.
The elementary events form the compound events in Figure 2.14. These compound
events reveal how the event-scheduling approach can conveniently represent the iterative
updating of inflow-rate changes that potentially can occur at all buffers j ::: 1 when the
exogenous flow rate changes, or at all buffers j ::: i when buffer i becomes empty. Notice
that executing an overflow event allows for recording when overflow begins.
Figure 2.15 provides more details. Because fluid flows continuously, it is necessary
to schedule events to handle fluid exhaustion and overflow. The EMPTY event updates a
change in a buffer's outflow rate to reflect the fact that fluid can exit an empty buffer at a rate
no greater than the rate at which it enters it. In the current setting, the FULL event merely
acknowledges that a buffer has become full and fluid (messages) will overflow and be lost.
In other operating environments, a decision may be made to reduce the inflow rate prior to
or at overflow. This action calls for rate changes in previous as well as successive buffers. The
FULL event here allows changes only in successive buffers.
The RATE event executes every time an exogenous or endogenous rate change occurs.
It introduces the reader to a new concept, namely, a cancellation. When fJi (r) changes at time
62 CHAPTER 2. MODELING CONCEPTS
Compute Yes
Detennine
i=l? time to next
Qi exogenous
rate change
Cancel
FULL Yes FULL Schedule
for scheduled? next RATE
BUFFERi for
BUFFERi
Cancel
EMPTY
No Yes for
:>'-----r--=, scheduled?
BUFFERi
No Yes
Schedule
EMPfYat Schedule
't'e='f+~ FULL
Yi-Pi for BUFFER i
Yes
i > k?
No
(a) RATE event
Figure 2.15 Fluid flow events (t' := current simulated time, f3i := f3i (t') Vi)
t', the scheduled execution for an already scheduled FULL or EMPTY event may change.
Canceling an event causes the simulation to remove the corresponding event notice from
its FES and, possibly, to schedule a new FULL or EMPTY event. Indeed, this can happen as
many as k - i + 1 times in a RATE event. Routine UPDATE describes the three alternative
ways that a change in flow rate can occur.
Event
EMPTY
Schedule
Record RATE for
overflow BUFFERi+l
now
Select
next
next event
event
No Yes
Yes No
Generate
new
Done
Figure 2.15
64 CHAPTER 2. MODELING CONCEPTS
• During execution of program code for an event, simulated time remains fixed.
• During execution of program code for a process, simulated time may advance. Indeed,
execution may terminate within the code, and after an elapsed simulated time execution
may begin again at a reactivation point in the code.
• An event notice with an attribute for desired execution time is used to schedule
execution.
• An event or process notice with attributes for desired execution time and reactivation
point is used to schedule execution.
• Every discrete-event simulation language keeps its event notices in a future-event set
(FES).
• Every discrete-event simulation language has a timing routine that operates on the FES
to cause the simulation to execute events in the desired order.
• The process-interaction approach also has some form of a conditional-events set that
keeps track of when conditions are met that allow execution to continue for each
process.
2.8 EXERCISES
GENERAL INSTRUCTIONS
For each exercise modeled with the event-scheduling approach, define all entities,
attributes, lists, and elementary events, as well the compound events they form. For each
exercise modeled with the process-interaction approach, define all entities, attributes, lists,
elementary events, and the processes formed from them.
QUARRY-STONE CRUSHING
iff? 2.1 Hard Rock Corporation owns a quarry and three power shovels that load its truck
with stone to be delivered to its crusher. The distances between each shovel and the crusher
vary. Two 20-ton and one 50-ton trucks are assigned to each shovel. A shovel loads its trucks
in first-come-first-served order. However, unloading at the crusher occurs first based on
truck size, with largest going first and then on a first-come-first-served basis. Table 2.1 gives
loading, dumping, and travel times, where a + £(b) denotes the sum of a constant a and
an exponentially distributed random variable with mean b. Once unloaded, the stone is
crushed at the rate of 25 tons per minute.
a. Ignoring waiting times, determine the long-run arrival rate to the crusher of a
randomly selected truck in tons per minute.
2.8. EXERCISES 65
b. Determine the long-run unloading rate at the crusher of a randomly selected truck in
tons per minute.
c. If this were an open-loop system that generates stone to the crusher as fast as the
shovels can load an unlimited number of trucks two-thirds of which are 20-ton and
one-third of which are 50-ton, would it be stable? Explain your answer in detail.
d. Explain why travel to and from the crusher does or does not playa role in part c.
t}1 2.2 A well-established demand exists for Hard Rock's crushed rock at A dollars per
ton. Management knows that the crusher can process more stone than is currently supplied to
it. To boost actual throughput, Hard Rock considers allowing an outside contractor to supply
additional stone to the crusher in 50-ton loads. The interarrival times between successive
loads would be i.i.d. from £(1/A), where A is to be determined by Hard Rock. Regardless of
origin, 50-ton trucks receive priority over 20-ton trucks, among 50-ton trucks selection is
based on first in first out, and among 20-ton trucks it is based on first in first out. External
trucks have unloading times 1.5 + £(1) in minutes.
Crushing costs B = O.SOA dollars per ton. Hard Rock provides stone to the crusher
at a cost of C = O.2SA dollars per ton. The outside contractor offers to provide rock at
D = O.26A dollars per ton. In order to maximize profit, Hard Rock management wants to
know what value to assign to A. Assume A = 32.
a. Determine the smallest rate A* such that the system would be unstable if A ::: A*.
b. Model the problem with external as well as internal input using flowcharts based on
the event-scheduling approach.
c. Model the problem with external and internal input using flowcharts based on the
process-interaction approach.
LOADING TANKERS
t}1 2.3 Tankers take on crude oil in an African port for overseas shipment. The port
has facilities for loading as many as three ships simultaneously. Interarrival times between
66 CHAPTER 2. MODELING CONCEPTS
tankers follow cell), where £(0) denotes the exponential distribution with mean 0 hours.
Three types of tanker exist. Table 2.2 describes their characteristics, where g(a, fJ) denotes
the Gamma distribution with scale parameter a and shape parameter fJ (note that the mean
is afJ).
One tug serves the port. All tankers require the tug to move them to and from the
berths. When the tug is available, berthing (an empty tanker) time follows £(1), whereas
deberthing (a full tanker) time follows £(1.25). When not towing a tanker, tug transit to
pick up a tanker is called deadheading and takes time drawn from £(0.75).
Upon arrival at the berths the tug next services the first tanker in the deberthing queue.
If this queue is empty, it services the first tanker in the berth queue in the harbor, provided
that a berth is available. Upon arrival in the harbor, the tug services the first tanker in the
berth queue. If the queue is empty, it services the first tanker in the deberthing queue. If
both queues are empty, the tug remains idle.
To compete with other oil-loading ports, the port authority plans to institute a rebate
program based on total port time. This is the summation of waiting, towing, and loading
times. If a tanker's port time exceeds 48 but is no more than 72 hours, the authority will pay
its owner a rebate of A dollars. If it exceeds 72 but is no more than 96 hours, the rebate is
3A dollars. In general, if it exceeds 24i but is no more than 24(i + 1) hours, the rebate is
(2i - 1)A. Assume A = 10,000 dollars.
To estimate the cost of this program the authority commissions a simulation study to
characterize port time. The first step is modeling.
a. Describe how the additional tankers would affect the stability of the overall queueing
system in the port.
b. Augment the model in Exercise 2.3b using flowcharts based on the event-scheduling
approach.
c. Augment the model in Exercise 2.3c using flowcharts based on the process-interaction
approach.
iff?l 2.5 The control of packet assembly and disassembly is a topic of major interest to all
who provide communications network services to industry, government, and the public at
large. The problem described here is considerably simplified to allow students to work on it
without the impediments that very high transmission rates and network size impose. How-
ever, the issues that arise in the scaled-down version continue to be principal considerations
in higher-speed problems as well.
A terminal packet assembly/disassembly (PAD) controller model contains r input
buffers each of capacity m and one output buffer of infinite capacity. The PAD controller
receives characters from r = 10 terminals, one for each input buffer, and assembles them
into packets before transmitting them into a network. The characters from each terminal
arrive at its input buffer and wait. A packet is formed when either an input buffer becomes
full or a special control character arrives, whichever is first. If present, the control character is
included in the packet. When a packet is formed, it is tagged with a fixed number of overhead
characters and sent to the output buffer, where it waits in a FIFO queue. The output buffer
serves all input buffers and, if there are any to transmit, puts out characters at a constant rate
of one per time unit. The input characters into each buffer form a Poisson process with rate
A. Assume that r is constant, so that P = r A is the arrival rate of characters into the PAD
controller.
The probability that an arriving character is a special control character is q := .02.
Also, one overhead character is added to a packet when it moves from the input buffer to
the output buffer.
The purpose for studying this model is to identify the rate A and input buffer capacity
m that minimize
subjectto the constraints .30 .::: P .::: 1 andm E {8, 9, ... , 32}. Note that J.-t increases without
bound as either P ~ 0 or P ~ Po < 1, where Po := system-saturation input rate.
b. Determine Po.
c. Identify all elementary events and use them to form compound events.
d. Using the event-scheduling approach, prepare flowcharts that describe the details of
the events in this problem.
(iF 2.6 Friendly Communications Incorporated provides mobile and standard telephone
services by means of a collection of communication towers distributed throughout a region.
A customer traveling through the region while using the mobile service automatically has
her/his call handed off and managed (transmission and reception) by a sequence of towers
en route. At any moment in time, the tower providing this service to the customer is the one
geographically closest to him or her. Each tower can handle m calls at a time.
Each tower has the capacity for handling a total of m standard and mobile calls simul-
taneously. For a traveling mobile caller, there is always the possibility that when her/his call
is handed off from one tower to the next, that next tower is already serving m callers, and
hence the mobile caller loses the connection. This loss is highly undesirable.
Assume that the times between successive new standard calls for a tower are LLd.
random variables from £ (1/ As), whereas the times between successive handoffs of mobile
calls to the tower are i.i.d. from £ ( 1/Ah ). Also, assume that call-duration times are i.i.d. from
£ (1/w) and independent of type.
To manage loss the company decides to dedicate r (::::: m) lines for handoffs. In par-
ticular, let X s ( r) denote the number of standard call and Xh ( r) the number of mobile calls
at time r. Let r _ denote the instant of time prior to a new demand. The operating policy is:
• If a new request for standard service arrives at time r, it is provided if Xs (r) < m - r.
Otherwise, service is denied and the call is lost.
• If a new mobile call handoff request occurs at time r, it is assigned a dedicated line if
Xs(L) < r. If Xh(L) > rand Xs(L) + Xh(L) < m, it is assigned one of the m - r
nondedicated lines.
• If Xs (r _) + Xh (r _) = m, the mobile call is lost.
The purpose of this study is to evaluate how the choice of the number of dedicated
lines r affects
and, in particular, the cost oflosing calls. If the cost oflosing a handed-off call is unity and
the cost of denying service to a new standard call is c( < 1), then it is of particular interest to
determine the r that minimizes long-run average total cost
(2.7)
b. Identify all elementary events and form compound events from them.
c. Using the event-scheduling approach, prepare flowcharts that describe the details of
the events.
e. Using the process-interaction approach, prepare flowcharts that describe the details
of the processes in part d.
2.9 REFERENCES
Cheng, R.C., and J.D. Lamb (1999). Making efficient simulation experiments interactively
with a desktop simulation package, University of Kent at Canterbury, United Kingdom.
Fishman, G.S. (1973). Concepts and Methods in Discrete Event Digital Simulation, Wiley, New
York.
Pritsker, A.A.B., J.J. O'Reilly, and D.K. LaVal (1997). Simulation with Visual SLAM and
AweSim, Wiley, New York.
CHAPTER
• Choosing a run length (t ) that ensures that the finite-sample averages are representative
of the unknown true long-term averages.
Sections 3.2 through 3.5 explain the significance of S (0), k - 1, and t, leaving the issues of
choice until Chapter 6, which gives a considerably more detailed account of these issues.
The account of computational forms in Section 3.1 aims to give the reader an un-
derstanding of the data-accumulation techniques that simulation programming languages
often provide implicitly. For the cases where such techniques are not provided, the account
provides sufficient information for a user to program the steps explicitly. Subsequent sec-
tions aim at sensitizing the reader to the important role that statistical issues play in assessing
the quality of the numbers that a simulation generates as output. This topic has many facets,
and any simulation user who contemplates presenting simulation output to an audience
and convincing them that the output truly characterizes the sysem will benefit first from an
understanding of what the statistical issues are (Sections 3.2 through 3.5) and second from
an awareness of how to resolve them (Chapter 6).
and
Occasionally, we use the more concise notation A(t) := A(O, t) and N(t) := N(O, t).
A discrete-event simulation program is an engine for producing sample paths {A ( r) -
A(s), s :::: r :::: t}, {N(r) - N(s), s :::: r :::: t}, {Q(r), s :::: r :::: t}, {B(r), s :::: r :::: t},
and {Wi; i = N(s) + 1, ... , N(t)}. These sample paths, sometimes called sample records or
realizations, provide histories of how the underlying processes in the simulation behave over
the finite time interval [s, t]. It is these histories that provide the raw data for computing
the summary sample statistics:
- A(s, t)
A(s,t):= ------, (3.7)
t-s
• average throughput
-( )._N(s,t)
N s,t .- - - - , (3.8)
t-s
Q(s, t) := - 1
t - s
It
s
Q(u)du, (3.9)
R(s, t) := -1-
t - s
It
s
B(u)du, (3.10)
_ 1
L
N(t)
W(s, t) := - - - Wi. (3.11)
N(s, t) i=N(s)+l
74 CHAPTER 3. DATA COLLECTION AND AVERAGES
Note that expressions (3.7) through (3.1O) are time averages, whereas expression (3.11) is an
arithmetic average. Sometimes Q(r} and B(r} are called time-persistent variables. Sections
3.1.1 and 3.1.2 explain why this name is applied.
The sample paths contain considerably more information than these averages alone can
convey. A sequence of exceedance proportions often provides supplementary information
of value. Let
ifx E A,
otherwise.
Then the system also has the following sample performance indicators:
_
PQ(q, s, t} := -
1 [t I(q,oo)(Q(u}}du, q = 0,1, ... , (3.12)
t - s s
_
PB(b, S, t} := - -
1 [t I(b,oo) (B(u»du, b = 0,1, ... , (3.13)
t- s s
_ 1 N(t)
Pw(w, s, t} := - (- )
N s, t
L
i=N(s)+l
I(w,oo)(Wi }, w > 0. (3.14)
While the averages (3.7) through (3.11) show central tendencies, the proportions (3.12)
through (3.14) can provide a penetrating view of extreme system behavior. A table or graph
of {PQ(q, s, t}; q = 0,1, ... } reveals how likely queue length is to be large. It is par-
ticularly useful in sizing the buffer or waiting room where jobs wait. A table or graph of
{PB(b, s, t}; b = 0,1"", m - I} reveals how well utilized all the servers are. A table or
graph of {Pw (w, s, t), W E {WI < Wz < ... }} characterizes the delay that an arbitrary
arrival to the system encounters. In practice, graphical display of these distributions enables
one to draw meaningful conclusions more quickly than tabular displays do.
While concise with regard to mathematical notation, expressions (3.7) and (3.14) give
no clue as to how to compute these averages in practice. This section addresses this issue. Let
tQi := time of the ith change in queue length for i = 1, ... , lQ(t),
tQo := O.
Suppose a simulation is run for the simulated time interval [0, S + T], where s ::: 0
and T > 0, and we wish to compute the average queue length over the interval [s, s + T].
Expression (3.9) implies
Q(s, s + T) = -
1 [s+r Q(u)du.
T s
Q(u) = Q(tQ,i-d,
reveals that {Q(u), s ::: u ::: s + T} is piecewise constant, so that expression (3.9) has the
equivalent form
(3.16)
order to ensure that overflow occurs with a frequency no greater than a specified quantity. In
a manner analogous to that for average queue length, expression (3.12) admits the recursion
- tQ,JQ(s+r:) - s -
PQ(q, s, s + t') = t' PQ(q, s, tQ,JQ(s+r))
t' +s - tQ JQ(s+r)
+ t'
. x I(q,oo) (Q(tQ,JQ(s+r)))'
Computing averages for resource utilization is analogous to that for queue length. Let
and
tBi := time of the ith change in the number of busy RESERVATIONISTs for
i = 1, ... , JB(t).
Since
we see that {B(u), s :::; u :::; s + T} is also piecewise constant in time. Therefore, time average
(3.lO) has the alternative representation
_ 1 [ JB(s+r)
B(s, s + T) = - L B(tB,i-l)(tBi - tB,i-l) + B(tB.JB(s+r))
T i=JB(S)+l
so that
Computing the averages in expressions (3.11) and (3.14) for waiting time calls for a
different approach than for queue length and resource utilization. Whereas the sample paths
of queue length {Q (T), s :::; T :::; t} and resource utilization {B (T), s :::; T :::; t} are indexed
78 C HAP TE R 3. DA T A COL LEe T ION AND Av ERA G E S
onthecontinuousvariabler, the sample path of waiting times {W;; i = N(s)+I, ... , N(t)}
is a discrete collection of observations. Moreover, whereas a simulation needs to keep track
of the number in queue and number of busy servers to compute the averages (3.9), (3.10),
(3.12), and (3.13), it must now keep track of the arrival timefor each job in the system and
subtract it from the simulated time at which the job enters service in order to compute its
waiting time. Making arrival time an attribute of the temporary entity corresponding to job
or CUSTOMER in the airline problem allows for this last calculation.
To conserve on space for data storage, one can again resort to recursion. Let
i=N(s)+I,
(3.21)
i = N(s) + 2, ... , N(s + r),
and
i = N(s) + 1,
(3.22)
i =N(s)+2, ... ,N(s+r).
and
P- ( )_ VN(t)-N(s)(W)
(3.24)
ww,s,t- () ().
Nt - N s
Section 3.5.1 describes a relationship known as Little's law that relates the arithmetic
average (3.11) for waiting time to the time average (3.9) for queue length, thus reducing the
amount of data required to compute both averages.
• Estimates whose statistical accuracy improves as the length of the sample record, on
which the estimates are based, increases.
Recall that the sample path for a simulation run results from the repeated operation
of the timing routine on the simulation's future-event set (FES) as simulated time T evolves.
At time T, the FES dictates which event occurs next and when to execute it. When, as
frequently occurs, execution of an event includes the scheduling of a future event, it provides
a new entry in the FES on which the timing routine eventually operates. While interaction
between the timing routine and the FES and interaction between an executing event and
the FES completely characterize the way in which simulated behavior evolves through time,
it provides this characterization with an emphasis on computational issues. An alternative
approach accomplishes this same objective by focusing on the state of the system. Introducing
this approach here enables us to shift the focus of discussion from computational to statistical
considerations while preserving all essential features of a simulation's dynamical behavior.
80 CHAPTER 3. DATA COLLECTION AND AVERAGES
where
SBiBI'i (r)
} the busy RESERVATIONISTs
SCkl'i(r)
} to the recorded message,
and
A little thought shows that a sample path {S (s), 0 :::: s :::: r} also provides sufficient
information to construct the corresponding sequence of waiting times {WI, ... , WN(r)}'
If the last event occurred (executed) at time r, then the next event or events execute at
where
If
then a COMPLETION event occurs at time r' for RESERVATIONIST i for an i E IE (r). If
then an END-11ESSAGE event occurs for CUSTOMER j at time r' for a j E Idr).
We immediately see that the clock attributes of the event notices in the FES at time r
are in one-to-one correspondence with the elements of the set
and that the ordering of the FES for execution is identical with this set, ordered from small
to large.
Hereafter, we frequently refer to S (r) as the state vector or the state at time r. Note
that the number of elemental entries in S (r) varies with r. In particular, these changes in
number can occur only at r '( r) for each r. Also, note that S ( r) contains both continuous
and discrete random variables as entries.
The centrality of {S (s), 0 :s s :s r} with regard to the future-event set and the determina-
tion of {B(s), 0 :s s :s r}, {Q(s), 0 :s s :s r}, and {Wi; i = 1, ... , N(r)} in Section 3.2.1
enable us to unify our approach to understanding the statistical properties of the sample
averages, as in expressions (3.7) through (3.14). Most critical in this assessment is the role
of the probability distribution of the random state vector S (r) and the behavior of this
distribution as a function of r . As before, we use the airline reservation problem to illustrate
concepts, but emphasize that the general case demands relatively minor modification.
82 CHAPTER 3. DATA COLLECTION AND AVERAGES
To execute a simulation run, we must first assign values to S (0), using either a de-
terministic or a random rule. We do this indirectly by establishing initial conditions that
are to prevail at simulated time zero. For example, suppose we start the airline reservation
simulation with a CALL at!' = 0 to an empty and idle system. Then the logic of this problem
dictates the initial vector state
where
IB(O) = lid,
IcCO) = 0,
Q(O) = 0,
B(O) = 1,
CeO) = 0,
SA (0) = time at which second CALL occurs,
SBi! (0) = service time for first completion.
Also,
Alternatively, if we were to start the simulation with a CALL scheduled in a time units, three
busy RESERVATIONISTs with remaining service times of b, c, and d time units, and no
scheduled END-MESSAGEs, then S (0) would have the entries
SA(O) = a,
SBi] (0) = b,
SBi,(O) = c,
SBi,(O) = d.
Moreover,
Let T denote the set of all possible states that a simulation model can realize as simulated
time elapses. Then the choice of initial conditions and the method by which a simulation
user makes this choice induce an initializing distribution
denoted by 7ro. In each of the two examples for the airline reservation problem, 7ro is degen-
erate, putting all its mass on a single state. These are special, but convenient, illustrations.
However, if the simulationist in the second example elects to sample values for the remaining
times to the CALL event and the three COMPLETION events, 7ro would be nondegener-
ate. Note that a simulationist does not literally sample from 7ro; however, her/his method
of assigning initial conditions is probabilistically equivalent to sampling from an implicit
7ro. Recognizing this equivalence enables us to characterize sample-path behavior as time
elapses.
For each r ~ 0 and DE T, let no('; riD) denote the conditional distribution of the
state set S (r), so that
To facilitate a meaningful statistical analysis on sample-path data, the simulation must endow
this conditional distribution with at least two important properties:
where n (A) is called the equilibrium or steady-state distribution for the subset of states
A in T. In particular, A ~ B ~ T implies 0 ~ n(A) ~ n(B) ~ n(T) = l.
• This limit (3.33) must hold for every initial distribution 7ro on T.
84 CHAPTER 3. DATA COLLECTION AND AVERAGES
Expression (3.33) asserts that as simulated time r elapses, the distribution of the
state vector S (r) converges to a distribution that is independent of the initial conditions
S (0) = V, regardless of which state VET is chosen to start the simulation. Moreover,
this occurs regardless of the distribution 7ro. These are extremely useful properties. Were
expression (3.33) not to hold, then the sample path generated during a simulation run
would have statistical properties that depend on the initial conditions, a feature antithetic to
our objective of approximating long-run averages for utilization, queue length, and waiting
times, which are presumably unique for a given simulation model with specified numerical
values for its input parameters. Unless otherwise explicitly stated, we hereafter assume that
the design of the simulation model ensures that expression (3.33) holds.
Let 7r := InCA), A ~ T}. Ali with 7ro, the interpretation of 7r must be in context.
Ali r increases, the dynamic logic of the simulation model implies that there exists a unique
distribution 7r, independent of S (0), that characterizes the behavior of S (r ). Moreover, this
dynamic logic, not actual sampling from 7r, dictates the value that S (r) assumes at time r.
A simulation user frequently picks the initial state arbitrarily with no randomizing
considerations at all so that 7ro is degenerate. Computational ease in assigning the initial
state and limited knowledge usually dictate its choice. However, some states turn out to be
better than others for the initial state inasmuch as they induce faster convergence to the
limit (3.33) and thereby require a shorter warm-up interval before data collection begins.
Section 6.1 returns to this topic.
Since sUPA~T Ino(A; s + rlV) - n(A)1 tends to decrease ass (> 0) increases, initial
conditions tend to influence data collected over the interval [s, s + r Jless than data collected
over the interval [0, r J. That is, both sample records have the same sample-path length r,
but the one collected after deleting the warm-up interval [0, s) is affected less by the starting
conditions of the simulation.
Recall that the output of a simulation run includes time averages, as in expressions
(3.7) through (3.14), computed from sample-path data, that serve as approximations to
the long-run averages, queue length, utilization and waiting time. These long-run averages
characterize congestion. In particular, we say that congestion increases (decreases) as average
queue length and waiting time increase (decrease). For fixed simulated times r1 and r2,
the dependence between two state vectors S (r1) and S (r2) tends to increase (decrease) as
congestion increases (decreases). For example, the dependence between queue lengths Q(r 1 )
and Q(r2) increases (decreases) for fixed times r1 and r2 as the traffic intensity increases
(decreases).
Since S (0) denotes the conditions that prevail at the beginning of a simulation run, it is
clear that the choice of an appropriate warm-up interval depends on the extent of congestion
in the system. While we must defer a discussion of how to choose an appropriate warm-up
interval until Chapter 6, we can at this point identify issues that should sensitize the reader
to the role of congestion in analyzing data.
3.3. CONDITIONAL AND EQUILIBRIUM DISTRIBUTIONS 85
Recall that every discrete-event simulation model has one or more service time distri-
butions to whose parameters a simulationist must assign numerical values before execution
can begin. Moreover, an open-loop system has an interarrival time distribution whose pa-
rameters also require numerical assignments. We call these values inputto the simulation. As
the values assigned to the mean service time, the variance of service time, or in an open -loop
system, to the arrival rate increases (decreases), long-run queue length and waiting time,
and therefore congestion, increases (decreases). Hence, increases in these input values alert
the simulationist to the need to increase the warm-up interval.
Since queue length Q ( r) and number of busy servers B ( r) at time r both are
entries in the state vector, the limit (3.33) has implications for these quantities. Let
'ITQ := {1l'Qq; q = 0, 1, ... } and 'ITB := {1l'Bb; b = 0, 1, ... , m} denote the marginal equilib-
rium probability mass functions (p.m.f.s) of 'IT with respect to queue length and number of
busy RESERVATIONISTs, respectively, where
and (3.34)
pr[B(s + r) = blS (s)] -?1l'Bb as r -7 00.
While these limits are reassuring, they merely tell us that if one runs a simulation for
a sufficiently long time r, he/she can expect Q(s + r) and B(s + r) to exhibit statistical
behavior that is independent of S (s). That is, the values that Q(s + r) and B(s + r) as-
sume tell us something about congestion, uninfluenced by the conditions that prevailed at
simulated time s. However, our principal interest is in the time averages {PQ(q, s, s + r);
q = 0,1, ... }, {PB(b, s, s + r); b = 0, 1, ... , m - I}, Q(s, s + r), and B(s, s + r), which
characterize the entire sample path. To ensure that these are meaningful approximations of
their corresponding long-term averages, we need more than the limits (3.34).
Let
and
PBb := 1 - 1l'BO - 1l'Bl - .•. - 1l'Bb.
86 CHAPTER 3. DATA COLLECTION AND AVERAGES
That is, the sample proportions {1- PQ(q, s, s+r); q = 0, 1, ... } converge to {1- PQq; q =
0,1, ... } and the sample proportions {I - PB(b, s, s + r); b = 0,1, ... , m} converge to
{1- PBb ; b = 0, 1, .. . m}.
The notation w.p.1 means "with probability one." It is equivalent to the notation a.e.
for "almost everywhere;' which is also common in the statistical literature. Both imply the
strongest form of convergence that probability theory has to offer. When expression (3.35)
holds we say that PQ(q, s, s + r) is a strongly consistent estimator of PQq and PB (b, s, s + r)
is a strongly consistent estimator of PBb .
While the limits (3.34) are necessary for the sample paths {Q(r), r ::: s} and
{B ( r ), r ::: s} to exhibit equilibrium behavior independent of S (0) as r --* 00, the limits
(3.35) assure us that the time averages PQ(q, s, s + r) and PB(b, s, s + r) tend to become
increasingly better approximations for PQq and PBb, respectively, as the length of the sample
path r increases without bound. Were this not so, data collected on a single sample path
would have little value.
To describe convergence for Q(s, s + r) and B(s, s + r), we rely on their relationships
to {PQ(q, s, s + r), q = 0, 1, ... } and {PB(b, s, s + r); b = 0, 1, ... , m - I}, respectively.
Let
q = 1,2, ... ,
= sample proportion of time r that q CUSTOMERs are in the queue
and
L qI'l.PQ(q, s, s + r)
00
Q(s, s + r) = (3.36)
q=l
and
L bl'l.h(b, s, s + r).
m
B(s, s + r) = (3.37)
b=l
3 .3 . CON D I T ION A LAN D EQUI LIB RI U M DIS T RIB UTI 0 N S 87
To put limiting behavior for Q(s, s + 1') and B(s, s + 1') into perspective, we rely on
yet another pair of equivalent representations,
()()
and
m-J
which follow from expanding and summing like terms in expressions (3.36) and (3.37),
respectively.
By definition,
m m
/-LB := L b:rrBb = L PBb (3.40)
b=O b=O
denotes the mean number of busyRESERVATIONISTs. If the limit (3.35) for PB(b, s, s + 1')
holds for each b = 0, 1, ... , m, then for fixed s and finite m
That is, the sample time average B(s, s + 1') converges to a constant that turns out to be the
probability average called the mean number of busy RESERVATIONISTs.
For queue length, an additional property must hold. By definition,
()() ()()
denotes the mean queue length. If the limit (3.35) for PQ(q, s, s + 1') holds for each q =
0, 1, ... and PQq -+ 0 sufficiently fast as q -+ 00, then /-LQ is finite and
The condition that /-LQ be finite is an important one. For a system modeled with finite
waiting room or buffers, it is clearly true that PQq = 0 for q ::: c, where c is the capacity
of the buffer. In this case the condition always holds. However, if a system is modeled with
infinite-capacity buffers, then the finiteness of /-L Q depends on the properties of the random
input. If the interarrival times and service times all have finite moments, then /-LQ is finite,
and as in expression (3.42), Q(s, s+1') approximates /-LQ with an error that tends to diminish
as l' increases.
88 CHAPTER 3. DATA COLLECTION AND AVERAGES
AN EXCEPTION
The preceding discussion assumes that an equilibrium distribution 1r exists and that
tLQ is finite, not unreasonable assumptions for many models of manufacturing, commu-
nications, and traffic systems. However, exceptions exist, and when they occur the concept
of long-term average becomes conjectural and statistical inference based on finite-sample
averages becomes suspect. An example illustrates the problem.
Consider a single-server queueing model with independent exponentially distributed
interarrival times (finite mean and variance) and i.i.d. service times with finite mean but
infinite variance. It is known that an equilibrium distribution (3.34) for queue length exists in
this case but it has an infinite mean. Therefore, the limit (3.42) does not hold. The reason for
this anomaly is not hard to find. While PQq decreases monotonically to zero with increasing
q, it does so too slowly for the infinite sum (3.41) to converge.
where ~ B ( r) and ~ Q ( r ) denote zero-mean random variables that are independent of initial
conditions. Expressions (3.43) and (3.44) reveal that if one runs a simulation for s + r
simulated time units but uses the truncated sample paths {Q(x), s ::::: x ::::: s + r} and
{B(x), s ::::: x::::: s + r} to compute approximations Q(s, s + r) and B(s, s + r) of tLQ and
IJ.B, respectively, then Q(s, s + r) - tLQ and B(s, s + r) - tLB converge with probability one
3 .3 . CON D I T ION A LAN D EQUI LIB RI U M DIS T RIB UTI 0 N S 89
to zero-mean random variables that are independent of the state in which the simulation run
began execution. Most importantly, this property of asymptotic unbiasedness holds regardless
of the initial state chosen from T. Section 6.1 returns to this topic.
The relationships between Q (s, s + r) and tl. Q (r) and between B (s, s + r) and tl.B (r)
yield additional properties of interest. In particular,
and (3.45)
rE [B(s, s + r) - JLB]2 ~ rvartl.B(r) ~ a~(B) as r ~ 00,
where a~(Q) and a~(B) denote positive quantities. Therefore, for large r, Q(s, s + r) has
approximate mean-square error a~(Q)/r, and B(s, s + r) has approximate mean-square
error a~(B)/r, regardless of the length s of the warm-up interval. This observation raises a
question as to why we should concern ourselves with truncation at all. The answer is that for
two warm-up interval lengths S2 > Sl ::: 0, the mean-square errors converge more rapidly
to a~(Q)/r and a~(B)/r for S2 than for Sj, as r increases.
The properties
and (3.46)
rl/2 [B(s, s + r) - JLB] -! N(O, a~(B)) asr ~ 00,
where -! denotes convergence in distribution andN(al, a2) denotes the normal distribution
with mean al and variance az, provide the additionally essential ingredients for assessing
how well Q(s, s + r) and B(s, s + r) approximate JLQ and JLB, respectively, for large r.
Expression (3.46) asserts thatthe distributions of the statistics rl/2 [Q(s, s + r) - JLQ] and
r 1/2 [B(s, s + r) - JLB] both converge to normal distributions as the sample-path length r
increases without bound. As illustration of their importance for error assessment for queue
length, the first limit in expression (3.46) implies that the interval
(3.47)
includes the true unknown long-term average JLQ with approximate probability 1 - 8 for
large r, where
denotes the f3 -quantile of the standard normal distribution. A similar interval estimate exists
for JLB with B(s, s + r) and a~(B) replacing Q(s, s + r) and a~(Q), respectively.
90 CHAPTER 3. DATA COLLECTION AND AVERAGES
In practice, a~(Q) and a~(B) are unknown. However, under specified conditions it
is known that if a~(Q, r) and a~(B, r) are estimators of a~(Q) and a~(B), respectively,
that satisfy
as r ~ 00 w.p.I
and (3.48)
as r ~ 00 w.p.I,
NOTE
Limiting properties analogous to those in expressions (3.43) through (3.48) also hold
for PQ(q, s, s + r) as an approximation to PQq for each q = 0, 1, ... and for PB(b, s, s + r)
as an approximation to PBb for each b = 0, 1, ... , m.
With regard to data collection, analysis, and run termination, simulationists frequently
employ one of two options:
OPTION A
• Calculate and display summary statistics based on sample-path data collected on the
time interval [S, s + T].
OPTION B
Option A implies that the simulated time [s, s + T ] for data collection is predetermined
but that the number of jobs, N(s, s + T) = N (T) - N (s), completed in the time interval
is random. Conversely, Option B implies that the length of the simulated time interval,
(TM' TM+N]' is random but the number of jobs N ( TM' TM+N) = N is predetermined. Of the
two, Option B has more appeal inasmuch as it allows the simulationist the freedom to specify
how much completed work is to occur during the period of observation.
When Option B is employed, the sample average queue length is
(3.49)
where in addition to the sample path {Q(u), TM ::; U ::; TM+ N } being random, the length of the
sample path is also random. For finite M and N, this new source of randomness contributes
to the error of approximating fJ.Q by Q(TM , TM+J. Although the limiting properties that
Sections 3.3.2 through 3.3.4 describe all assume Option A, it can be shown under mild
additional qualifications that as N ~ 00 under Option B, limiting behavior analogous
to expressions (3.42), (3.45), and (3.46) again holds, and as M ~ 00, limiting behavior
analogous to expression (3.43) also holds.
Like properties hold for the sample average number of busy RESERVATIONISTs
(3.50)
We now turn to the estimation of the long-term average waiting time. The analysis proceeds
analogously to that for utilization and queue length, the differences being the discrete index-
ing of the sample path WI,"" WN(r), the continuous range [0, (0) for Wi, and the effect
of alternative modes of terminating the simulation (Section 3.4). Recall that
1
L
N(s+r)
W(s,s+r):= Wi (3.51)
N(s + r) - N(s) i=N(s)+1
_ 1 N(s+r)
Pw(w, S, s + r):= (
N s +r
) ()
- N s
L
i=N(s)+1
I(w.oo) (W;), 0::: W < 00,
the proportion of CUSTOMERs that wait longer than W time units for service. Most sim-
ulation languages either automatically compute or provide the means for computing the
waiting-time empirical distribution function {I - Pw(w, s, s + r), WE {WI> Wz > ... >
wr > O}}, for a user-specified integer r and WI, ... , W r .
Let {Fw (w), W :::: O} denote the equilibrium d.f. of waiting time. Under relatively
general conditions for Option B and for each fixed M,
(3.52)
I-Lw := 100
W dF(w) = 1 00
[1 - F(w)]dw < 00,
it follows that
(3.53)
Thus for each W :::: 0, Pw(w, r M , r M +N ) is a stongly consistent estimator of 1 - F(w) and
W(rM' r M+N) is a strongly consistent estimator of I-L w.
As in the case of queue length, the finiteness of I-L w holds for many simulation models.
However, it does not hold when the interarrival-time or service-time distributions do not
have finite first and second moments.
For finite N, an error arises in approximating {I - F (w), w :::: O} by Pw (w, r M' r M+N)
and I-Lw by W( r M , r M +N ). To facilitate the assessment of this error, we rely on additional lim-
3.5. WAITING TIME 93
iting properties. We describe them for W(.M' • M+N) and note that for each w ::: 0 analogous
limiting properties hold for Pw(w, .M' .M+N) as an approximation to 1 - F(w).
Under Option B, relatively general restrictions, and for finite N, we have
(3.54)
(3.55)
as N -+ 00. (3.56)
These results facilitate the derivation and computation of confidence intervals for ILw
in Section 6.6 based on replacing (1~(W) with a strongly consistent estimator provided by
the batch means method.
If Option A is employed for data collection, then expression (3.11) gives the sample
average waiting time where in addition to the sample sequences W N(sl+!, .•. , W N(s+rl being
random, the number of waiting times N (s + .) - N (s) is random, contributing one more
source of error to the approximation of ILw for finite sand •. Then under mild additional
qualifications, limiting properties similar to expression (3.54) hold as s -+ 00 and properties
similar to expessions (3.53) and (3.55) hold as. -+ 00. Also, a parallel development ensures
strong consistency and asymptotic normality for Pw(w, s, s + .) for each w ::: 0, and the
methods of Section 6.6 again apply.
Let A denote arrival rate. Then Little's law (e.g., Stidham 1974) states that for all
queueing systems for which ILQ, A, and ILw exist,
3.6 SUMMARY
This chapter has introduced the reader to the mechanics of calculating time and arithmetic
averages that serve as estimates of system performance measures. It has also alerted the reader
to the presence of errors, to ways of limiting them, and to the need to assess the extent of
remaining errors. In particular,
• Recursive expressions are available that minimize the need for data storage for
computing time and arithmetic averages during simulation execution.
Although computing the finite sample averages Q(s, s + T), PQ(q, s, s + T) for each q and
B(s, s + r), and PB(b, s, s + r) for each b in Sections 3.1.1 and 3.1.2 provides us with
estimates of their corresponding true long-run performance measures, these computations
do not provide the necessary data to compute assessments of how well the sample averages
approximate the true averages. If data collection begins at time s and ends at s + r, then the
techniques of Chapter 6 rely on the availability of sample-path sequences for j = 1,2, ... ,
1 [s+jll.
Qj:= - Q(u)du,
!:::.s+(j-l)ll.
1 [s+jll.
PQj(q):= !:::. I(q,oo)(Q(u»du, (3.58)
s+(j-l)1l.
1 [s+jll.
Bj:= - B(u)du,
!:::. s+(j-l)1l.
1 [S+jll.
PBj(b) := - I(b,m] (B(u»du j = 1, ... ,t:= Lr/!:::.J,
!:::. s+(j-1)1l.
3 .7 . PER I 0 Die D A T A COL L E CT ION 95
Collect
statistics
where I::!.. is a positive time increment chosen, ifpossible, to make L / I::!.. an integer. For example,
{QI> ... , Qt} provides the data needed to compute an estimate a;,(Q), of a;,(Q), which
together with Q(s, s + I::!..t) is used to compute an approximating confidence interval for
/LQ.
To collect these data at simulated time u after a warm-up interval s, we rely on a
periodically recurring event as in Figure 3.1, where we assume that the first COLLECT event
is scheduled at time u ::: s + I::!... For example, one approach gathers the data
Qj := Q(s + jl::!..),
P'U(q) := I(q,oo)(Q(s + jl::!..)),
Bj := B(s + jl::!..),
P~j := I(b,m] (B(s + jl::!..)),
f,s+(j-l)/1
S+j/1
Q
(
U
)d
U
-+ I as ~ -+ 0 w. p.I,
~ x Q (s + j~)
the error of approximation diminishes as the interval between observations, ~, decreases.
The appeal of this alternative approach is its simplicity, especially when the selected
simulation language does not provide an automated procedure for collecting the time-
integrated quantities (3.58).
• As the length of a simulation run '[' increases, the errors of approximation in sample
averages, due both to initial conditions and random sampling fluctuations, decrease.
That is, the values of the sample averages tend to converge to the values of the unknown
corresponding long-run averages.
• Under Option A, sample average waiting time and estimates ofits exceedance probabil-
ities are ratio estimates. Under Option B, sample averages of queue length and resource
utilization and estimates of their exceedance probabilities are ratio estimates. Error
analysis for ratio estimates calls for more detailed attention to sources of variation
than for simple sample averages. See Section 6.11.
• Little's law (Section 3.5.1) establishes a proportional equivalence between the long-
run averages of waiting time and queue length that can eliminate the issue of ratio
estimation.
3.9 REFERENCES
Stidham, S., Jr. (1974). A last word on L = AW, Oper. Res., 22, 417-421.
CHAPTER4
Converting modeling logic as in Chapter 2 into executable code is the next step in simulation
program development. To this logic must be added all the housekeeping functions of assign-
ing values to input parameters and arranging for the desired output to emerge at the end
of program execution. This chapter illustrates these steps, first using the SIMSCRIPT 11.5
simulation programming language and then the Arena general-purpose simulation system
based on the SIMAN simulation language. It also describes how the resulting programs are
executed and displays their output.
A survey in Swain (1999) reveals at least 54 products for performing discrete-event
simulation on a computer. These vary widely in the ways they allow program creation.
Moreover, variations exist in how a program, regardless of program-preparation modality,
is converted to executable code and how the mode of conversion affects portability and
execution time. Portability denotes the extent to which a program is executable on different
hardware platforms. Section 4.1 describes several modalities for program creation. When
viewed as special cases of this account, subsequent sections based on SIMSCRIPT 11.5 and
Arena/SIMAN take on considerable more meaning for the reader.
100 CHAPTER 4. PROGRAMMING AND EXECUTION
Create program
(a) Translated
via textual
directly into
entry binary code
Create program
(b)
via textual
entry
Modality (c) mimics Modalities (a) and (b) with one major difference. Templates of
icons are displayed on the screen, one for each language statement or block. The simulationist
merely points, clicks, drags, and drops the blocks into a "model window" and connects them
to create a source program. Currently, this is the most commonly employed modality, and
Arena/SIMAN, AweSimlVisual SLAM, and SIMLAB/SIMSCRIPT u.s all permit this option
on Windows-based PCs. Section 4.25 illustrates the concept with Arena/SIMAN.
In principle, Modality (d) performs as Modality (c) with one important difference.
The icons in the tableaus correspond to macromodules each of which represents a sequence of
simulation-language statements or blocks. For example, an "Arrive" macromodule includes
all statements associated with bringing new items into a system. A "Server" macromodule
includes all statements related to providing an item with service. Combining Modalities
(c) and (d) enables a simulationist to flesh out a program that macromodules alone cannot
create. Arena/SIMAN and AweSimlVisual SLAM offer this option, whose ostensible purpose
is to reduce the required language familiarity that a simulationist must have to construct a
program. Section 4.24 illustrates the concept for Arena/SIMAN.
Some macromodules in Modality (d) are relatively complex in content. For example,
the availability of macromodules that represent the behavior of conveyors and automatic
guided vehicles (AGV) to move items within factories and warehouses, automated storage
102 CHAPTER 4. PROGRAMMING AND EXECUTION
and retrieval systems (ASRS), robots, and bridge cranes considerably reduces programming
effort in building simulations of manufacturing and materials handling systems.
Modality (e) represents a strategy for packaging many of these special-purpose tasks
that, for example, manufacturing requires into a moderately large collection of macromod-
ules that correspond directly to off-the-shelf precompiled C++ subprograms or rely on a
C++ translator for object-program creation. This eliminates any reliance on a simulation
language per se. Many software offerings that cater to specialized modeling rely on this op-
tion. Its purpose is to attract potential users with limited or no knowledge of a simulation
programming language by reducing the barriers to entry. While the benefit is immediately
clear, a disadvantage emerges when a simulationist employs software that, while easy to use,
does not have the flexibility to represent the exact flow logic in her/his model. Virtually
all simulated software offers an option that allows a simulationist to merge user-created
programs with user-written code in C, C++, or other high-level language. Presumably this
would be the option one would have to take to overcome the limitation of Modality (e).
Since this approach requires a simulationist to be an able programmer in the selected lan-
guage, it undermines the philosophy of "no programming required." Because of this barrier,
some simulationists merely alter the original concepualization of their systems to make them
amenable to representation in terms of the iconized blocks and modules that their selected
simulation software offers. Although the extent to which this action undermines the quality
of a study varies from problem to problem, the practice is lamentable, at a minimum, and
jeopardizes scientific integrity, at worst. Section 4.27 describes potential pitfalls.
Rather than clarity of concept, today's highly interactive PC environment demands
rapidity in moving from a less than completely thought -through concept to execution. While
speed of creation is important, a large-scale discrete-event simulation with intricate flow-
logic inevitably requires some awareness of the nuts and bolts of simulation programming.
This is especially true if a program is to be used repeatedly in a computationally efficient way.
The extent to which pedagogy that focuses on this rapid movement from concept to execution
prepares the newcomer to simulation to address issues of model size and complexity is
debatable. There is a more basic issue.
The point-and-click approach also encourages a simulationist to skip the preliminary
steps in Sections 2.3 and 2.4 that explicitly identify events and flow logic in favor of creating the
model directly on the PC screen and, at the click of the mouse, converting the representation
to executable code. Although this protocol may work well for problems of small and moderate
size, large problems with complex flows present a challenge that is most easily met with
deliberate attention to the steps in Sections 2.3 and 2.4 prior to program creation. While
especially true for the student just learning simulation methodology, experience indicates
that more seasoned simulationists can also benefit from this focus on fundamental principles.
Accordingly, our discussion of SIMSCRIPT II.S relies heavily on the event-scheduling and
process-interaction approaches of Chapter 2. Our discussion of Arena/SlMAN focuses on
the process-interaction approach with passive resources.
Regardless of the extent of embeddedness, every discrete-event simulation program-
ming language provides a user with a syntax that supports either the process-interaction or
4 .2 . S I M SC RIP T II. 5 103
guage, the subprograms illustrate concepts, but not necessarily the most efficient coding. The
advantages of illustrative versus tightly written subprograms should not be underestimated.
SIMSCRIPT 11.5 represents the latest in a sequence of discrete-event simulation lan-
guages that use the SIMSCRIPT title. Markowitz, Karr, and Hausner (1963) developed the
original SIMSCRIPT at the Rand Corporation. SIMSCRIPT II, which represents a consid-
erable extension of the original features and capabilities, was developed at Rand by Kiviat,
Villanueva, and Markowitz (1969). SIMSCRIPT 11.5 is a substantial enhancement of SIM-
SCRIPT II supported by CACI (1987, 1993a, 1993b, 1997). All examples described here are
based on SIMSCRIPT 11.5.
The language has a compiler and is divided into five levels:
LEVEL 2. A language roughly comparable in power to FORTRAN but departing greatly from
it in specific features.
LEVEL 3. A language roughly comparable in power to C or PASCAL but again with many
specific differences.
LEVEL 4. That part of SIMSCRIPT 11.5 that contains the entity-attribute-set features of
SIMSCRIPT. These features have been updated and augmented to provide a more
powerful list-processing capability. This level also contains a number of new data
types and programming features.
LEVEL 5. The simulation-oriented part of SIMSCRIPT 11.5, containing statements for time
advance, event processing, generation of statistical variates, and accumulation and
analysis of simulation-generated data.
By providing the features in level 5, SIMSCRIPT 11.5 relieves the user of the need
to provide these special-purpose routines. Indeed, every simulation programming lan-
guage provides these features, thereby giving them a considerable edge over general-purpose
programming languages.
The principal building blocks of SIMSCRIPT 11.5 are entities, attributes, and sets.
Entities denote objects of a system; attributes, characteristics of the entities; and sets, entity
groupings or lists. Figure 4.2 contains a SIMSCRIPT 11.5 program that incorporates the logic
specified in Figures 2.5 through 2.8 based on the event -scheduling approach. For convenience
ofexposition, we adopt the convention that all lowercase words denote SIMSCRIPT 11.5 code,
whereas all uppercase words denote user-defined concepts. In general, SIMSCRIPT 11.5
makes no distinction between lower- and uppercase letters. Occasionally, we use quotation
marks in the text to identify SIMSCRIPT 11.5 keywords. Line numbers are for the benefit of
the reader and should not appear in an executable version of this program. SIMSCRIPT 11.5
statements can begin in any column.
4 .2. S I M SC RIP T II. 5 105
Every SIMSCRIPT II.5 program written to execute a simulation begins with a nonex-
ecutable subprogram called a preamble that defines the system's entities, attributes, sets, and
the relationships among them. It also defines all global variables and functions accessible
to all executable components (events and subroutines) within the program. In Figure 4.2,
line 2 of the preamble indicates that unless otherwise specified all variables are assumed to
have integer mode. Line 3 declares the existence of a set called QUEUE, which is the only
nonSIMSCRIPT II.5 word there. We may call this set QUEUE, LIST, or any other name we
like, provided that we avoid using the names of specified SIMSCRIPT II.5 system variables.
Upon encountering this set declaration for QUEUE in the preamble, SIMSCRIPT II.S
implicitly defines a global variable, n.QUEUE, that serves as the number of elements in the
set. During execution, SIMSCRIPT II.S updates n.QUEUE each time that either an addition
or deletion is made. Initially, n.QUEUE is set to zero. More generally, for each set declared
in a preamble, SIMSCRIPT II.5 defines a global variable with the same name prefaced by n.
Global variables are accessible from anywhere in a SIMSCRIPT II.5 program, in contrast to
local variables, which are accessible only from within the subprogram that defines them.
,,------------------------------------------------------------------
PREAMBLE
,,------------------------------------------------------------------
1 preamble
2 normally mode is integer
3 the system owns a QUEUE
4 permanent entities
5 every RESERVATIONIST has a STATUS
6 define NO.BUSY as a variable
7 accumulate AVE.UTIL as the average, V.UTIL as the variance and MAX.UTIL
as the maximum of NO.BUSY
8 accumulate UTIL.HISTO (0 to n.RESERVATIONIST by 1) as the histogram
of NO.BUSY
9 accumulate AVE.Q as the average, V.Q as the variance and MAX.Q as the
maximum of n. QUEUE
10 accumulate Q.HISTO (0 to 32 by 1) as the histogram of n.QUEUE
11 temporary entities
12 every CUSTOMER has a TYPE, a START and may belong to the QUEUE
13 define START and WAITING. TIME as double variables
14 tally AVE. WAIT as the mean, V.WAIT as the variance and
MAX. WAIT as the maximum of WAITING. TIME
15 tally WAIT.HISTO (0 to 8 by .25) as the histogram of WAITING. TIME
16 define ZERO. WAIT as a variable
,,----------------------------------------------------------------------
MAIN
,,----------------------------------------------------------------------
1 main
2 open unit 10 for input
3 open unit 15 for output
4 use unit 10 for input
5 use unit 15 for output
6 read LAMBDA,OMEGA,M and P INITIALIZE
" PARAMETERS
7 if RRHO>=1.0 print 1 line thus
ERROR-----ACTIVITY LEVEL>=l ERROR CHECK
8 stop PARAMETERS
9 otherwise
10 reserve SEEDS(*) as 4
11 for 1=1 to 4 do
12 read seed. v(I) ASSIGN SEEDS
13 let SEEDS(I)=seed.v(I) SAVE SEEDS
14 loop
15 read T and K
16 let NUM=1
,,-----------------------------------------------------------------
event CALL
,,-----------------------------------------------------------------
1 event CALL saving the event notice
2 define ACTION as an integer variable
3 define T.CALL to mean exponential.f(1./LAMBDA,1)
4 create a CUSTOMER
5 let TYPE=KIND
6 let START(CUSTOMER)=time.v
7 reschedule this CALL in T.CALL minutes
8 call SERVICE yielding ACTION
9 if ACTION=NO.SUCCESS
10 schedule an END_MESSAGE given CUSTOMER in .15 minutes
11 else
12 add 1 to ZERO. WAIT
13 always
14 return
15 end
,,------------------------------------------------------------
routine KIND
,,------------------------------------------------------------
routine KIND
2 if random.f(4) < P
3 return with MANY
4 else
5 return with ONE
6 end
,,-----------------------------------------------------------
event END_MESSAGE
,,-----------------------------------------------------------
event END_MESSAGE given CALLER
2 define ACTION and CALLER as integer variables
3 let CUSTOMER=CALLER
4 call SERVICE yielding ACTION
108 CHAPTER 4. PROGRAMMING AND EXECUTION
5 if ACTION=NO.SUCCESS
6 file CUSTOMER in QUEUE
7 else
8 always
9 return
10 end
,,-------------------------------------------------------------
event COMPLETION
,,-------------------------------------------------------------
1 event COMPLETION given CLIENT and WORKER
2 define ACTION , CLIENT and WORKER as integer variables
3 destroy CUSTOMER called CLIENT
4 if QUEUE is empty
5 let STATUS(WORKER)=IDLE
6 let NO.BUSY=NO.BUSY-1
7 return
8 always
9 remove the first CUSTOMER from QUEUE
10 let RESERVATIONIST=WORKER
11 call SERVICE yielding ACTION
12 return
13 end
, ,---------------------'------------------------------------------
" routine SERVICE
,,---------------------------------------------------------------
1 routine SERVICE yielding ACTION
2 define ACTION as an integer variable
5 i f none
6 let ACTION=NO.SUCCESS
7 return
8 else
9 let STATUS=BUSY
10 add 1 to NO.BUSY
11 always
,,---------------------------------------------------------------
,,---------------------------------------------------------------
1 routine S_TIME
2 if TYPE= MANY
4.2. SIMSCRIPT 11.5 109
,,---------------------------------------------------------------
routine ACCOUNTING
,,---------------------------------------------------------------
1 routine ACCOUNTING
2 define DEAD. TIME as a double saved variable
3 if NUM=K
4 reset totals of NO.BUSY,WAITING.TIME and n.QUEUE
5 let ZERO. WAIT = 0
6 let DEAD.TIME=time.v
7 always
8 i f NUM >= K
9 let WAITING.TIME=1440.*(time.v-START(CUSTOMER))
10 always
11 if NUM=K+T-1
12 call SUMMARY(DEAD.TIME)
13 stop
14 always
15 add 1 to NUM
16 return end
,,---------------------------------------------------------------
routine SUMMARY
,,---------------------------------------------------------------
routine SUMMARY(DEAD.TIME)
2 define DEAD. TIME as a double variable
3 define RUN. TIME to mean (time. v-DEAD. TIME)
4 define DUM1,DUM2 and DUM3 as double variables
5 start new page
6 skip 1 line
7 print 7 lines with M,LAMBDA,OMEGA,P,RRHO,K-1 thus
MULTIPLE-
DESTINATION PROB.=*.*** ACTIVITY LEVEL=*.*** NO. TRUNCATED=******
8 skip 1 lines
9 print 1 line with NUM-K+1 and RUN.TIME thus
4.3 ENTITIES
As in line 4 of the preamble, the words "permanent entities" must preface declarations
relating to such entities. Here the declared permanent entity RESERVATIONIST has an
attribute STATUS. The significance of this attribute becomes apparent later when we search
for an idle RESERVATIONIST. For each permanent entity, SIMSCRIPT 11.5 implicitly defines
a global variable n.entity. This quantity denotes the number of such entities in existence
at a specific time during execution. In the present case, n.RESERVATIONIST serves this
purpose. We assign it a positive integer value in the "main" program, prior to beginning
a simulation run. The words "temporary entities" (line 11) preface declarations relating to
such entities. Notice in line 12 that the temporary entity CUSTOMER has an attribute TYPE
and may be a member of the set QUEUE, defined in line 3. TYPE allows for identification
of a CUSTOMER as requesting a one-way or a round-trip reservation. Failure to assign any
membership to a declared set results in a diagnostic error message during compilation.
The words "event notices" in line 17 of the preamble prefaces such declarations. However, as
lines 17 through 19 indicate, two ways exist for declaring these notices. If the COMPLETION
and END...MESSAGE event notices were to have no attributes, then we could replace lines
17 through 19 by
apply.
Note the use of the underscore in END ...MESSAGE. This acceptable use in SIMSCRIPT
11.5 provides a convenient way of making variable names more comprehensible to readers.
Also note the use of the period in line 6 of the preamble, which improves comprehension.
In this book we adopt the convention of using an underscore in the names of events and
routines and using a period in entity, attribute, and variable names. Although entity names
can have as many characters as one wishes, the first seven characters in the name of a routine,
global variable, or attribute must be unique, as must be the first five characters in the name
of an entity, event, or set.
Since two events may be scheduled for execution at the same time, the declaration in
line 20 removes any ambiguity regarding the order of execution. This statement indicates
that a CALL event has priority over COMPLETION and END...MESSAGE events and that
112 CHAPTER 4. PROGRAMMING AND EXECUTION
a COMPLETION event has priority over END~ESSAGE events. If two CALL events are
scheduled for the same time, SIMSCRIPT 11.5 executes them in the order in which their
corresponding events notices are created. Suppose that the priority declaration is
Then SIMSCRIPT 11.5 implicitly assigns priority in the order END~ESSAGE, CALL, and
COMPLETION. After ordering priorities as specified in the "priority order" statement,
SIMSCRIPT 11.5 goes back to the "event notices" statement and assigns successive priorities
to events declared there but omitted from the "priority order" statement. These priorities are
assigned in the order in which the events are declared. Note that in the present case omission
ofline 20 would not affect the priority order. Its value here is pedagogic.
the time averages that Section 3.1 describes. Section 4.14 shows how inclusion of a "reset"
statement allows one to adjust these averages to account for the warm-up interval.
SIMSCRIPT 11.5 responds to a request for values of MAX.UTIL, MAX.Q, and
MAX.WAIT by computing
and to a request for the time variances V.UTIL and V.Q, and the variance V.WAIT, by
computing
(4.3)
By default, NO. BUSY has integer mode, whereas WAITING.TIME is a double precision
floating-point variable. An alternative would be to define WAITING. TIME as a "real vari-
able;' which would make it a single-precision floating-point variable. To reduce numerical
round-off error, we encourage double-precision declarations on 32-bit wordsize computers.
Line 8 of the preamble declares that SIMSCRIPT U.5 is to create a histogram of
NO.BUSY, and line 10 does likewise for n.QUEUE. SIMSCRIPT u.s responds to requests
for values of these histograms by computing
J(r)
UTIL.HISTO(I) = 8(B(r) - I + l)(r - tJ(r» + L8(B(ti-l) - I + l)(ti - ti-I),
i=1
1= 1, ... , n.RESERVATIONIST + 1, (4.4)
and
L Q.HISTO(I),
32
r - 1=33,
1=1
where
if x = 0,
elsewhere.
Then UTIL.HISTO(I)/r gives the proportion of time that 1-1 RESERVATIONISTS are busy
for 1 :::: I :::: 33, and Q.HISTO(I) gives the proportion of time that I-I CUSTOMERs await
service for 1 :::: I :::: 32. The remaining ordinate, Q.HISTO(33), contains the amount of time
that 32 or more CUSTOMERs await service.
114 CHAPTER 4. PROGRAMMING AND EXECUTION
1 b
PB(b, 0, r) = 1 - - LUTIL.HISTO(I) (4.6)
r 1=0
= proportion of time that more than b
RESERVATIONISTs are busy
and
1 q
PQ(q, 0, r) = 1 - - L
Q.HISTO(I) (4.7)
r 1=0
= proportion of time that more than q
CUSTOMERs wait.
I
In a similar manner, the declaration in line 15 of the preamble leads to
where
If waiting times are recorded in minutes, then at time r, WAIT.HISTO(I) contains the
number of CUSTOMERs whose waiting times were at least 0.25(1-1) but less than 0.251
minutes for 1=1, ... , 32, and WAIT.HISTO(33) contains the number of CUSTOMERs with
waiting times of at least eight minutes. With regard to the exceedance proportion (3.14),
recall that for all W E [0, (0),
whereas
1
L
lw/.25J
1 - -- WAIT.HISTO(I) = proportion of waiting times::: w. (4.10)
N(r) 1=1
4.6. TRAFFIC INTENSITY 115
As line 12 of the CALL event shows, the integer variable ZERO.WAIT in line 16 of the
preamble accumulates the total number of CUSTOMERs who do not wait, and therefore
ZERO.WAIT .
1- N (r:) = proportion of CUSTOMERs who Walt. (4.11)
We use expressions (4.1 0) and (4.11) in the output. Since waiting time has a continuous
distribution function for all w > 0, the difference between the values that expressions (4.9)
and (4.10) generate should be negligible.
be described shortly. The use of line 24 provides us with a convenient way of expressing
RRHO, which corresponds to p in expression (4.12), concisely. When exact evaluation of p
is not possible, computable lower and upper bounds PL and Pu' respectively, can be useful.
If PL > 1, then P > 1; conversely, if Pu < 1 then P < 1.
We now consider the existence of the recorded message. Ifthe simulation runs for a long
period of time, then the number of calls that become available for service is independent
of the time delay due to the recorded message. Then A is the long-run arrival rate, and
consequently the activity level defined in expression (4.12) continues to apply.
If one is simulating a closed-loop system, then the traffic intensity is always less than
unity and no need exists for evaluating p. However, p < 1 in this case does not necessarily
imply a unique equilibrium distribution.
Line 31 defines SEEDS as a global one-dimensional array having an integer mode
because ofthe global declaration in line 2. Line 32 declares an integer function that determines
whether a one-way or round-trip reservation is desired. Line 33 also defines a double-
precision function S_TIME. We describe the contents of the KIND and S_TIME functions
shortly. Functions are similar to, but not identical to, routines. In the particular case of lines
32 and 33 we note that the subprogram associated with S_TIME has a double mode as a
result of the inclusion of "double" before "function." However, the function KIND has the
integer mode because of the default to line 2. The "end" statement tells the SIMSCRIPT 11.5
compiler that all global declarations have been made and what follows is the executable part
of the program.
The "main" routine is the first subprogram that SIMSCRIPT 11.5 executes. After defin-
ing input and output units in lines 2 through 5, it reads values (line 6) for LAMBDA, OMEGA,
M, and P from the specified input unit using a free-form format. Lines 7 through 9 execute
an error check using RRHO (line 24 of preamble) and demonstrate a simple "if" statement.
Theorem 4.1.
LetX bea random variable with distribution function (d.f) {F(x), a ::;: x ::;: b}, denoted
byF. Let
which is called the inverse distribution function of X, and let U have the uniform distribution
on [0, 1], denoted brU(O, 1). Then G(U) has the d.f. F.
This result has immediate implications for sampling from F. For continuous F, one can
sample U from U (0, 1) and solve F(X) = U for X. For example, if F(X) := 1 - e- AX for
° t
A > and x ~ 0, then X = - !n(I - U) has the exponential distribution with rate A. If
F is discrete with points of increase at, say, a, a + 1, ... , b - 1, b and F (a - 1) := 0, then
X = a + I is distributed as F, where
Chapter 8 describes other methods for generating random samples, all of which pre-
sume the availability of a sequence of independent random samples from U (0,1). To
approximate this idealization, every simulation language provides a procedure for gener-
ating a sequence {Ui := ZdM, i = 1,2, ... } where Zo, Zb Z2,'" are integers often
derived from the one-step recursion
Here A and M are integers selected to make the points {Ud sufficiently dense in (0, 1) and
to have distributional properties that "closely" resemble those of the idealized i.i.d. uniform
sequence. Expression (4.13) is called a pseudorandom number generator (png). GPSS/H,
SIMAN, SLAM, and SIMSCRIPT 11.5 all use pngs of this form.
To initialize the png at the beginning of a simulation experiment, one provides a seed
°
Zo for expression (4.13). This seed dictates the subsequence of numbers that expression
(4.13) generates during execution. SIMSCRIPT 11.5 actually has 1 pseudorandom number
streams, each of which requires a seed. The seed for stream I is stored in a system variable
seed.v(I), which assumes a default value if none is assigned by the user. Although Chapter
9 deals with issues related to pseudorandom number generation in detail, it is important
that the reader now recognize that well-designed computer simulation experiments call for
explicit identification of the first and last pseudorandom numbers used in each stream that
an experiment employs. One reason is reproducibility.
Recording the seeds, which are the first pseudorandom numbers used, enables one to
run a related experiment with the exact same stream of numbers but different values for
other input parameters, and then to compare experimental results with one major source of
variation, the differences in pseudorandom numbers, removed. Section 4.22 returns to the
118 CHAPTER 4. PROGRAMMING AND EXECUTION
topic of "common pseudorandom numbers" and shows how they can reduce the computing
time to compare the output of two runs of a simulation, with different input values for one
of its parameters, to within a given statistical accuracy.
Line 10 in the main program reserves space for the array SEEDS (line 31 of preamble).
Lines 11 through 14 read four user-specified seeds into the SEEDS array and then assign
SEEDS(I) to seed.v(I). Thus SEEDS(I) contains the first random number used in stream I.
When the simulation terminates, seed.v(I) contains the seed to be used in the next generation
from stream I. In particular, stream 1 generates pseudorandom numbers for interarrival
times, stream 2 for service times for single-destination trips, stream 3 for the additional
service time for multiple-destination trips, and stream 4 for determining values for TYPE.
The "loop"statement in line 14 demarcates the end of the DO loop that begins in line 11.
For a given integer I::::: 1, the statements
release seed.v(*)
reserve seed.v(*) as I
cause SIMSCRIPT 11.5 to resize seed.v. This would be required if I > 10 and should be
inserted in the main program prior to assigning seeds to seed.v.
SIMSCRIPT 11.5 allows coding of more than one statement on a single line. For
example, we could have written lines 11 through 14 as
decimal days. Since this action occurs at the beginning of execution and since SIMSCRIPT
II.5 initializes all system and declared variables to zero, time. v = 0.0 at this point in simulated
time.
pr( U ::::: p) = 1
P du = p. (4.14)
Line 6 of the CALL event assigns to START (CUSTOMER) the current simulated
time time.v. This will be used later to compute the CALL's waiting time. Line 7 directs
SIMSCRIPT 11.5 to use the event notice that generated the current execution of this CALL
event to schedule the execution of the next CALL event in T.CALL (line 3) minutes. Here
"reschedule" is syntactically equivalent to "schedule:' If"a" replaces "this;' then SIMSCRIPT
U.5 creates a new event notice. This difference is important with regard to program efficiency.
Use of "a" requires SIMSCRIPT 11.5 to find and allocate space to the new event notice. Use
of "this" eliminates this often time-consuming search and allocation procedure. The reader
should note that in order to use the CALL event notice again, the words "saving the event
notice" must appear in line 1. Otherwise, SIMSCRIPT 11.5 destroys the event notice when
execution of the corresponding event is about to begin.
Note also in line 7 that the event is scheduled to occur in T.CALL minutes. Since time.v
is in double-precision decimal days, the use of "minutes" causes SIMSCRIPT 11.5 to schedule
the next CALL in time.v+ T.CALL/1440.0 days, since there are 1440 minutes in a day. For
consistency CALL.RATE and SERVICE.RATE, read in the main subprogram, must be in calls
per minute.
4.13. FI LIN G PRIO RI TIE S 121
When an END~ESSAGE event executes, its local variable CALLER contains the identifi-
cation of the CUSTOMER assigned in the schedule statement in line 10 of the CALL event
made at time time.v- .15/1440 days. Assignment of this identification to the global variable
or entity CUSTOMER in line 3 is necessary because during the elapsed time a new CALL
event may have occurred, and hence CUSTOMER may refer to a new entity. If an attempt
at service (line 4) fails again (line 5), then the CUSTOMER is filed in the set called QUEUE.
Ifline 12 of the preamble had failed to mention that a CUSTOMER could belong to the
set QUEUE, then the "file" statement here would induce an error message during execution
indicating an attempt to file an entity in a set for which no corresponding membership dec-
laration exists. In lieu of explicit declaration to the contrary in the preamble, CUSTOMERs
are filed in the order in which they encounter this file statement.
after line 12 in the preamble. Then an encounter of the file statement in line 6 of the
END~ESSAGE event would cause an ordering first on TYPE, with one-way trips coming
first, and then, if ties occur, an ordering on time of filing. In the problem under study
the present preamble declares behavior closer to reality than the example given here does.
However, other contexts may call for the use of alternatives similar to this example.
Several additional issues deserve attention. Suppose that we deletelines 11, 12, and 13 of
the preamble and line 4 of the CALL event. Then the event notice CALL could serve as a record
of a temporary entity instead of CUSTOMER, "a" would replace "this" in line 7 of the CALL
event, and CALL would replace CUSTOMER in lines 3 and 6 of the END_MESSAGE event.
The reader should recognize that an event notice is a specialized temporary entity and can
function as such in many convenient ways. Although no great computational improvement
122 CHAPTER 4. PROGRAMMING AND EXECUTION
accrues from this alternative approach here, situations may arise in practice where it is
desirable to keep the number of temporary entities to a minimum. Note that set membership
for CALL in QUEUE must also be declared.
The local variable ACTION in the END~ESSAGE event is not the same as the local
variable ACTION in the CALL event. We chose the same labels to demonstrate that two or
more subprograms can have local variables with the same names. In fact, a local variable
can have the same name as a global variable, provided that the subprogram contains an
appropriate "define" statement. For example, if we include
in the END~ESSAGE event, the local variable RRHO would be distinct from the global
variable RRHO defined in the preamble.
Line 3 of the COMPLETION event instructs the simulation to release the space occupied by
the record of the temporary entity CUSTOMER called CLIENT. Failure to release space in
this manner may cause the simulation to run out of space when it needs to create records of
new temporary entities. Line 4 indicates that if the set QUEUE is empty, then the RESER-
VATIONIST called WORKER should have his attribute STATUS set to IDLE. Because of line
24 of the preamble, this action is equivalent to
let STATUS(WORKER) = 0 .
Lines 4 through 7 of the COMPLETION event imply that if no CUSTOMERs await service,
then NO.BUSY should be reduced by 1, the corresponding RESERVATIONIST should be
put in the idle mode, and control should return to the timing routine.
Recall that the prefix n. before a set name denotes the number of entries currently in
that set. Therefore, n.QUEUE denotes the number of CUSTOMERs in the QUEUE, so that
the statement
if QUEUE is empty
is equivalent to
if n.QUEUE =0.
The programmer has her or his choice of which to use.
If the set QUEUE is not empty in the COMPLETION event, then control passes to
line 9, where the "first" CUSTOMER is removed, since he or she is about to receive service
4.14. COMPLETION EVENT 123
from the RESERVATIONIST with name WORKER who has just completed service. Failure
to include line 9 results in an increasing list length even though CUSTOMERs receive service.
The assignment of the name WORKER to the entity name RESERVATIONIST is neces-
sary if the SERVICE routine is to work correctly. The quantity event.v is a system variable that
contains the class number i.event of the event that began execution last. Class numbers are
assigned according to the priority order statement in the preamble. Class numbers for CALL,
END~ESSAGE, and COMPLETION are i.CALL, i.END_MESSAGE, and i.COMPLETION,
respectively, and assume values of 1,3, and 2, respectively. Now all three classes of events call
the SERVICE routine. In case of CALL and END_MESSAGE, a search for an idle RESER-
VATIONIST is necessary in lines 3 and 4 of the SERVICE routine. For a COMPLETION,
control passes to line 9, since the RESERVATIONIST is already known. S_TIME is a function
that we describe shortly.
If no RESERVATIONIST is idle (line 5), then the routine yields NO.SUCCESS, which
is 1, according to the preamble. When success occurs, RESERVATIONIST denotes the idle
server whose STATUS we want to change from IDLE to BUSY. Note that
is equivalent to
again demonstrating the implicit subscripting ability ofSIMSCRIPT 11.5. However, note that
substitution of the statement
in line 5 of the COMPLETION event would probably cause an error, since there is little
likelihood that RESERVATIONIST = WORKER because of the passage of time. Line 10 of
the SERVICE routine merely increments the user-defined variable NO.BUSY by 1.
Line 12 indicates the scheduling of a COMPLETION for the current value of RESER-
VATIONIST. Line 13 calls a user-written subroutine ACCOUNTING that checks on the
progress of the simulation with respect to truncation, computes WAITING.TIME for the
CUSTOMER entering service ifNUM ::: K, and updates NUM. Line 14 of COMPLETION
assigns SUCCESS to ACTION for the benefit of the calling event.
The S_TIME subprogram determines service time from the Erlang distribution in
line 3 for a multiple-destination trip and from the exponential distribution in line 5 for a
one-stop trip. Note that S_TIME is double precision. Failure to make this declaration in the
preamble would result in S_TIME being treated as integer. SIMSCRIPT 1I.5's structured "if"
statement has the form
[2
K
+. L
J(T) ]
B2(ti_d(ti - ti-l) - (AVE.UTIL)2,
,=J(TK_1)+1
J(T)
UTIL.HISTO(I) = 8(B(r) - I)(r - tJ(T») + L 8(B(ti-d - 1+1) (4.18)
i=J(TK_1)+1
Y.Q = 1
r - r
Q
K_ 1
[2 (r)(r - tJ(T») (4.20)
+. L
J(-r) ]
Q2(ti_l)(ti - ti-l) - (AVE.Q)2,
,=J(TK_1)+1
L Q.HIST(l),
32
r - 1=33,
1=1
4.15. GETTING AN EXECUTABLE PROGRAM 125
1
L
N(r)
AVE.WAIT = Wi, (4.23)
+1
II: W?-
N(r) - N(rd i=N(rK)
V.WAIT = 1 [N(r)-N(rKH1](AVE.WAIT)2},(4.24)
N(r)-N(rK) i=N(rKl
N(r)
L
i=N(rK)
h25(I-I),.25I] (Wi), 1= 1, ... , 32,
WAIT.HISTO(I) = (4.26)
N(r)
L /[32,00) (Wi), 1=33.
i=N(rKl
In the present case, note that N (rK ) = K and N (r) = K + T - 1. Also note that line 5
reinitializes ZERO.WAIT.
Line 6 records the current time that the SUMMARY subroutine needs to normalize
the time-integrated statistics properly. Note that line 2 defines DEAD. TIME as a double-
precision saved variable. The qualifier "saved" ensures that DEAD.TIME retains its value
between successive calls to ACCOUNTING. Omission of "saved" would cause DEAD.TIME
to be initialized to zero at the beginning of each execution of ACCOUNTING.
If NUM = K + T - 1, then the simulation has been executed for the number of
customers K + T - 1 specified in the main routine. It then calls the SUMMARY subroutine,
which prints out all input parameter values in its line 7, all summary statistics in lines 9
through 21, and then prints the user-specified input seeds and the final numbers for each
pseudorandom stream in line 22. The "stop" statement in line 13 of ACCOUNTING provides
one way to terminate the simulation's execution.
has scanned, and execution terminates. For example, an error in the preamble usually causes
a scan termination before the executable portion of the program is reached.
Alternatively, the compiler scans the program, and, if the level of error is below that
for scan termination, SIMSCRIPT 11.5 produces an object program that is storable in a
user-specified file. The compiler also produces a listing of the entire source program with
appropriate error messages. A natural question to ask is: What happens to statements with
errors? SIMSCRIPT 11.5 ignores them during compilation, even though object programs
are created for every subprogram. Consequently, the object programs corresponding to
subprograms with errors are worthless and should be discarded. When the user examines
her/his program listing, she/he identifies the errors, corrects them in the source program,
and attempts to recompile the program successfully.
SIMSCRIPT 11.5 also allows a user to compile and execute a program all in one sub-
mission. The appeal is apparent. If compiler-detected errors exist in the program, execution
usually terminates with an execution error message. Such error messages also may occur when
no compilation errors arise, since the user may have failed to construct an internally consis-
tent executable program. During execution, stategically user-placed LIST statements in the
source program can provide information about entities, attributes, sets, and other variables.
In addition to the diagnostic at compilation, SIMSCRIPT 11.5 also provides SIMDEBUG
for tracing the sequence of routine calls during a simulation that lead to an execution error
(CACI 1993b). Invoking the -d option at compilation enables this capability for subsequent
program execution.
Unless a user has considerable confidence that the source program contains no errors
detectable during compilation, he/she is well advised to use this combined compilation and
execution procedure sparingly. This advice follows as a consequence of the mandatory link-
age editing step that follows the compilation step and precedes the execution step. The linkage
editing step links the object program together with a series of routines in the SIMSCRIPT
11.5 library that are needed for execution but have not been previously incorporated. These
routines differ from those automatically compiled into the object deck. For example, in our
. airline program there are more than 50 such routines, including those for Erlang, exponen-
tial, and uniform variate generation. The combined object program plus SIMSCRIPT 11.5
routines form a load module. Linkage editing takes time, and a user who repeatedly uses
the compilation and execution option with a program with probable compilation errors is
wasting time.
We wish to point out that once a program has been successfully compiled and executed
the linkage editing step can be avoided on future runs. To accomplish this a user submits his
object program for linkage editing and then stores the resulting load module in a predesig-
nated file. To execute the program one submits instructions to take the load module from
the data set and execute it. This procedure takes negligible time.
This relatively brief description of SIMSCRIPT 11.5 creates a familiarity, not an in-
timacy, with the language. The reader who intends to do the SIMSCRIPT 11.5 exercises in
this book will find regular access to the CACI references indispensable for success. More-
over, thorough understanding of the process of conversion of a source program written in
4.16. A FIR S T RUN 127
SIMSCRIPT II.5 into an object program coded in the basic machine language of the computer
can lead to considerable cost saving and to reduced frustration in trying to get an executable
object program. We describe several issues deference to which should reduce the needed
effort.
main
program
Line 6 provides the input for the "read" statement in line 6 of the main program. Line 12
provides the seeds for the four pseudorandom number streams. These seeds come from
entries in Table 4.2, which lists numbers that successively occur 1,000,000 numbers apart in
the stream of numbers that the SIMSCRIPT II.s pseudorandom number generator
produces. The entries are from column 0 and rows 0, 1,2, and 3, implying that successive
numbers are 10,000,000 apart in the pseudorandom number sequence. For AIR_EV.sim, this
choice of seeds implies that for runs made with T + K :::: 10 7 the four streams would not
overlap. Nonoverlapping streams are essential for independent sampling with regard to each
source of variation in this problem. "Line IS" ofSIMUlO provides values for T and K.
Of necessity, virtually every discrete-event simulation begins with guesses for K and T
and later revises them based on information that the preliminary run reveals. The present
account follows this approach. By setting K = 1, AIR_EV.sim uses all the data generated
during a run to compute statistics. Since this is a preliminary run, setting T = 1000 is merely
a guess on how long to run the simulation to obtain meaningful data.
Figure 4.3 displays the output for these choices. It summarizes descriptive statistical
behavior over the 0.6818 x 24 = 19.632 hours of simulated time that elapsed up to the
moment at which the 1000th CUSTOMER entered service. Tableaus similar in format to
this one are commonplace output for many discrete-event simulations. Unfortunately, they
contain no information on how well these sample averages approximate the long-term
128 CHAPTER 4. PROGRAMMING AND EXECUTION
Table 4.2 Seeds for SIMSCRIPT 11.5 Pseudorandom Number Generator (spaced 1,000,000 apart) Z 1,000,000 (10i+ j)
i \i 3
0 604901985 1911216000 726466604 622401386 1645973084 1901633463 67784357 2026948561 1545929719 547070247
1110948479 1400311458 1471803249 1232207518 195239450 281826375 416426318 380841429 1055454678 711617330
1416275180 788018608 1357689651 2130853749 152149214 550317865 32645035 871378447 108663339 199162258
40579844 1357395432 829427729 1967547216 1955400831 2003797295 2094442397 2037011207 234502811 989756374
1912478538 740735795 1417788731 457273482 1315849725 270156449 440381980 1658090585 766876137 695181594
1140617927 1763098393 862536069 944596746 1832412366 1370121812 349487370 1490679974 1137328972 717010525
1768908897 214786952 1001221991 810390021 466350553 285688338 511678575 417093409 1857363469 833556803
1168765321 1578167688 904774509 1230498508 349030873 1280945183 411345101 1477279210 523541596 44009158
8 1034152236 171671287 1486370683 758021537 675302256 766501909 1570038230 127735274 531051296 481363190
9 36897498 377244078 632839225 1113362767 996065998 1127104879 1070367500 1992322523 548733793 1489852891
10 1719061561 3280042 1657019267 1741267743 691072269 1090974938 763220480 1468416723 111113372 129823184
II 705619618 224040976 749810472 2013253460 792658328 86620226 1386345831 1735570696 1896821842 278150891
12 331083792 1598034603 236635316 252926587 471825789 37034748 376315326 2146164618 1999725174 1243665337
13 1336631754 438764943 957241771 1713987536 1948054280 1998497269 575575728 677819252 501253489 1945486566
14 1245688777 2000276877 1503544457 464753035 200460239 1434443717 1353395916 133529216 1070327290 1928287458
15 1384322130 893932629 1181351847 606871877 523684234 1002300248 791546478 1328653688 246224997 48717991
16 2127710456 497489986 869470589 61678709 1145621181 1695821109 369707566 2110142430 763197278 11382857
17 1246856358 1714587858 873019592 1279964778 1396199241 1399930491 2078774631 985879465 486028376 1478854650
18 568269458 1657131937 1622687092 91313597 2080365494 1650386438 1871205625 563020663 1728323861 590715859
19 513501749 793321696 1443190012 1950895003 597186867 50824927 911425540 398409796 1672302183 1870294907
20 1827350617 727130390 774781557 1955524233 87547656 1061350608 1491284628 2029219172 1260286972 272221686
21 300327217 1787384331 2014193199 666978949 301608013 948450895 1453252697 419227541 1678821481 1765439952
22 177708831 1077885023 540589041 2007603355 1543903327 2017128524 1405189468 1003195553 337684924 1565288286
23 1745588809 485902835 1763594466 1082423631 194255479 1912029349 1219836142 1648556563 1508071873 549212365
24 1096265301 851153926 456184535 1408460673 1685622150 190036881 142510264 1465148875 459174572 597953519
25 606282883 1721436086 975289131 1376880454 1041829784 1596248327 2108842626 413468719 1204553786 9011429
26 626121779 203036030 1837216393 2086017536 697945492 1610367790 1512734966 925844033 1356793564 1549516128
27 649444368 510292152 1742847415 1285151791 1006048803 1538805236 1767548554 1446954807 1842805571 1969150158
28 2135785600 906045904 784888097 1048325198 416733559 993764136 1303965501 121604326 1780949928 1259010827
29 2102580471 741705624 1349641363 1376265619 653106395 271655202 1907239477 1015954941 1938162956 371946026
30 1842460388 543303725 1390660531 1138405358 31074996 1712456909 1247559532 1617264816 755962474 804894664
31 1186319334 494117518 1634124003 1027439985 319326476 1043817176 1323412056 668757796 406168599 1317790466
32 625592935 1520076665 1900759891 1684472723 209831417 2007811944 587647848 1424142232 6938939 427509950
33 1174409129 210461470 539786056 1629541058 1819341982 43434266 1391309379 244792174 750490187 423505883
34 904658495 245177844 841290082 1402203157 429993932 1836064376 1038894007 1923849909 1600794244 1950123859
35 960647611 974174009 1934369904 808615644 1879784225 795995555 1922561547 69238569 961625762 163574669
36 1095421583 554291019 432345723 855636598 971945436 881294334 1783677724 2088374054 1270902641 1182268061
37 2004539543 216813966 1304722830 629904199 834124981 898116231 864082217 389917225 1278587457 1869657489
38 1111329860 1594031833 571644852 1053085806 1019423302 482661750 1134475119 1104046462 1929367108 1097726063
39 295080740 1818474208 1129948309 75253501 1876330799 506183851 1692164827 873044608 1908879123 1897274087
40 1373006294 445158089 292594684 1305725195 847492301 1067706417 1718084174 133626496 971565385 1931931986
41 1677252989 312760713 891757911 776146802 462527160 1917080512 1349286825 909926550 1756656652 1570226967
42 105992480 1444798270 523658664 1024065462 299634195 884544980 1281114105 2106315124 869738253 1165668988
43 1036972300 462764735 314834790 222634789 1852359919 1085683972 115959636 695883743 1545554827 1372269350
44 287358587 2022531413 535827657 1657359673 904942635 317419570 576435644 1843235552 1761208654 912499785
45 1230888777 1724910189 1288149046 897051070 1758822711 1977931462 451692590 1554328303 1935881922 49510711
46 14291789 46830509 499758343 758082642 1018016755 1635908329 1577325787 423614699 1901481113 763520381
47 251686092 860899664 1253266716 487207054 1133665090 858964589 2104231773 554226602 126548109 568187190
48 71320167 1595587069 1886787081 883887920 1470032706 817226546 1572454264 766098912 1700253028 230254384
49 1488181869 1104477402 2087453595 1544780480 826720767 1926533288 23680406 97080449 2139633377 994728742
averages of interest. In particular, they contain not a clue as to how large K should be to
make the influence of initial conditions negligible on the displayed summary statistics.
To make this issue of statistical accuracy more salient, AIR-EV.sim was rerun with only
T changed from 1,000 to 1,000,000. This was motivated by the observation that since a run
with T = 1000 took less than a second, a run with T = 1,000,000 would take no more than
17 minutes. Figure 4.4 shows the corresponding output, which differs substantially from
that in Figure 4.3. For example, T = 1000 gives a sample average waiting time of 5.88179,
whereas T = 1,000,000 gives 4.29191. Because the summary in Figure 4.4 is based on a
larger sample path, one is inclined to believe that it is more representative of the long-run
averages. However, it provides no other indication of how good the approximations are and,
in particular, provides no guidance as to the choice ofK to mitigate the effects of starting the
simulation in the empty and idle state. Chapter 6 addresses both these issues in detail and
describes techniques for estimating a suitable initial truncation and for assessing how well
the time averages based on simulated data approximate the corresponding true long-run
averages of interest.
4.16. A FIRST RUN 129
MULTIPLE-
DESTINATION PROB. = .750 ACTIVITY LEVEL= .875 NO. TRUNCATED=
PROPORTION
WAITING TIME WHO WAIT QUEUE PROPORTION
(minutes) THIS TIME LENGTH OF TIME
W> 0 .8550 Q > 0 .7825
>= .25 .8420 > 1 .7183
>= .50 .8270 > 2 .6475
>= .75 .8120 > 3 .5660
>= 1.00 .7970 > 4 .4923
>= 1.25 .7760 > 5 .4352
>= 1.50 .7560 > 6 .3860
>= 1.75 .7370 > 7 .3212
>= 2.00 .7180 > 8 .2637
>= 2.25 .6980 > 9 .2036
>= 2.50 .6780 > 10 .1577
>= 2.75 .6590 > 11 .1261
>= 3.00 .6340 > 12 .1030
>= 3.25 .6100 > 13 .0877
>= 3.50 .5890 > 14 .0802
>= 3.75 .5710 > 15 .0785
>= 4.00 .5540 16 .0752
>= 4.25 .5280 17 .0664
>= 4.50 .5170 > 18 .0574
>= 4.75 .4970 > 19 .0442
>= 5.00 .4800 > 20 .0369
>= 5.25 .4650 > 21 .0278
>= 5.50 .4480 > 22 .0247
>= 5.75 .4330 > 23 .0221
>= 6.00 .4170 > 24 .0190
>= 6.25 .3990 > 25 .0149
>= 6.50 .3820 > 26 .0110
>= 6.75 .3660 > 27 .0080
>= 7.00 .3490 > 28 .0040
>= 7.25 .3240 > 29 .0008
>= 7.50 .3110 > 30 O.
>= 7.75 .2950 > 31 O.
>= 8.00 .2810 Q >=32 O.
NO. OF BUSY
RESERVATIONISTS PROPORTION
> 0 .9925
> 1 .9616
> 2 .9064
> 3 .8530
MULTIPLE-
DESTINATION PROB.= .760 ACTIVITY LEVEL~ .875 NO. TRUNCATED=
PROPORTION
WAITING TIME WHO WAIT QUEUE PROPORTION
(minutes) THIS TIME LENGTH OF TIME
W> 0 .7336 Q> 0 .6161
>= .25 .7070 > 1 .5262
>= .50 .6794 2 .4484
>= .76 .6525 3 .3816
>= 1.00 .6261 > 4 .3242
>= 1.25 .6004 5 .2757
>~ 1.50 .5757 6 .2350
>= 1.75 .5516 > 7 .2006
>= 2.00 .5281 > 8 .1713
>- 2.26 .5054 > .1461
>= 2.50 .4838 > 10 .1249
>= 2.75 .4630 > 11 .1070
>- 3.00 .4429 > 12 .0917
>= 3.25 .4237 13 .0785
>= 3.50 .4055 14 .0673
>= 3.75 .3880 > 15 .0578
>- 4.00 .3711 > 16 .0496
>= 4.25 .3548 >17 .0425
>- 4.60 .3394 > 18 .0362
>- 4.75 .3249 > 19 .0309
>= 6.00 .3108 > 20 .0263
>= 6.26 .2974 > 21 .0223
>= 5.50 .2846 > 22 .0189
>= 5.75 .2724 > 23 .0160
>= 6.00 .2608 > 24 .0137
>= 6.26 .2496 > 25 .0117
>= 6.50 .2389 > 26 .0100
>= 6.75 .2284 > 27 .0085
>= 7.00 .2189 > 28 .0073
>= 7.25 .2097 > 29 .0062
>= 7.50 .2008 > 30 .0063
>- 7.75 .1922 > 31 .0046
>- 8.00 .1843 Q >=32 .0046
NO. OF BUSY
RESERVATIONISTS PROPORTION
> 0 .9854
> 1 .9341
> 2 .8436
> 3 .7331
reserve W(*) as T
letW(NUM-K+l) = 1440.*(time.v-START(CUSTOMER))
to the ACCOUNTING routine between lines 8 and 9 directs SIMSCRIPT 11.5 to save the
waiting times in decimal days in the double-precision array W, which is 8T bytes in length.
Therefore, the size of the array grows linearly with T, which conceivably can create a space
problem as T becomes excessively large. Section 3.7 describes procedures for collecting
sample-path data on queue length and resource utilization.
from flowchart to executable program. A process can also characterize a permanent entity.
For example, a process can describe the behavior of each reservationist in the airline problem.
From the event-scheduling perspective of Section 2.3, the airline reservation prob-
lem concerns interactions between two types of entities, CUSTOMERs (temporary) and
RESERVATIONISTs (permanent). One formulation of the process-interaction approach, as
in Figures 2.10 and 2.11, provides a process for each CUSTOMER and a process for each
RESERVATIONIST. Our SIMSCRIPT II.S rendering of this problem follows the logic in these
figures. Here, each CUSTOMER has an attribute TYPE that identifies whether a one-way
or two-way reservation is desired. TYPE plays the same role here as in the event-scheduling
approach in Section 2.3.
Italics in this list denote numbers and variables that the simulation programmer assigns. In
practice, one can use the process-interaction option in SIMSCRIPT II.5 to simulate a system
in two different but equivalent ways. One relies on the process statements exclusively. The
other exploits the resource statements "request" and "relinquish" as well. Section 4.20 de-
scribes the approach based exclusively on processes, and Section 4.21 describes the approach
using processes and resources.
4.20. U SIN G PROC E SSE sEx C L U S IV ELY 133
Since a process has no system variable n.process analogous to n.entity for a permanent entity,
we use M (line 19) to serve this purpose globally for RESERVATIONISTs.
The main routine agrees with that in Figure 4.2, with two notable exceptions. Firstly,
the statement in line 18
causes SIMSCRIPT 11.5 to create a process notice for each RESERVATIONIST. This process
notice contains fields for explicitly declared attributes in the preamble as well as fields to
store scheduling information. In the event-scheduling approach, SIMSCRIPT 11.5 assigns a
future events set ev.s(l) to each event notice where the priority order declared in line 16 of
the preamble determines I. SIMSCRIPT 11.5 makes a similar assignment for process notices.
In particular, I = 1 for RESERVATIONIST process notice and I = 2 for a CUSTOMER
process notice.
In addition to allocating space for each RESERVATIONIST process notice, the afore-
mentioned "activate" statement indicates in each time.a field that the desired execution time
is time.v = 0 and files the notices in ev.s(l) in order of creation. In short, "activate" per-
forms the same task for a process that "schedule" does for an event. The term "reactivate" is
synonymous with "activate:' Secondly, the statement
in line 19 of "main" causes creation and filing in ev.s(2) of a process notice for CUSTOMER
with time.a = O.
One issue regarding "activate" deserves explicit mention. Whereas the article "a" in
the aforementioned "activate" statement causes creation and scheduling, the statement
the
activate CUSTOMER now
this
134 CHAPTER 4. PROGRAMMING AND EXECUTION
,,-----------------------------------------------------------------
PREAMBLE
,,-----------------------------------------------------------------
1 preamble
2 normally mode is integer
3 the system owns a QUEUE and an IDLE. LIST
4 processes
5 every CUSTOMER has a TYPE, a START and may belong to the QUEUE
6 define START and WAITING. TIME as double variables
7 define SERVER as a variable
8 tally AVE. WAIT as the mean, V.WAIT as the variance and
MAX.WAIT as the maximum of WAITING. TIME
9 tally WAIT.HISTO (0 to 8 by .25) as the histogram of WAITING. TIME
10 define ZERO. WAIT as a variable
11 every RESERVATIONIST has a DEMAND and can belong to the IDLE.LIST
12 define NO.BUSY and NO.RESERVATIONIST as variables
13 accumulate AVE.UTIL as the average, V.UTIL as the variance and MAX.UTIL
as the maximum of NO.BUSY
14 accumulate UTIL.HISTO (0 to 10 by 1) as the histogram
of NO.BUSY
15 accumulate AVE.Q as the average, V.Q as the variance and MAX.Q as the
maximum of n. QUEUE
16 accumulate Q.HISTO (0 to 32 by 1) as the histogram of n.QUEUE
17 priority order is RESERVATIONIST and CUSTOMER
11 reserve SEEDS(*) as 4
12 for 1=1 to 4 do
4.20. U SIN G PROC E SSE sEx C L U S I VEL Y 135
See Fig. 4.1 for KIND, S_TIME, ACCOUNTING, and SUMMARY routines.
136 C HAP TE R 4. PRO G RAM MIN G AN D EXEC UTI 0 N
causes the scheduling of the reactivation of an already existing process named CUSTOMER.
Both the CUSTOMER and RESERVATIONIST statements offer illustrations of the "activate"
statement in this context.
Once control passes to the timing routine via the "start simulation" statement in line
20 of "main;' the routine scans the first entry in each list to select the next process, that
is to continue execution of scheduled events. Since line 16 of the preamble indicates that
RESERVATIONIST has priority over CUSTOMER, SIMSCRIPT II.s first activates a RESER-
VATIONIST. Control then passes to the RESERVATIONIST process, where a check of the
QUEUE occurs. Since this set is empty at the beginning of the simulation, the RESER-
VATIONIST is filed in the IDLE.LIST and then is "suspend"ed. The "suspend" statement
deactivates t.his RESERVATIONIST. In particular, it terminates execution, sets the implic-
itly assigned attribute sta.a (RESERVATIONIST) from "active," denoted by I, to "passive;'
denoted by 0, and records the address of the next statement as the reactivation point. Note
that failure to assign the RESERVATIONIST to a set, before invoking "suspend," can result
in a loss of that process to the simulation. After the first RESERVATIONIST is suspended,
control passes to the timing routine, where execution of the remaining M -1 RESERVATION-
ISTs occurs in like manner. After all are suspended, the timing routine finds one remaining
process, namely, the CUSTOMER, whose activation was scheduled in the main program.
The first executable statement in the CUSTOMER process (line 4) determines TYPE.
Line 5 assigns the call time to START, and line 6 stores the name of the current CUSTOMER
in a local variable PATRON. The need for this step is a consequence of the next activate
statement, which schedules the occurrence of the next call. Once the activate statement has
been executed, the global variable CUSTOMER refers to the next CUSTOMER, not the
currently active one. However, the statement
restores the designation to the currently active CUSTOMER and facilitates implicit
subscripting thereafter.
If the condition in line 9 is true, at least one RESERVATIONIST is idle. Then line 10
identifies the first of these, removes it from the IDLE. LIST, and line 12 signals the RESERVA-
TIONIST to provide service to the CUSTOMER identified in line 11. Recall that DEMAND
is an attribute of RESERVATIONIST. SIMSCRIPT II.s then executes the "suspend" state-
ment in line 24, which deactivates this CUSTOMER process. It is important to recognize
that the actual execution of the RESERVATIONIST reactivation occurs after this "suspend"
statement is executed.
If the IDLE.LIST is empty in line 9, then the program transfers to and executes line
14. Here, SIMSCRIPT II.s sets the time.a attribute of the CUSTOMER process notice to
time.v + 0.15/1440 days and files the notice in ev.s(2). It also indicates in the notice that the
subsequent line 16 is the reactivation point. After the wait, the CUSTOMER again checks
for the availability of a RESERVATIONIST in line 16. If at least one is idle, SIMSCRIPT II.5
executes lines 19,20,21, and 24. If none are idle, it executes lines 17 and 24.
4.21. U5 I N G PRO C E SSE 5 AND RES 0 U RC E 5 137
,,------------------------------------------------------------------
PREAMBLE
,,------------------------------------------------------------------
1 preamble
2 normally mode is integer
3 processes
4 every CUSTOMER has a TYPE and a START
5 define START and WAITING. TIME as double variables
6 tally AVE. WAIT as the mean, V.WAIT as the variance and
7 MAX.WAIT as the maximum of WAITING. TIME
8 tally WAIT.HISTO (0 to 8 by .25) as the histogram of WAITING. TIME
9 define ZERO. WAIT as a variable
,,---------------------------------------------------------------
" MAIN
,,---------------------------------------------------------------
1 main
2 open unit 10 for input
3 use unit 10 for input
4 open unit 15 for output
5 use unit 15 for output
6 let n.RESERVATIONIST=1
7 create each RESERVATIONIST
8 read LAMBDA,OMEGA,M and P " INITIALIZE
9 let u.RESERVATIONIST(1)=M
4.21. USING PROCESSES AND RESOURCES 139
,,------------------------------------------------------------------
" process CUSTOMER
,J _________________________________________________________________ _
1 process CUSTOMER
2 define PATRON as a variable
3 define T.CALL to mean exponential.f(l./LAMBDA,l)
4 let TYPE=KIND
5 let START=time.v
6 let PATRON=CUSTOMER
7 activate a CUSTOMER in T.CALL minutes
8 let CUSTOMER=PATRON
9 if u.RESERVATIONIST(l) > 0
10 request 1 unit of RESERVATIONIST(l)
11 add 1 to ZERO.WAIT
12 otherwise
13 wait .15 minutes
14 request 1 unit of RESERVATIONIST(l)
15 always
16 call ACCOUNTING
17 work S_TIME minutes
18 relinquish 1 unit of RESERVATIONIST(l)
19 return end
,,------------------------------------------------------------------
routine ACCOUNTING
,,------------------------------------------------------------------
,,------------------------------------------------------------------
routine SUMMARY
",J _________________________________________________________________ _
The preamble now has a new keyword "resources" in line 10. It prefaces the declaration
of the list of resources or servers to be used in the program when all have attributes. Since
in the present case we elect to define RESERVATIONIST without explicit attributes, the
statement
suffices. The preamble also contains modifications of the "accumulate" and "tally" state-
ments. The need for these modifications becomes apparent to the reader as we describe the
effects that using "resources" induces in the main routine and CUSTOMER process.
Although similar to those in Figures 4.2 and 4.5, the main routine differs in several
important ways. In particular, n.RESERVATIONIST in line 6 of "main" refers to the number
of different classes of RESERVATIONISTs here, not to the number of reservationists (see
Section 4.3). This is a consequence of defining RESERVATIONIST as a resource instead of
as a process. The implicitly generated variable u.RESERVATIONIST(I) denotes the number
of available RESERVATIONISTs in class 1 and requires assignment of a value. Note that data
structures are created for each resource class (line 7), not for each resource. A comparison of
the CUSTOMER processes in Figures 4.5 and 4.6 indicates notable differences. In particular,
in Figure 4.6 the system variable u.RESERVATIONIST( 1) in line 9 of the CUSTOMER pro-
cess enables a CUSTOMER to determine whether a RESERVATIONIST is available. If one is,
the CUSTOMER executes the "request" statement in line 10. If one is not, the CUSTOMER
executes the "wait" statement in line 13 and upon reactivation executes the "request" state-
ment in line 14. The "request" and "relinquish" statements are powerful preprogrammed
bodies of code designed to mimic the steps commonly encountered in demanding resources
in a queueing simulation.
If a RESERVATIONIST is idle, the CUSTOMER executes the "request" statement in
line 10. If not, the CUSTOMER executes the "wait" in line 13 and upon reactivation executes
the "request" in line 14. The "request" statement invokes a SIMSCRIPT 11.5 system routine
designed to mimic the two alternative types of action that arise in a queueing simulation
when resources are demanded. To understand the options, a knowledge ofSIMSCRIPT 1I.5's
implicit behavior is necessary.
Whenever a preamble declares a "resource;' SIMSCRIPT 11.5 creates two associated
lists, q.resource and x.resource. At execution of a "request" statement SIMSCRIPT 11.5 creates
a record of a special temporary entity, qc.e, whose attributes include who.a, assigns the
address of the requesting process to who.a( qc.e), and files it in an implicitly created list or
set of resources owned by the requesting process. If u.resource is greater than or equal to the
number of requested units ofthe resource, the qc.e record is also filed in x. resource. Otherwise,
it is filed in q.resource to await service. If the desired number of units of the resource are
available, the process continues execution. For example, "work S_TIME minutes" would be
executed in line 17 of the CUSTOMER process. If the desired number of units of resource are
unavailable, execution ceases and control passes to the timing routine with the next executable
4.21. USING PROCESSES AND RESOURCES 141
statement as reactivation point. For the airline reservation problem, the "request" statement
incorporates blocks 8, 9, 10, and 11 in Figure 2.10.
The statement
is unusually powerful in content, essentially corresponding to the logic in Figure 2.11. When
executed in line 18 of the CUSTOMER process, SIMSCRIPT 11.5 removes the temporary
entity record qc.e from x.RESERVATIONIST(l) and from the list of resources owned by
CUSTOMER who.a(qc.e) and files the CUSTOMER process notice for who.a(qc.e) in the
corresponding list of scheduled processes with its time.a(who.a(qc.e)) = time.v, which is
"now:' Next, it destroys the qc.e record and checks to see whether q.RESERVATIONIST(l)
is empty. If it is, then u.RESERVATIONIST(l) is augmented by 1. Otherwise, it removes
the first qc.e from q.RESERVATIONIST(l), files it in x.RESERVATIONIST(l), and files the
process notice corresponding to who.a( qc.e) in the single future event set with time.a( who.a)
= time.v. In the present example, ev.s(l), the list of scheduled CUSTOMER processes, is the
future-event set.
The programming convenience that the "request" and "relinquish" statements offer
is self evident. They reduce programming effort by replacing a sequence of more elemental
statements, as in Figure 4.5, that collectively would effect the same modeling logic. This
saving in effort occurs k times in a simulation with k stations in series; it can become
substantial as k increases. Every simulation that employs the process-interaction approach
contains macrostatements analogous to "request" and "relinquish:'
In exchange for this reduction in effort, a simulation user gives up explicit control over
some parts ofprogram flow. Although not necessarily detrimental, this loss of flexibility needs
to be understood explicitly. For example, the steps SIMSCRIPT 11.5 takes are not apparent
from the program in Figure 4.6. In particular, note that the RESERVATIONIST automatically
becomes committed when it is released if another process is waiting. This action can cause
a problem in other simulations. For example, consider the tanker problem in Exercise 4.7,
where a TANKER (process) may arrive in the harbor while the TUG (resource) is towing
out another TANKER and yet another TANKER has completed loading and has requested
the TUG. Here, the TANKER in the harbor would have to
where A is an integer larger than the priority with which the TANKER at the berth requested
the TUG. Although this would work here, one needs to avoid this statement if the TANKER
arrives while the TUG is heading in to the berths, since it would lead to an order of servicing
contrary to that intended.
At least one other feature deserves attention. It is entirely possible to employ events,
processes, and resources in the same SIMSCRIPT 11.5 simulation. SIMAN and SLAM II also
provide this option, which can introduce considerable flexibility in modeling a system with-
142 CHAPTE R 4. PROG RAMM I N G AN D EXEC UTIO N
activate
work
wait
1, ... , r assign the same seed to stream i on each of two runs of a simulation program each
with different values for an input parameter that does not affect sample generation. Then
sample averages on each run are consequences of the same random input sequences. This
implies that the difference between corresponding sample averages on the two runs arises
principally, if not entirely, from the difference in the parameter's values. An example based
on waiting time for the airline reservation problem illustrates the benefit that can arise from
this property.
It is of interest to evaluate the reduction in waiting time that materializes when the
number of reservationists increases from m = 4 to m = 5. A simulation for m = 4 generated
a sample record of waiting times Xko Xk+l, ... , Xk+t-h and a simulation with m = 5 using
the exact same seeds generated a sample record of waiting times Yko ... , Yk+t-h where the
choice of k ensured that the influence of initial conditions was negligible (Section 6.1) and
where t = 100,000.
The sample waiting times are
_ 1 k+t-l
Xkt =-
t
L j=k
Xj = 4.072 minutes
and
_ 1 k+t-l
Ykt =-
t
L
j=k
Yj • = 0.7347 minutes.
Their difference is
_. 1 k+t-l _ _
Zkt =-
t
L
j=k
Zj = X kt - Ykt = 3.337 minutes,
- 2
tvar Xkt --+ 1100 (X),
- 2
tvar Ykt --+ 1100 (Y)'
- 2
tvar Zkt --+ 1100 (Z), as t --+ 00,
so that ikt, -rkf> and Zkt have approximate large-sample variances 11~(X)/t, 11~(Y)/t,
and I1Jo(Z)/t, respectively. With LABATCH.2, as described in Sections 6.6 through 6.7.5,
144 CHAPTER 4. PROGRAMMING AND EXECUTION
generated
&!(X) = 3429,
&!(Y) = 60.92,
&!(Z) = 2847,
as many observations to achieve the same variance for the sample average difference Zkt
as independent sample records. Moreover, this result occurs with no additional computing
time per run.
Estimating the difference in the proportion of customers who wait reveals an even
greater benefit of common random numbers. Let
and
Then Xkt and :rkt estimate the long-run proportion of customers that wait for m = 4 and
m = 5 reservationists, respectively. The same sample records yielded
Xkt = 0.7345, :rkt = 0.3748, Zkt = 0.3597
and
more observations as independent sample records to achieve the same variance for the sample
average difference Zkt.
Why do the savings in sample sizes vary so substantially for the difference of means
and the difference of proportions? Recall that
where
Therefore,
G!(Z) 2p(X, Y)
1-
----::---=---::--- -
G&,(X) + G&,(Y) - <7oo (X) +
--:-=---:-::::-:-
<7oo(Y) ,
<7oo(Y) <700 (X)
where
- - Goo(X, Y)
p(X, Y) := corr (Xkt, Ykt) ~ () ()'
Goo X Goo Y
Thus variance reduction is a function both of the correlation between sample averages and
of the ratio Goo (X) / Goo (Y). Low correlation diminishes the potential variance reduction, as
does a large or small ratio Goo(X)/Goo(Y).
For sample average waiting times,
[J(X, Y) = 0.7033
and
aoo(X)
-;;------(
Goo Y
) = 7.502.
146 CHAPTER 4. PROGRAMMING AND EXECUTION
p(X, Y) = 0.8906
and
The higher correlation and smaller relative difference between uoo(X) and uoo(Y) account
for the greater benefit of common pseudorandom numbers for sample proportions than for
sample average waiting times.
To realize these variance reductions calls for more than common pseudorandom num-
bers on each run. It requires that a separate pseudorandom number stream be dedicated to
each source of random variation and that the seed for stream i be identical across runs. Most
major simulation languages provide access to multiple pseudorandom number streams and
allow user assignment of their seeds.
At least two additional issues deserve attention. The seeds for the streams must be
chosen so that the sequences they generate do not overlap; otherwise, the sequence would be
dependent, contrary to intention. The second issue concerns the number of pseudorandom
numbers that stream i generates on each run and their use. The airline reservation simulation
executed until exactly k + t customers entered service. The structure of the problem ensured
that each stream generated exactly the same number of pseudorandom numbers on the run
for m = 4 and on the run for m = 5, and that each number was used for exactly the same
purpose on both runs.
Common pseudorandom number streams may also induce a variance reduction when
stochastic variation differs on the two runs. Suppose that the purpose for simulating the
airline reservation model is to study the effect on waiting time of changing p from .75 to
.90. If common pseudorandom number seeds are used, then both runs would have the same
sequence of intercall times but different sequences of service times. Let
where
i
Ji(p) := L I[O,pj(UI), i 2: 1,
1=1
and Bo := O. Therefore, the difference between the ith service times on runs with p = .75
andp = .90 is
times as large would be required to estimate this difference with the same estimated accuracy.
In the present case, relatively small changes in the S_TIME code in Figure 4.2 can make
the two sequences of service time more similar. In particular:
DUMI = exponential.f(I/OMEGA,2)
DUM2 = exponential.f(1I0MEGA,3)
Delete line 5.
C;(p) = Ai + BiI[o,pj(Ui ),
148 CHAPTER 4. PROGRAMMING AND EXECUTION
so that
That is, only 100 x (.90 - .75) = 15 percent of the service times differ. Simulations run
with these changes produced X = 0.7292 for p = 0.75, Ykt = 0.8806, Xkt - Ykt =
-0.1514, a~(X) = 6.028, a~(Y) = 5.789, and a~(Z) = 1.590, so that
effort than common pseudorandom number seeds to implement and to evaluate. This de-
mand lowers their appeal in practice for simulators who prefer more easily implementable
online methods.
--
SIMAN Parser (in C/C++)
Blocks converts SIMAN
I Modules I f---------. f----- Executable
and statements to module
Elements machine code
Figure 4.8 Arena discrete-event simulation program development
the previous three, the Common, Support, and Transfer Process panels, contain aggregates
of SIMAN statements, again for frequently encountered constructs. Their representations
on the screen attempt to identify them with their principal underlying activities. Hereafter,
we refer to these three as the CST panels. Arena 4.0 contains these eight panels. Arena 3.51
contains the first two and the last three.
In principle, pointing, clicking, dragging, dropping, and connecting modules from,
for example, the Common panel and dropping them into a model window allows a user with
little to no familiarity with SIMAN to create a simulation program. Analogous operations
applied to the Blocks and Elements panels allow a more knowledgeable user of SIMAN to
construct a simulation program directly from its basic blocks or macromodules. Arena also
offers the user the option to program directly in SIMAN via a textual editor. Figure 4.8
depicts program creation in the Arena environment.
As with all other simulation languages, SIMAN embraces the elementary concepts of
entity, attribute, event, list, process, and future-event set described in the introduction to
Section 2. It includes a grammar that caters to the process-interaction approach. Although
it is not possible to create a SIMAN program that embraces the event-scheduling approach
of Section 2.3, Section 4.28 describes SIMAN's EVENT block, which allows a simulationist
to introduce elements of that approach within the framework of process interaction. The
SIMAN literature often refers to event scheduling as event orientation and to process inter-
action as process orientation. Its event -scheduling capabilities can be traced to early work of
Kiviat at U.S. Steel, who developed the GASP discrete-event simulation language (Pritsker
and Kiviat 1969). Its process-interaction features can be traced back to GPSS (Gordon 1969).
Arena embraces SIMAN's process-interaction concepts as the basis for its modeling
environment. SIMAN's time-advance protocol follows the next-event approach (Section
2.1). It maintains its future-event set (FES) in a single list as a heap (Section 5.4.3). Its
pseudorandom number generator has the form (4.13) with A = 16807 and M = 231 - 1,
and it allows for multiple streams each with its own seed (Section 4.7). The seeds may be
specified by the user. Otherwise, SIMAN employs its default seeds. Section 9.4 describes the
properties of this generator. For reference, see Pegden et al. (1995).
As mentioned, the BAAT panels are available with Arena 4.0. Using them produces
spreadsheets below the model display for entities, queues, resources, etc. The spreadsheets
facilitate program construction. However, there are qualifications to using these and the CST
panels. In a particular problem specification may exceed the capacity of these panels to model
4.24. M/M/1 ARENA EXAMPLE 151
the problem completely. When this is so, the simulationist may augment the aggregates taken
from these with statements from the Block and Elements panels. The "WHILE" statement
illustrates one area in which this merging can be beneficial.
In addition to the modules provided by these panels, Arena's Professional Edition
allows a user to create her/his own modules, out of SIMAN blocks, and collect them into
a template (panel). Arena provides a capability for dynamic animation as simulated time
elapses during execution and a means for postsimulation graphical display of sample paths,
histograms and other selected concepts. Arena also allows for the incorporation of user-
written code in Visual Basic, and C/C++. However, the burden for this incorporation falls
on the simulationist.
The description here is based on Arena Version 4.0. We illustrate Arena first using the
high-level Common panel and then, at the other extreme, the Block and Elements panels.
We then describe several features of the BAAT panels. In conformity with SIMAN reference
material, we capitalize all SIMAN block, element, and module names. To distinguish between
SIMAN code and user-specfied variables, etc., we capitalize only the first letters of the latter.
We first illustrate Arena program construction exclusively by means of the Common panel,
some of whose modules are depicted in Figure 4.9. Consider a single-server queueing system
with i.i.d. exponentially distributed interarrival times with mean 1.1111 and i.i.d. exponen-
tially distributed service times with unit mean. Jobs receive service in first-come-first-served
order. There are five types of state changes or elementary events (Section 2.3):
These can easily be incorporated into a single process as in Section 2.4. In the Common panel,
the ARRIVE module serves as arrival generator, the SERVER module as work processor, and
the DEPART module as disposer of jobs after they complete service. Figure 4.10 shows a
model constructed by pointing and clicking on these objects, one at a time, in the Common
panel and dragging and dropping them in an opened model window labeled mml.doe.
Double clicking with the left mouse key on the icon for the dropped ARRIVE module
opens a dialog box that provides space for time of first arrival number of jobs per arrival
and time between arrivals. The defaults for the first two are 0 and 1, respectively, and we
allow those to prevail. Clicking on the time between arrivals brings up a list of distributional
options for sampling interarrival times. The menu there lists 13 distributions, including two
empirically based options, one for continuous random variables and the other for discrete
random variables. Clicking on Expo(mean) and replacing "mean" by 1.1111,1 specifies the
exponential distribution with mean 1.1111 using pseudorandom number stream 1.
..
152 CHAPTER 4, PROGRAMMING AND EXECUTION
--./
r-- .
~'- -I
L. '
\ .5 ..1 .CZ '/
- •~L.
,
. -1
C-' ' .L. 9
• --- L... ~Q
Arrive • Depart I • Server " Inspect " AdvServer ~ Process
-,
i
!
Arrive 1 Depart 1
Server 1 Inspect 1 AcfvServet 1
•
Elller2 Aclions 1 Queue 1
__tl. Container 1
IResource : , Container !
R8S0Urce 1
Number Available
---';
Arrive 1
Server 1 Depart 1
•
Simulate
MM 1 Model
10000
Clicking on the "connect" option in the dialog box sets the stage for linking the
ARRIVAL and SERVER modules. Bringing down the "object" menu, clicking on "connect;'
and clicking once on the exit node of the ARRIVAL module and then once on the entry node
to the SERVER module connects them. Similar steps for the SERVER module with mean
replaced by 1,2 specifies exponential service times with unit mean using pseudorandom
number stream 2. Connecting the SERVER and DEPART modules is accomplished by first
4.24. M/ M/ 1 ARE N A EXAM P L E 153
STATIONS: Arrive I:
Depart I:
Server I;
Model statements for module: Server I
TALLIES: Server I_R_Q Queue Time;
2$ STATION. Depart I;
233$ TRACE. -I,"-Anived to station Depart lin":;
203$ DELAY: 0.;
240$ TRACE, -I."-Disposing entityln":;
232$ DISPOSE;
clicking on the "connect" option in the dialog box and following steps analogous to those
used previously.
A SIMULATE module dragged from the Common panel and dropped in the open
mml.doe window creates the basis for executing the model. Double clicking on it brings
up its dialog box with entries for "title;' "number of replications;' "beginning time;' and
"length of replication." In the present setting, the last three of these are set to 1, 1000, and
10,000.
154 CHAPTER 4. PROGRAMMING AND EXECUTION
Clicking on "SIMAN" and then on "View" in the Run menu displays the corresponding
SIMAN code. Figure 4.11 shows it partitioned into a MOD file, or Model file (left side),
and an EXP file, or Experiment Source file (right side). The MOD file contains the executable
SIMAN code whereas the EXP file contains all nonexecutable global declarations plus a
list of final results to be tabulated. In the present case, Arena has automatically included
these output quantities in TALLIES and DSTATS statements. TALLIES relates to output
quantities computed from discrete-indexed sample-path data, for example, waiting time.
SIMAN refers to these as discrete-valued variables. DSTATS relates to output computed
from continuous-time indexed sample-path data; for example, queue length. SIMAN refers
to these as time-persistent variables.
Of particular interest is the partition of the MOD file into three sets of SIMAN
blocks that correspond to the ARRIVE, SERVER, and DEPART modules. The reader quickly
appreciates the benefit that point and click from the Common panel offers.
Clicking on "Go" in the "Run" menu executes the program with animated activity in
the mml.doe window. Alternatively, clicking on "Fast Forward" suppresses the animation
and induces considerably faster execution. When execution terminates, Arena asks the user
whether he/she wishes to view its automatically generated output summary. We return to
this topic in Section 4.25, where we examine the output for the airline reservation program.
Note that Arena has relieved the simulationist of the need to compile, link, and execute
the program and, by default, has provided for the computation of summary statistics. It also
uses default seeds for the two pseudorandom number streams.
What does the SIMAN code in the MOD and EXP files tell us? As a basis for answering
this question, Section 4.24.1 describes a collection of SIMAN Block and Element statements
and then uses the latter to explain the contents of the EXP file in Figure 4.11 b. Then Section
4.25, which studies the Arena/SIMAN version of the airline reservation problem, use the
Block elements to explain the contents of the MOD file for that model.
BLOCKS
ENDIF;
IF:
QUEUE, queue name, capacity, transfer address when capacity exceeded;
RELEASE: ,resource name, quantity to release:
repeat;
ELEMENTS
COUNTERS: number,
,counter name, limiting value, initial value, option, output file:
repeat;
repeat;
SEEDS: ,stream ID name or number, seed value, initialize option (yes or no) :,
repeat;
156 CHAPTER 4. PROGRAMMING AND EXECUTION
The notation "repeat;" indicates that several records of multifield information may be entered
by merely listing them sequentially, each followed by a colon, except for the last, which is
followed by a semicolon. The "number" entry in each element with "repeat" designates
a unique numerical identifier. Whenever the "name" entry in the same record is invoked
in SIMAN, it refers to this unique identifier. For a complete listing of SIMAN Blocks and
Elements, see Pegden et al. (1995), Systems Modeling Corporation (1995b), or the Help
menu in the Arena screen display.
The content of the EXP file in Figure 4.11 b provides a basis for familiarizing ourselves
with several of the Elements statements. Recall that this file displays the nonexecutable global
declarations that the user-specified model in Figure 4.10 automatically creates in the SIMAN
code.
ATTRIBUTES identifies QueueTime as an attribute of the process. RESOURCES de-
clares a single server, Server LR, Capacity (1,), and QUEUES associates a set Server LR_Q
with this resource having the FIFO discipline. In the present context, STATIONS is self-
explanatory but contains additional information in other models (e.g., Pegden et al. 1995,
p. 214). We defer our discussion of the TALLIES and DSTATS statement until Section 4.25.
To follow an entity's progress through a system for diagnostic purposes, SIMAN pro-
vides the TRACE element. It allows a user to specify those entities and variables that are to
be monitored during the simulation, presumably for the purpose of checking system flow
for errors. Arena also provides for an automatic trace if one clicks on Run Control on the
Run menu, then on Trace, and then on Enable Block Trace. Before using this option, the
simulationist is encouraged to read the accompanying Help file.
-t Release ~ Dispose
Res ervalm B t
Figure 4.12 Arena generated SIMAN Blocks and Elements for airline reservationist
problem
CREATE in Figure 4.13 iteratively brings new processes into existence, each of which
we hereafter call Customer, for convenience of exposition. Furthermore, "batch size" = 1
indicates that these Customers are created one at a time. Creation starts at "offset time" = O.
Successive Customers are created at "interval" = EXPO (1 , 1) as defined in EXPRESSIONS in
Figure 4.13. These are exponentially distributed samples with unit mean using pseudoran-
dom number stream 1. MARK is a SIMAN-defined function that assigns the current time
in the user-specified attribute Time-In of the Customer.
ASSIGN determines Type (ofCustomer), declared as its first attribute in ATTRIBUTES,
by sampling from the user-specified Type.J)istribution in EXPRESSIONS using stream 4.
IF allows the subsequent DELAY to be executed for Message_TimeJ:n VARIABLES if no
Reservationist is available (NR(Reservationist) = = N-Reservationist;). ENDIF delimits the
IF range.
158 CHAPTER 4. PROGRAMMING AND EXECUTION
PROJECT. "Airline
2$ CREATE. Reservation".··G.S.F.".712211999,Yes.No.Yes.No,No.No.No.No;
1:lntercaiLTime:MARK(Time_IN):NEXT(3$);
ATTRIBUTES: I.Type:
3$ ASSIGN: TYP""Type_Distribution;
2,Time_ln;
11$ IF: NR(Reservalionist)=N_Reservationist;
4$ DELAY: Message_Time"Other:NEXT(5$);
VARIABLES: I.Message_Time,CLEAR(System),0.15:
2,N_Reservationist,CLEAR(System).4;
5$ ENDIF;
6$ QUEUE. Customer_Q;
SEEDS: 1,1973272912,No:
7$ SEIZE. I.Other:
2,1964472944,No:
Reservalionist.I:NEXT(8$);
3,1l20463904,No:
4,1351423507,No;
8$ TALLY: Waitin&...Time.INT(Time_in),I;
0$ COUNT: Completed_Calls, I;
QUEUES: Customer_Q,FirstinFirstOut;
1$ DELAY: Service_Time(Type)"Other:NEXT(9$);
RESOURCES:
9$ RELEASE: Reservationist.l ; Reservationist.Capacity(4),,stationary,COST(0.0,0.0,0.0);
10$ DISPOSE: No;
COUNTERS: Completed_Calls,IOOO,Replicate;
TALLIES: I,Waitin&...Time,"Waitin&...Time.dat";
DSTATS: I,NQ(Customer_Q),QueueJ-ength:
2,NR(Reservationist),#_Busy_Reservationists;
REPLICATE, I,0.0"Yes,Yes,0.0.,,24.0,Ho=;
QUEUE files a Customer process in a user-specified list called CustomeLQ, which has
infinite "capacity." If the specified "capacity" were limited, and a Customer were denied entry
because of space, the "balk label" would redirect the entity to an alternative block. SEIZE
functions similarly to REQUEST in SIMSCRIPT 11.5. Here "priority" = 1 denotes first-
come-first-served for the Reservationist resource whose total number is N..Reservationist
= 4 in VARIABLES. Once an entity flows from the- SEIZE block, TALLY collects "value
of tally" = INT(Time_In) and stores these data in "name of quantity" = Waiting_time for
subsequent analysis and display. Time-..ln, the second attribute of Customer, declared in
ATTRIBUTES, stores the simulated time at which the Customer was created in the CREATE
block. INT(Timdn) is a SIMAN defined function that computes the elapsed time between
current simulated time (at TALLY) and Time-..ln.
COUNT adds 1 to the user-declared Completed_Calls in COUNTERS. When the
limit of 1000 completions, specified in the COUNTERS element, is reached at COUNT,
SIMAN terminates the simulation run. Thus we have two ways of controlling run length,
one based on elapsed time (Option A in Section 3.4) in the MIMI 1 example and one based on
number of Customers receiving service (Option B in Section 3.4) in the airline reservation
problem.
4.25. ARE N A / S I MAN A I RLIN ERE S E RV A T ION EXAM P L E 159
The next DELAY provides service to the Customer using the service time distribution
defined under EXPRESSIONS. IfType = 1 (single destination), it samples from EXPO(2,2),
the exponential distribution with mean 2 using pseudorandom number stream 2. If Type
= 2 (multiple destinations), it augments that sample by EXPO(2,3) using pseudorandom
number stream 3. After time elapses at this second DELAY, SIMAN RELEASEs one unit of
the resource Reservationist. Then DISPOSE eliminates the record of this Customer process
from the simulation.
Recall that SIMAN uses a pseudorandom number generator of the form (4.27). The
SEEDS element allows us to specify Zo, ZIOOOOOO, Zzoooooo, and Z3000000 for the four seeds
using entries in Fishman (1978, Table A.2). Note that exclusive use of the Common panel
does not allow this option. Also, note that the third field of each stream entry indicates that
the streams are not to be reinitialized to the original seeds on successive replications. Since
the REPLICATE element indicates 1 replication in its first field, this is not an issue here.
Recall that the DSTATS element allows us to specify the continuous-time sample paths
on which data for time-persistent statistics are to be collected and analyzed. NQ and NR are
SIMAN-defined system variables. In the present setting, NQ(CustomeLQ) denotes queue
length for the user-specified CustomeLQ set and NR(Reservationist), the number of busy
resources of the user-specified resource Reservationist. Note that the user-specified names,
Queue Length and #j3usy_Reservationists, in field 3 refer to the respective Arena-assigned
indices, 1 and 2, in field 1.
In the EXP file of Figure 4.l3, DSTATS declares that data on two time-persistent
phenomena are to be collected and summarized. One is NQ(CustomeLQ), the number
in the set designated by CustomeLQ. It is to be named Queue-Length (field 3), which
implicitly refers to index 1 in field 1. The other is NR(Reservationist) (field 2), the number
of busy RESOURCES called by the user-designated name, Reservationist.1t is to be named
# _Busy_Reservationists, which implicitly refers to index 2 in field 1.
The executable TALLY statement in the MOD file in Figure 4.l3 computes waiting
times as INT(TimeJ:n) in field 2 (see Section 4.22) and refers to them as Waiting_Time
in field 1. The TALLIES statement must have this designation in field 2. In the present
case, it also declares that these data are to be stored in the user-specified file, Waiting_time
.DAT, in binary form. Double quotation marks must precede and follow the file name. The
DSTATS element also allows for data storage. Section 6.9 describes how to use this file for a
user-specified batch-mean analysis.
Figure 4.14 displays the user-specified statistical summary of output. The sample
average waiting time 5.6114, queue length 5.8416, and number of busy reservationists 3.5064
are comparable to the values of their corresponding quantities, 5.8818, 5.862, and 3.7135,
in Figure 4.3 for SIMSCRIPT 11.5. Arena has a capability for computing an approximating
confidence interval for the time long-run averages and displaying its half-length. The default
significance level for the confidence level is 0.95. In the present case, the entry (Corr) indicates
that the data are correlated so that a half-length cannot be computed by the Arena's built-
in method. See Section 6.6 for a discussion of Arena's method of computing a confidence
interval.
160 CHAPTER 4. PROGRAMMING AND EXECUTION
TALLY VARIABLES
DISCRETE-CHANGE VARIABLES
COUNTERS
OUTPUTS
Identifier Value
System.NumberOut .00000
After run termination, a simulationist can click on "Output" in the Tools menu and
then on "Graph:' This gives options for graphical and tabular displays. Figure 4.15 shows
the table of the resulting waiting-time histogram. Clicking on "Data File" in the File menu
brings up a dialog box, one of whose options is to export the saved data to a user-specified
textual file for subsequent analysis.
Histories may be saved at the modular level using the STATS module in the Common
panel. It provides options for DSTATS, TALLIES COUNTERS, and FREQUENCY variables.
4.25. ARENA/SIMAN AIRLINE RESERVATION EXAMPLE 161
Histogram Summary
Waiting time
Recall that SIMAN maintains its future-event set (FES) or event calendar as a single
list. CREATE schedules arrivals by inserting the current Customer record into this FES with
reactivation time being the next InteLcall time. The first DELAY does similar linkage with
current time + 9 seconds as the reactivation time. The second DELAY performs similarly.
QUEUE effectively makes use of the lists defined in QUEUES to store records.
SEIZE selects and removes records from the Customer _Q as resources become available
at the RELEASE statement in another Customer process. Although SIMAN effects the
same logic for its QUEUE-SEIZE-RELEASE sequence as SIMSCRIPT 11.5 does for its
q.resource-x.resource-request-relinquish sequence, its list-processing programming code
differs substantially.
162 C HAP TE R 4. PRO G RAM MIN G AN D EXECUTION
As already mentioned, the BAAT panels permit modeling at a higher level of code
aggregation than exclusive reliance on the Blocks and Elements panels allow while retaining
more modeling flexibility than the more aggregated models in the CAT panels allow. As with
the other panels, each module in the BAAT panels has a dialogue box that enables a user to
specify which of several actions are to be taken. However, the BAAT menus in these boxes
offer more options and actions than those in the Block and Elements panels.
As illustration, the BAAT panels contain a multiple-purpose "process" module. We use
quotation marks here merely to distinguish Arena's use of the word "Process" from our more
generic use of the term to describe the principal concept in the process-interaction approach.
See Chapter 2. The dialogue box of the "Process" module contains a menu with items
Delay
Size, Delay
Size, Delay, Release
Delay, Release
where Seize, Delay and Release are SIMAN statements with corresponding entries in the
Blocks panel. A user clicks on the choice that fits the problem at hand. For example, a
modeler of the airline reservation problem may use Seize, Delay, Release or Delay, Release,
depending on how the time spent waiting is to be collected in the module. More generally,
we emphasize the versatility of this and other BAAT modules that allow a modeler to make
multiple Block selections in a single module.
Although space considerations limit what we can show here, we encourage the reader
to model the airline reservationist problem using the BAAT panels with the same input
specification depicted in Figure 4.13 based on Blocks and Elements. In principle, the outputs
should be identical.
As mentioned, both SIMAN and SLAM allow simulation modeling and programming using
the event-scheduling approach. Unlike SIMSCRIPT 11.5, however, for which the event-
scheduling syntax is an integral component of the language, Arena/SIMAN requires skill
in C (Pegden et al. 1995, Appendix F), and AweSimNisual Slam requires skill in C or Visual
Basic (Pritsker et al. 1995, Section 13.2). Regrettably, a consequence of these requirements
is to limit accessibility to the event-scheduling approach in these languages.
4.27. MACROMODULES 163
From the point of view of pedagogy, this should in no way deter the reader from
studying the concept of event scheduling in Chapter 2 and the programming constructs to
which it leads in Sections 4.2 through 4.17. Familiarity with these ideas provides a consid-
erably deeper understanding of the inner workings of discrete-event simulation than the
higher-level functionality of the process-interaction approach allows. The familiarity can be
of considerable help in trying to understand precedence relationships in complex models.
4.27 MACROMODULES
Macromodules can incorporate considerably more functionality than the elementary blocks
of a simulation language. The MIMll example well illustrates this, where three macromod-
ules in Figure 4.lO lead to the relatively detailed MOD and EXP files in Figure 4.11. Relying
on macromodules dearly saves time and has great appeal for the experienced program-
mer. Moreover, the minimal programming to which it leads allows those with little if any
familiarity with a language to model complex systems and execute simulations of them.
For both experienced and inexperienced programmers, there is an issue of correct-
ness. In particular, the user of this approach needs to be assured that the generated code
does, indeed, do exactly what helshe wishes. Studying the self-documenting code in Figure
4.11 provides one way to gain this assurance. In practice, many a simulationist pays scant
attention to this code. Regardless of the simulation language, this can lead to a serious mis-
representation of modeling logic, as the next several examples show. This is especially so at
the higher level, for example, in modeling conveyors, where many alternative logic protocols
exist and only one ofwhich may be embraced in the macromodules of a particular simulation
language.
Three examples taken from Banks and Gibson (1997) illustrate the dangers inherent
in this minimal approach to simulation programming based on macromodules:
The words sound right. You want to model a bridge crane. The no-programming
software has a bridge crane! The model must include an automated guided vehicle
(AGV). Okay, the no-programming software has an AGV. This looks easy, and the
model is constructed rapidly. It takes only four hours to build with animation, and
that's four-and-a-half days faster than with the package that doesn't advertise no-
programming.
But you need to dig deeper into what the bridge crane module really does. You
need to dig deeper into those AGV movement rules. What scheduling logic is being
used? What parking rules are used? Is this the same as your bridge crane? Does your
AGV system work this way?
There is much danger in treating these capabilities as a black box. You may
find that you haven't accounted for the minimum spacing of the AGVs, and that is
important. You may find that the control algorithm for the bridge crane is not the
same as the one your system is using, and it can't be changed.
We might go as far as saying that by not requiring you to explicitly specify or
"program" model logic, no-programming packages hide critical details that you may
need to see in order to understand and verify the model's behavior and results. If you
were told to design a machine, you wouldn't simply describe the machine's outside
view, fill its surface with some pretty colors from your paintbrush type software, and
then turn on the automatic inside machine design program. You would need to design
the inside of that machine carefully, including all of the spindles, bearings, gears, races,
and their interactions.
4.28. LESSONS LEARNED 165
MODULE OPAQUENESS
• Recording first and last seeds for each pseudorandom number stream allows for easy
reproducibility of results. This is especially helpful in checking out a program. It also
facilitates the use of common pseudorandom number streams.
• The method of common pseudorandom number streams is a technique that may lead
to a variance reduction in comparing sample averages computed from data on two
simulation runs, each based on a different assignment for parameter values or on
different system operating rules.
• SIMSCRIPT 11.5 is a full-service programming language that allows all the arithmetic
and file management operations in languages like FORTRAN and C and, in addition,
has a syntax catering to discrete-event simulation. Unix and Windows implementa-
tions are available, the latter allowing a point-click-drag-drop approach to program
construction. Its principal concepts are events, processes, entities, attributes, sets, and
event notices. It admits both the event-scheduling and process-interaction approaches
166 CHAPTER 4. PROGRAMMING AND EXECUTION
to modeling. Its principal strength comes from the high level of generality it offers for
modeling the competing demands for resources that arise in a wide variety of delay
systems. However, this high generality puts more of a burden on the simulationist
with regard to programming than do other languages, such as GPSS/H, SLAM, and
SIMAN, that provide constructs considerably more focused on commonly encoun-
tered flow logics. Nevertheless, SIMSCRIPT 11.5 offers many pedagogic benefits for
teaching students how to model much of this logic, a particularly valuable asset when
one encounters a nonstandard flow logic that some of these other languages either
handle awkwardly or cannot handle.
• For the same problem, a program coded in SIMAN tends to execute faster than one
coded in SIMSCRIPT 11.5. SIMAN and SIMSCRIPT 11.5 are C-based.
4.29 EXERCISES
GENERAL INSTRUCTIONS
differences. The instructor can assign seeds in a way that ensures nonoverlapping sequences
for the streams assigned to each source of variation for each student as well as nonoverlapping
sequences among students.
While this ability to compare answers is a classroom luxury not available in prac-
tice, its ability to sensitize students to how seemingly small coding differences can generate
substantially different sample paths makes the approach worthwhile.
The second set of assigned seeds are unique to the student. Once differences in runs
using the class seeds are resolved, each student uses the individual seeds to execute her/his pro-
gram. For N students, this provides N independent sets of statistical results to the instructor
for analysis.
In addition to a complete listing of the simulation program, each student's submission
should contain a listing of the values of all input parameters. Each should contain two sets
of output, one using class seeds and the other, the student's seeds. Each of these outputs
should list initial and final seeds for each pseudorandom number stream. All results should
be listed to four significant digits.
tjfJl4.1 Prepare a flowchart for an event that repeatedly executes at one-minute intervals
and collects data on:
iv. tons of stone unloaded at the crusher during the past minute (throughput).
tjfJl 4.2 This exercise establishes a basis for estimating profit without external deliveries.
Prepare and execute a simulation program based on the event-scheduling approach using
the flowcharts in Excercise 2.1e.
a. Begin the simulation with all trucks at their respective shovels and with the 50-ton
truck ready to begin loading. Priority order is arrival at the crusher, arrival at a shovel,
and data collection.
b. Table 4.3 shows how trucks are identified with shovels. Assign pseudorandom number
stream i to truck i for i = 1, ... , 9 to generate times for loading, transit to crusher,
dumping, and transit to shovels. At site 1 the ordering of trucks is 1, 2, and 3. At site
2 it is 4, 5, and 6. At site 3 it is 7, 8, and 9.
d. For debugging purposes, all students should use the same seeds for corresponding
streams. For personal runs, each student should use distinct seeds taken from Table 4.2.
Doing so allows us to regard personal runs as statistically independent replications.
Note: Assigning distinct seeds within a row in Table 4.2 to the nine streams called
for in part b ensures that the sequences generated by these streams do not overlap,
provided that each truck makes no more than 1,000,000/4 = 250,000 round
trips from its shovel. Assigning a distinct row to each student and a distinct row
for class seeds ensures that the sample paths generated by each student and by the
class seeds are statistically independent.
e. Compute estimates of
i. crusher throughput
f. Prepare graphs of
t%? 4.3 This exercise establishes a basis for comparing profits with and without external
deliveries. Prepare and execute a simulation program based on the event-scheduling ap-
proach using the augmented flowcharts in Exercise 2.2b that incorporate stone delivered by
the outside contractor.
a. Use the initial conditions in Exercise 4.2a augmented by the arrival at the crusher of a
truck from the external source.
b. Assign stream 10 to inter arrival times for external deliveries and stream 11 for
corresponding unloading times.
N.B. These assignments preserve the same stochastic variation associated with the
original nine trucks, so that changes in performance are due to the addition of
external trucks and the stochastic variation that their interarrival and service times
induce.
d. Run the simulation using the same seeds for streams 1 through 9 as in Exercise 4.2b.
h. Describe the influence of initial conditions in the graphs of part g and compare them
to what you observed in the corresponding graphs in Exercise 4.2f.
i. Discuss the effects of external deliveries on profits and utilization of Hard Rock's
equipment. See Exercise 2.2.
t%? 4.4 Independent Runs. Rerun Exercise 3 using the last pseudorandom numbers
produced there as the seeds for corresponding seeds in the new run. For j = 1, ... , 72, let
ZZj := crusher throughput during time [5(j - 1), 5 j) for Exercise 4.2
Z3j := crusher throughput during time [5(j - 1), 5j) for Exercise 4.3
Z4j := crusher throughput during time [5(j - 1), 5j) for the current exercise.
170 CHAPTER 4. PROGRAMMING AND EXECUTION
Plot {Z3j - ZZj; j = 1, ... , 72} and {Z4j - ZZj; j = 1, ... , 72} on the same graph and
interpret the differences between them, ostensibly due to the use of common pseudorandom
numbers.
~ 4.5 Prepare and execute a simulation program based on the process-interaction ap-
proach using the flowcharts in Exercise 2.1 f and Exercise 4.1. Follow the directions in Exercises
4.2a through 4.2e and show that this program produces the identical results as in Exercise
4.2e.
~ 4.6 Prepare and execute a simulation program based on the process-interaction ap-
proach using the flowchart in Exercise 2.2c and Exercise 4.1. Follow the directions in Exercises
4.2a through 4.2e and show that this program produces the identical results as in Exercise
4.3f.
~ 4.7 Using the flowcharts for Exercise 2.3b based on the event-scheduling approach,
prepare and execute a simulation program for the tanker problem.
a. For events that occur at the same time, assume the priority order: tanker arrival, tanker
berthing, loading completion, picking up a tanker at a berth, picking up a tanker in
the harbor, and tanker departure.
b. Start the simulation with all berths idle, the tug in the harbor, and the arrival of a
tanker in the harbor.
c. Run the simulation until the nth tanker has sailed from the harbor, where n = 1000
tankers.
Pseudorandom
Source of variation stream no.
Interarrival times
Towing in 2
Towing out 3
Deadheading in 4
Deadheading out 5
Type 6
Loading times
type 1 7
2 8
3 9
e. Data Collection and Analysis. Let Tn denote the simulated time at which the nth
tanker has sailed from the harbor. Use data from the simulated time interval [O,Tnl to
estimate system parameters. In addition to identifying input parameter values clearly,
your output should contain averages, standard deviations, and maxima for:
IV. Number of committed berths (reserved for tankers being towed in and holding
loaded tankers waiting to be towed out). A "committed" berth is one that has a
nonloading tanker occupying it or is awaiting a tanker that the tug is either towing
or is deadheading to get.
Based on the port time definition in Exercise 2.3, it should also contain estimates of:
t$? 4.8 Using the flowcharts for Exercise 2.3c based on the process-interation approach,
prepare and execute a SIMSCRIPT U.5 simulation program for the tanker problem, treating
tankers and tugs as processes. Include steps a through e of Exercise 4.7.
t$? 4.9 Based on the augmented flowcharts in Exercise 2.4b for the event -scheduling
approach, prepare and execute a simulation program using the same input as in Exercise 4.7.
For the additional tankers, use
Pseudorandom
Sources of variation for new tankers stream no.
Round-trip times 10
Deadheading in 11
Deadheading out 12
Towing in 13
Towing out 14
Loading times 15
~ 4.10 Do the same as in Exercise 4.9 for the process-interaction approach as modeled
in Exercise 2Ac.
~ 4.11 Do the same as in Exercise 4.9 for the mixed approach modeled in Exercise 2Ad.
The simulation programs developed in Exercises 4.12 and 4.13 establish a mechanism
for generating sample-path data to be employed in Chapters 6 and 7 to estimate how mean
delay in transmission /L(m,).,) in expression (2.6) varies as a function of character arrival
rate)" and packet size m.
~ 4.12 Using the flowcharts for Exercise 2.5b based on the event-scheduling approach,
prepare and execute a simulation program for the terminal PAD controller problem.
a. Give precedence to arrivals at the output buffer over arrivals at input buffers and to
transmission completions over arrivals at the output buffer.
d. For a first run, take)., = 1/20 characters per time unit and m = 32 and run the
simulation until the output buffer transmits the t = 2500th nonoverhead character.
e. Let
Collect and use T1 , ••• , 4, to estimate /L(m,).,) and the exceedance probabilities
pr(Ii > w) for each w E {350, 400, 450, 500, 550, 600}.
f. Graph T1 , ••• , Tt • What does this reveal about the warm-up interval?
4.30. REF ERE NeE 5 173
rf}? 4.13 Using the flowcharts for Exercise 2.6 based on the process-interaction ap-
proach, prepare and execute a simulation program for the terminal PAD controller problem
according to parts a through f in Exercise 4.12.
The simulation programs developed in Exercises 4.14 and 4.15 provide a means to be
employed in Chapters 6 and 7 for generating sample-path data for estimating the loss prob-
abilities fJh (m, r) and fJs (m, r) in expression (2.7), as functions of number of transmission
lines m and number oflines r dedicated to handoffs.
rf}? 4.14 Using the flowcharts for Exercise 2.6 based on the event-scheduling approach,
prepare and execute a simulation program for the mobile-telephone service problem.
a. Give precedence to hand-off arrivals over standard arrivals and to call completions
over all arrivals.
b. Begin with one randomly scheduled hand-off and one randomly scheduled arrival to
an otherwise empty and idle system.
c. Assign pseudorandom number stream 1 to interarrival times of han doffs, stream 2 to
standard interarrival times, stream 3 to duration times for handoffs, and stream 4 to
duration times for standard calls.
d. Run the simulation with m = 11, r = 0, Ah = 2, As = 4, (j) = 1 for a total of t = 1000
calls regardless of type. Hint: The quantity Ah / (Ah + As) denotes the probability that
a new call is a mobile call.
e. Devise and implement a data collection plan to estimate fJh (m, r) and fJs (m, r) in
expression (2.7).
f. Devise and implement a graphical analysis to assess the influence of initial conditions
on the sample-path data of part e.
g. Note any distinction between the statistical properties of the estimates of fJh (m, r) and
fJs(m, r).
rf}? 4.15 Using the flowcharts for Exercise 2.6e based on the process-interaction ap-
proach, prepare and execute a simulation program for the mobile telephone service problem
according to parts a through g in Exercise 4.14.
4.30 REFERENCES
Banks, J., and R. Gibson (1997). Simulation modeling: some programming required, JIB
Solutions, 29, 26-31.
174 CHAPTER 4. PROGRAMMING AND EXECUTION
CACI (1987). SIMSCRIPT II.S Programming Language, CACI Products Company, La Jolla,
California.
CACI (1993a). SIMSCRIPT II.S Reference Handbook, CACI Products Company, La Jolla,
California.
CACI (1993b). SIMDEBUG User's Manual: SIMSCRIPT II.S Symbolic Debugger, CACI
Products Company, La Jolla, California.
CACI (1997). SIMSCRIPT II.S Reference Handbook, CACI Products Company, La Jolla,
California.
Fishman, G.S. (1996). Monte Carlo: Concepts, Algorithms, and Applications, Springer-Verlag,
New York.
Henriksen, J.O. (1997). An introduction to SLX, 1997 Winter Simulation Conference Pro-
ceedings, S. Andrid6ttir, K.J. Healy, D.H. Withers, and B.L. Nelson, editors, IEEE,
Piscataway, N.J.
Kelton, W.D., RP. Sadowski, and D.A. Sadowski (1998). Simulation with Arena, McGraw-Hill,
New York.
Kiviat, P.J., R Villanueva, and H.M. Markowitz (1969). The SIMSCRIPT II.S Programming
Language, Prentice-Hall, Englewood Cliffs, N.J.
Law, A.M., and W.D. Kelton (1991). Simulation Modeling and Analysis, McGraw-Hill, New
York.
Pegden, CD., R.E. Shannon, and RP. Sadowski (1995). Introduction to Simulation Using
SIMAN, second edition, McGraw-Hill, New York.
Pritsker, A.A.B. (1995). Introduction to Simulation and SLAM II, fourth edition, Wiley, New
York.
Pritsker, A.A.B., and P.J. Kiviat (1969). Simulation with GASP II, Prentice-Hall, Englewood
Cliffs, N.J.
Pritsker, A.A.B., and J.J. O'Reilly (1999). Simulation with Visual SLAM and AweSim, second
edition, Wiley, New York.
Schriber, T.J. (1991). An Introduction to Simulation Using GPSSIH, Wiley, New York.
Swain, J.J. (1999). 1999 Simulation software survey, ORMS Today, 26, 38-5l.
4.30. REF ERE NeE s 175
Every execution of a computer program uses memory space and consumes computing time.
In particular, a discrete-event simulation expends a considerable proportion of its running
time executing searches for new space and creating and maintaining order among the myriad
of entity records and event notices it generates as simulated time evolves. In spite of their
relative importance, current PC workstation environments, with their substantial memo-
ries and reduced, if nonexistent, emphasis on execution within a specified computing time
constraint, make these topics appear less important to the simulationist than they were in
the past. Moreover, every simulation programming language implicitly provides a means for
managing space and performing searches during execution of virtually any program written
in the language, further removing these issues from a simulationist's consciousness.
This computing environment is reassuring to a potential simulationist, for it relieves
her/him of the need to be concerned about memory space and computing time for simu-
lations of small and moderate sizes. Indeed, most advertising for simulation languages and
packages focus on examples that illustrate this speed of execution. However, as the number of
entity and event classes in a simulation increases, it is not unusual to see the corresponding
computing time increase rapidly. What may have taken seconds for a small-size simula-
tion now takes minutes for its moderate-size extension. What may have taken hours for a
178 CHAPTER 5. SEA RCH, SPA eE, AND TIME
moderate-sized simulation now takes days for its large-size extension. When such an increase
in computing time occurs, it often puzzles and frustrates the simulationist.
Simulation languages manage space and conduct searches in different ways. As a
consequence, programs based on the same simulation logic but written in different languages
vary in their execution times and space needs. It is not the purpose of this chapter to
choose the one among these languages that performs best with respect to time and space
conservation. Indeed, it is problematic to determine whether a single language dominates
when one considers the widely varying characteristics of many simulations ..
This chapter has a twofold purpose: to characterize the way in which memory space
needs arise during a simulation and to describe prototypical modes of memory manage-
ment and search that characterize the procedures that many simulation languages employ.
An awareness of these concepts enables a simulationist to anticipate potential computing
problems during the design phase of a study, rather than encountering them as a consequence
of costly execution.
To establish a formalism for discussing space and time, Section 5.1 describes a series-
parallel queueing model whose parameters we employ throughout the chapter to characterize
how space and time needs vary. Section 5.1.1 addresses the space issue generically for the
future-event set, and Section 5.1.2 illustrates how thoughtful analysis prior to modeling can
significantly reduce space needs during execution.
This illustration has more general implications. Rather than regarding a problem's
description as a recipe to be translated into programming code and then executed, the illus-
tration encourages simulationists to apply their skills of mathematical analysis to transform
the description into a probabilistic equivalent that increases computational efficiency.
To set the stage for a discussion of space management, Section 5.2 describes the essential
features oflist processing, with emphasis on predecessor-successor relationships. Section 5.3
introduces a succession of progressively more sophisticated procedures for this management.
Section 5.4 focuses on the management of the future-event set. In particular Section 5.4.1
discusses single linear event lists, Section 5.4.2 multiple linear event lists, Section 5.4.3 heaps,
and Section 5.4.4 Henriksen's Algorithm. An example, carried through the four subsections,
provides a basis for understanding and comparing the time needs of each method of FES
management.
Section 5.5 describes how the restricted formalism of Section 5.1, which Sections 5.1.1
through 5.4.5 employ to illustrate concepts, can be extended to a broader class of delay
models.
arrivals
several of these properties as they arise in the context of a commonly encountered class of
delay problems. Once acquainted with these properties, the reader will have a perspective for
understanding what motivates the discussion of alternative data structures for space search
in Section 5.2 and for managing the FES in Sections 5.4.1 through 5.4.4. To broaden the range
of applicability of these concepts, Section 5.5 relaxes several of the modeling assumptions
made in the present section.
Consider a simulation model based on the k-station queueing system in Figure 5.1,
where r statistically independent arrival processes feed jobs to station 1. Every job receives
service at each station j from one ofits m j servers for j = 1, ... , k. Upon completion of
serviceatstationk,ajobdepartsthesystem.Fori = 1, ... , r,arrivals of type i occur at times
Til ~ Ii2 ~ ... with identically distributed interarrival times {Ii,/+l - Iiz; I = 1,2, ... }
with mean 1/Wai.
Each server at station j has identically distributed service times with mean l/wsj for
j = 1, ... , k. Then one may think of Wa := Wa\ + ... + War as the rate at which jobs arrive
to the system at station 1 and of m jWsj as the rate at which station j processes waiting jobs
for j = 1, ... , k.
At each simulated time r, interest focuses on
and
where
and
p := max p. < 1,
max l::;j~k J
where
j = 1, ... ,k.
where
_ 1
m:= -(ml
k
+ ... +mk). (5.2)
5.1. MEMORY SPACE NEEDS AND COMPUTING TIME 181
Were station j to have a finite buffer capacity, C j' for each j = 1, ... , k and were jobs lost
to the system when they arrive at station j and find its buffer full (i.e., Qj ( r) = C j ), then
where
Let
and
In a highly congested system, these properties imply that at an arbitrarily selected time r:
• The number of event notices in the FES, r + B (r), is most likely to be r + km.
• The number of extant temporary entities, B( r) + Q( r), is most likely to be k(G + m).
and
implying that:
• The number of event notices in the FES tends to grow without bound as mincreases.
182 CHAPTER 5. SEARCH, SPACE, AND TIME
We next examine how space needs vary as a function of traffic intensity and the
amount of stochastic variation in interarrival and service times. In a highly congested but
uncapacitated system (Cj = 00; j = 1, ... , k), memory space needed for event notices
remains proportional to r + klii. However, space needs to accommodate the records of
temporary entities behave differently. As an illustration, suppose that Tl :s Tz :s ... denotes
the ordered interarrival times Uj=l {Tjz; 1= 1,2 ... } for the r types of arrivals and assume
that {Iz+! - 1/; I = 1,2, ... } is an Li.d. sequence with mean l/wa and variance a~. Also,
assume that the service times at station j have variance, a~. Let
a
Ya := _a_ = coefficient of variation of interarrival times
l/wa
and
a·
Ysj := _S_l_ = coefficient of variation of service times at station j.
l/wsj
Small Ya implies that interarrival times vary little from their mean, whereas large Ya implies
large deviations from this mean. An analogous characterization applies to Ysj for service
times at station j.
It is known (Kollerstrom 1974) that if interarrival times to station j are i.i.d. and traffic
intensity Pj is less than but close to unity, then
(5.5)
As an example, a model with Pj = .99 and Ya = Ysj = l/./i, as would be the case if
interarrival and service times came from Erlang distributions with two phases (Section 8.13),
gives v ~ 49.50. However, if interarrival and service times were exponentially distributed,
then Ya = Ysj = I, so that v ~ 99.00. The sensitivity to stochastic variation is apparent.
These results, based on mean-value behavior, convey only part of the story regarding
space needs in an uncapacitated queueing system. Suppose one runs the simulation for
5.1. MEMORY SPACE NEEDS AND COMPUTING TIME 183
where
gives the maximal number of temporary entities in the system during the simulation. For
every fixed positive integer q, pr[suPO~Z::9 Q(z) > q] is an increasing function of t, implying
that for given input Wa!, ... , War, Ws!, ... , Wsb m!, ... , mb a long simulation run is likely
to demand more space to store its records than a short run.
Each job passing through the system induces 2( 1 + k) interactions with the FES, one
to schedule the next arrival of this type, k to schedule its completions at each of the k stations
it must visit, and 1 + k to select the next event to execute when the job arrives at station 1
and completes service at stations j = 1, ... , k.
Let ga (q) denote the average computing time required to schedule an additional event
when the FES contains q event notices and let gb(q) denote the average computing time
required to select the next event from an FES containing q event notices. Then at simulated
time r at which an interaction with the FES occurs, each job passing through the system
consumes
(1 + k)[Ega(r + B(r)) + Egb(r + B(r)] ::: (1 + k)[ga(r + km) + gb(r + km)] (5.6)
computing time on average interacting with the future-event set. Each simulation language's
protocol for managing the FES determines the particular form that ga(.) and gb(.) take. For
example, Section 5.4.3 shows that simulation languages that structure their future-event sets
as binary heaps have ga(B(r)) = O(logz B(r)) and gb(B(r)) = O(logz B(r)). Therefore,
for a simulation of a highly congested system that uses these languages, each job's interaction
with the FES takes O( (1 + k) logz (r + km)) time on average. Regardless of the protocol,
{ga (q)} and {gb (q)} both are increasing functions of q.
The last -mentioned property suggests that any reduction in the size of the FES reduces
its average management time. Here we describe one opportunity for reduction. Suppose that
for each arrival of type i = 1, ... , r, the interarrival times {'Ii.I+! - 'IiI; I = 1,2, ... }
184 CHAPTER 5. SEARCH, SPACE, AND TIME
form a sequence of i.i.d. exponentially distributed random variables with exponential p.d.f.
denoted bycaIP(wair). As we have described the model, one would proceed as follows:
PROTOCOL A
• Creates a record for the arriving job and assigns i to its type attribute.
PROTOCOL B
• Creates a record for the arriving job and assigns I to its type attribute.
• Creates and files an event notice in the FES for this next arrival with execution time
r+t::..T.
Protocol B generates an arrival process with statistical properties identical to those induced
by Protocol A. However, with regard to benefits and costs, Protocol A:
• Requires O(r + km) memory space to store the event notices needed to maintain the
FES.
• Consumes 0((1 + k)[ga(r + kin) + gb(r + km)]) average time per job interacting
with the FES.
• Requires O( 1 + km) memory space to store the event notices needed to maintain the
FES.
The statistical equivalence of samples generated by Protocols A and B exists if and only
if {1I,1+1 - 111; I = 1, 2, ... } are i.i.d. exponentially distributed random variables for each
type i = 1, ... , k. If these times have any other distributions, applying Protocol B would be
inappropriate. However, for some simulation formulations, the assumptions of the underly-
ing problem are that interarrival times for the aggregate arrival process are i.i.d. with known
distribution and with known selection p.m.f. {qj := pr(that an arrival is of type i); i =
1, ... , k}. Then we can effect the same procedure as in Protocol B as follows:
PROTOCOLC
• Creates a record for the arriving job and assigns I to its type attribute.
186 CHAPTER 5. SEARCH, SPACE, AND TIME
• Samples the next interarrival time t::.T from its interarrival time distribution.
• Creates and files an event notice in the FES for this next arrival with execution time
r + t::.T.
When it applies, Protocol C allows one to reap the same space and time benefits as in Protocol
B.
If a modeler has empirical arrival-time data {Iiz; I = 1, ... , Nd for i = 1, ... , r,
these revelations regarding the advantages of Protocol C should encourage her/him to follow
these steps when modeling the arrival process (see Chapter 10):
• If H is accepted:
Simulation languages usually employ one of two memory management techniques. One,
as in SIMSCRIPT 11.5, searches and allocates space each time the simulation calls for the
creation of a record for a new temporary entity or for a new event notice. The other, as in
GPSS/H, SIMAN, and SLAM, uses a block-array concept to accomplish the same purpose. At
the start of execution it allocates a block of contiguous memory space, which the executing
simulation uses to store new temporary entity records and event notices. Once a record
or event notice is no longer needed, both approaches make previously committed space
available for future use.
Regardless of the space allocation approach, all simulation languages rely heavily on
the concept of list processing to keep order among records and event notices as simulated
time elapses. List processing denotes a myriad of operations executable on a data structure
in a digital computer. The data structure is called a list. The list contains records each of
which has fields to store information. The operations include (Knuth 1973):
5 .2 . LIs T PROC E S SIN G 187
• Gaining access to the jth record of a list to examine or change its content.
• Inserting a new record after the jth but before the (j + 1)st record.
• Deleting the jth record from the list.
• Combining lists.
• Ordering records in a list in ascending order based on the values in specified fields.
• Searching the list for records with given values in certain fields.
FIELD
2 3 4 5
ship arrival cargo predecessor successor
Address identification time tonnage address address
FIELD
2 3 4 5
ship arrival cargo predecessor successor
Address identification time tonnage address address
new
record -LI_0_8_0_91----''--_1_8_--'--_1_67_._3--'-_1_4_7_24_4--'-_ _ _ . 1 - -_ _- '
,-----'---'---'-----'-----------'---'-----'---------'-----------------------------'1
i !
trailer
!
! i
before
I000~1 I I08091 I i insertion
!i !
'_._._-_._._._._._._._._._._._._-_._._---_._._._--._.--------------------------- ...:i
r------------------------------------------·
, '
:,
,
~ after
~:
insertion
,,
,, ,,
L__________________________________________ I
is simply record 14. Similar predecessor relationships apply for records 16 and 17. A reverse
relationship exists for the successor relationship. Record 17, the last record in the list, has no
successor and is called the trailer.
Ordering the records in this way facilitates the selection of the next ship for unloading
when a berth becomes idle. In particular, one selects the header record (1) and makes record
2 the new header. This selection presumes that ships receive service in the order of their
arrival. Suppose that service is to occur in increasing order of cargo tonnage (field 3). Then
Figure s.2b shows the predecessor-successor relationships that prevail for the four waiting
ships. Also suppose that a new ship, 18, arrives at time 167.3 (field 1) with a cargo of 147244
tons (field 3) and "enters" the queue. Figure S.2c shows the new record and the old and new
predecessor-successor relationships that prevail when cargo tonnage determines order. Note
that in order to chain record 18 to the list one need change only the predecessor address of
record 15, the successor address of record 17, and assign predecessor and successor addresses
to record 18. These operations correspond to the concept of inserting a record into the list.
Deleting a record from the list entails converse operations.
prevailing discipline for ordering the records upon insertion in the list, as in Figure S.2a,
then a single linear list has constant insertion and deletion times, regardless of its length.
If the ordering discipline depends on an attribute of the record other than simulated
time at insertion as in Figure S.2b, then relying on a single linear list becomes problematic.
For example, suppose that ordering within the QUEUE in the airline reservation example is
based first on TYPE (either ONE or MANY) and then on simulated time at insertion. If the
list contains N records, insertion can take O(N) computing time, as would occur when all
N records have TYPE = MANY, the record to be inserted has TYPE = ONE, and the list is
entered from its front end.
Maintaining two lists, one for each TYPE, would again lead to constant computing
times for insertion and deletion, independent of list lengths. However, two lists create a need
to check a record's TYPE to choose the appropriate list for insertion and a need to check
both lists for deletion when the higher-priority list is empty.
More generally, the computing times to insert and delete records according to the values
of an attribute other than simulated time of insertion can, in principle, be made independent
of the lengths of the lists by using multiple lists as above. However, the computing time
required to determine the list in which to insert a record or from which to delete a record
tends to increase with the number oflists. If k lists hold N records in total and N » k, then
multiple lists tend to offer a computational advantage. If k > N, as occurs when there are
relatively few waiting customers virtually all of whom differ with regard to their values for
the critical attribute, then a single list is likely to offer an advantage.
Every simulation language has built-in procedures for maintaining lists. Some use
multiple linear lists as above, others use special data structures, such as heaps that do not
maintain completely ordered lists but have O(log2 N) insertion and deletion computing
times. Section S.4.3 describes binary heaps in the context of managing the future-event set,
which is a list ordered on desired execution, rather than scheduling, time for an event.
While its supporting documentation rarely spells out the exact modality that a language
has adopted for list processing, presumably for proprietary reasons, list processing times all
have common tendencies. They grow with the number of sublists employed to accommodate
the primary criterion for insertion and with the number of entries per sublist if the secondary
criterion for insertion is other than simulated time of insertion. The present discussion is
intended merely to sensitize the first-time user of a simulation language to a potentially
major consumer of computing time.
During execution, a simulation must maintain records of temporary entities and of event
notices in its FES to ensure continued evolution. As time elapses the number of these entity
records and the number ofthese event notices vary, often substantially. Accommodating these
5.3. DYNAMIC SPACE MANAGEMENT 191
records and event notices and managing their creation and eventual elimination account for
a major portion of computing time.
Every computer program begins execution with an upper bound on the memory
allocated to it. Sometimes this is literally at the individual program level. More often, today's
computing environments impose this upper bound at the level of the user. That is, he/she is
given some partition of memory within which to do computing in a stand-alone computing
environment. This partition can be virtually the entire uncommitted memory capacity of the
computer. In a network environment, the size of this partition usually reflects the competing
needs of all network users.
At the beginning of a simulation run, some of this space becomes reserved for the
program and data records that it needs to begin execution. Several languages also set aside
large block arrays within which the simulation stores records of temporary entities and event
notices as they arise during the simulation's execution. Others provide this space on demand.
The present account describes both approaches.
Algorithms SPACE_FINDER and SPACE-RELEASER describe elementary prototypes
of dynamic space management:
ALGORITHM SPACE_FINDER
1. Search of space
Yes No
3y. Mark space as occupied. 3n. Terminate simulation.
4y. Assign space.
Sy. Continue simulation.
ALGORITHM SPACE_RELEASER
3. Continue simulation.
The likelihood of this occurrence increases with the length of time for which the simulation
program is to be run. To reduce the frequency of such an occurrence, an effective space
management policy releases space as soon as it is no longer needed, so that it can be merged
with contiguous uncommitted space and subsequently assigned to future demands as they
arise. For example, the airline reservation simulation destroys temporary entity records for
CUSTOMERs in block 4 of Figure 2.8 and destroys event notices for executed events in
block 4 of Figure 2.5. Therefore, good programming practice encourages one to:
Let dynamic space manager (DSM) denote the procedure that a simulation language
employs to search for and assign space. For simplicity, one can regard the DSM as a sub-
program to which a simulation program transfers control each time it requests or indicates
that it no longer needs a space segment. Let an uncommitted space segment of length n de-
note a sequence of n successive words in computer memory that are not already assigned.
Assume that the DSM maintains a space roster, a linked list of records each containing the
address of the first word of a noncontiguous uncommitted space segment and its length. A
noncontiguous uncommitted space segment oflength n denotes a sequence of n successive
uncommitted words in memory preceded and succeeded by previously allocated words.
Each attempt to assign space in Algorithm SPACE_FINDER requires a search of the
space roster to identify the locations of uncommitted space segments and their lengths.
Conversely, every attempt to merge space in Algorithm SPACE_RELEASER requires a search.
Collectively, allocating and merging space consume a substantial portion of computing time
in a simulation.
For a given simulation, let <¥l denote the mean computing time expended per space
allocation and let <¥2 denote the mean computing time expended per space merge. Suppose
the simulation is executed until N jobs, or CALLs in the airline reservation problem, receive
service. If f denotes the frequency with which new space is allocated per job or CALL
during this simulation, and if we assume that a space merge eventually follows each space
allocation, then the DSM consumes mean computing time f . (<¥l + «2) per job or CALL.
Clearly, choosing efficient space allocation and merge procedures makes <¥l and <¥2 smaller
than they would otherwise be, and that is clearly desirable. Moreover, adopting a simulation
programming strategy that keeps f as small as possible is also desirable. To control f, we
repeat our earlier admonition:
• Aggregate elementary events that occur at the same simulated time into compound
events.
Since allocating space for an n2 -word record takes more time in general than allocating
space for an n 1 -word record, where n2 > n 1, the additional admonition:
• Keep the number of attributes of events and entities to the required minimum.
5 .3 . DYNAMIC SPACE MANAGEMENT 193
predecessor successor
address address
A(1,I) A(1,2) ... A(1,r - 1) A(1,r) D(1)
A(2,1) A(2,2) ... A(2,r - 1) A(2,r) D(2)
trailer--+ )-1 n
header--+ ) 2
n- 1
n 2 ) - 1
iI, i 2, ... , i n - 4 is a permutation of {l, ... , n} \ {2, ) - 1, ), n}
(b)
To effect space allocation and merge, a dynamic space manager can take alternative
forms. For example, some simulation programming languages rely exclusively on linear
linked lists to keep track of uncommitted space (e.g., Figure 5.2). With each successive space
allocation, the computing time required to find an uncommitted segment of space of any
given length tends to increase, usually because more search is required. Other languages rely
on a block array approach, combined with a linked list, to reduce this search time. This
alternative can significantly reduce search time.
For the moment, assume that all space requests are for segments of r contiguous words.
Figure 5.3 depicts an n x r block array A and an n x 1 block array D. Each row of A denotes
a space segment of length r, including fields for predecessor and successor addresses that
allow chaining linked committed rows of A into a doubly linked linear list called ALIST. We
emphasize that this is merely one way to maintain a list. Section 5.4.3 describes the concept
of a heap, which provides the basis for alternative list-maintenance procedures that become
increasingly more efficient as the number of records in the list grows. The D array contains
the addresses of uncommitted rows in A.
194 CHAPTER 5. SEARCH, SPACE, AND TIME
and
#VACANT +- n.
Then Algorithm SPACE...FINDER* describes one way to satisfy a demand for space oflength T
in less computing time on average than Algorithm SPACE...FINDER. IfA has no uncommitted
rows (#VACANT = 0), the algorithm executes its right branch in computing time that varies
with space availability in the remaining memory. However, if A has at least one uncommitted
row (#VACANT > 0), the algorithm executes its left branch in constant computer time,
independent of the availability of space in the remaining memory. This occurs because no
need exists to search for space. As n increases relative to the number of space segments
occupied at a moment in simulated time, the constant-time left branch comes to dominate.
Figure 5.3b illustrates chaining in the ALIST where rows j, 2, n, and j - 1 comprise the
ALIST, indicating that these are committed, whereas the remaining n - 4 rows listed in the
D array are uncommitted. Note that the ALIST also may contain committed space segments
not in the A array.
ALGORITHM SPACE_FINDER*
Yes No
2y. i +- D(1). 2n. Execute Algorithm SPACE-FINDER.
3y. If #VACANT > 1,
D(1) +- D(#VACANT).
4y. #VACANT +- #VACANT - 1.
Sy. Assign record to A(i, 1), ... , A(i, r).
6y. Insert new record last in ALIST.
7y. Continue simulation.
ALGORITHM SPACE_RELEASER*
Record is in
A array?
Yes No
For the left branch of Algorithm SPACE_FlNDER*, let f31 denote the mean computing
time expended per space allocation and let f3z denote the mean computing time expended
per space release. Note that f31 :s al and f3z :s az. Let P denote the probability that space is
available in the A array to satisfy a space demand (left branch). Then mean computing time
for Algorithm SPACE_FlNDER* is
and
Since
the second alternative allows one to choose an n :::: n 1+... +nk without necessarily increasing
the frequency of search for space in remaining memory. Moreover, if rl = ... = rb then
nrl :::: (nl + ... + nk)rh implying a reduction in space as well.
5.3.2 RESIZING
Since the frequency of search for new space in Algorithm SPACE-FINDER* dimin-
ishes as n increases, computing time is reduced, but at the expense of reserving more,
potentially unused, space for the A and D block arrays. To balance computing time and
space considerations, some DSMs start with a small or moderate n but allow for an upward
resizing of the arrays if the test #VACANT = 0 is true in Algorithm SPACE-FINDER*. Al-
gorithm SPACE-FINDER** displays a prototypical procedure for performing these steps,
where (j(n) (> n) denotes an integer-valued function of n. For example, (j(n) := n doubles
the numbers of rows in A and D each time it exhausts the already available space.
Using Algorithm SPACE-FINDER** instead of Algorithm SPACE-FINDER* replaces
the need to search for space for individual records by a considerably less frequent need
to search for block arrays to augment A and D. While each resizing of the block ar-
rays may consume considerably more computing time, the lower rate at which resizing
is necessary generally favors the approach. Again, we emphasize that applying Algorithm
SPACE_FINDER** to each of k pairs of arrays (AI, Dd, ... , (At, Dk ) allows considerable
flexibility in how memory is allocated to different uses during the course of a simulation's
execution.
Our exposition here is intended merely to make the reader aware of the fact that dy-
namic space management that incorporates block-array data structures generally executes
more efficiently with respect to computing time and less efficiently with respect to space
usage. Since computing time considerations usually dominate, one may well prefer a simu-
lation programming language or package that employs these concepts. Since vendors rarely
mention this topic in their promotional literature, it falls to the potential user of a language
or package to elicit this information.
The greatest perceived benefit of Algorithm SPACE-FINDER** arises from the obser-
vation that it reserves blocks of space and requires little time when releasing space, and that
the frequency with which it encounters the relatively high cost of resizing is inversely related
to the block size n.
There remains the issue of unused space blocks. Suppose that k blocks of size n x r have
been allocated. If the demand for space falls below k blocks during a simulation, virtually no
language attempts to unallocate the unused space, since this would incur the relatively costly
effort of relocating records spread throughout the k blocks into the retained k - 1 blocks.
5 .4 . FU T U RE - EVENT SET 197
Accordingly, there is a tendency for allocated space to increase as simulated time evolves.
However, the elapsed simulated time between successive space increases tends to decrease,
thus slowing the rate of increase.
ALGORITHM SPACE_FINDER**
Yes No
2y. i *- D(1). 2n. Augment A by B(n) rows.
3y. If#VACANT > 1, 3n. Augment D by B(n) rows.
D(1) *- D(#VACANT). 4n. #VACANT *- B(n).
4y. #VACANT *- #VACANT - 1. Sn. DU) *- n + i, i = 1, ... , B(n).
Sy. Assign record to AU, 1), ... , A(i, r). 6n. n *- n + B(n).
6y Insert new record in ALIST. 7n. Assign record to AU, 1), ... , AU, r).
7y. Continue simulation. Sn. Execute Algorithm SPACE_FINDER.
• Generate reports.
Of these, managing the future-event set accounts for the largest proportion of comput-
ing time. Although every simulation programming language provides special-purpose data
structures to accommodate the FES and operations on it, individual differences do exist
198 CHAPTER 5. SEARCH, SPACE, AND TIME
c. After a deletion, find the next-event notice among those remaining on the FES.
d. Find an event notice whose attributes assume particular values and delete it from the
FES.
The next-event notice denotes the one whose clock attribute value is smallest among all
event notices in the FES. Action a corresponds to scheduling an event, b to choosing the next
event to execute, c to identifying which event notice is to be executed next, and d to canceling
the scheduled execution of an event. Since the cancellation rate customarily is much smaller
than the insertion, deletion, and search rates of actions a, b, and c, respectively, cancellations
contribute little to the overall computing time of a simulation run. Accordingly, we say no
more about them and, unless otherwise stated, hereafter subsume action c into action b.
Ideally, we prefer to employ the simulation programming language that manages the
future-event set most efficiently with regard to space and time. Regrettably, empirical studies
have repeatedly shown that no method demonstrates uniformly superior performance with
regard to average computing time when tested on different types of simulation models
(McCormack and Sargent 1981, Chung et al. 1993). Two factors principally determine the
computing time required to perform actions a and b: the number of event notices in the
FES and the distribution of simulated time between scheduling and executing an event. In
particular, they influence the sample sequence of insertions and deletions observed during
the simulation, the computing time devoted to action a, and, possibly, the computing time
devoted to action b.
Let a and b denote executions ofactions a and b, respectively. For a particular simulation
with n events in the FES, recall from Section 5.1.1 that g. (n) and gb (n) denote the respective
average times that these actions consume. At a particular moment in simulated time, suppose
that the FES contains k event notices and experiences a sample sequence of 20 insertions
and 20 deletions in the order
abababababababababababababababababababab. (5.8)
Then the average computing time consumed is 20 [g. (k) + gb(k + 1) J. Alternatively, suppose
the 20 insertions and 20 deletions occur in the order
aaaaabbbbbaaaaabbbbbaaaaabbbbbaaaaabbbbb. (5.9)
5.4. FUTURE-EvENT SET 199
revealing a potential difference in average computing time, depending on the form that
the insertion/deletion sequence takes. In addition, two different types of simulation faced
with the same insertion/deletion sequence have different average times ga (k) and gb(k) as a
consequence of different distributions of elapsed time between scheduling and executing an
event.
The absence of a universally dominant procedure with regard to average performance
forces us to focus principally on a worst-case computing time measure of peformance that
depends on the number of event notices in the FES but is usually independent of distribu-
tional properties. This measure reveals how computing time grows in the worst case as the
size of the simulation grows. Its limitation is that it rarely informs us as to how a procedure
performs relative to others for small and moderate size simulations. Nevertheless, the worst-
case measure can be invaluable in explaining why a particular simulation software package
peforms well for a relatively small demonstration problem but consumes dramatically more
computing time when employed to simulate a moderate or large system.
As shown in expression (2.5), the record of an event notice has multiple fields for
storing identification, time of execution (clock) other attributes, predecessor address, and
successor address. Since the discussion of the next several sections focuses on the ordering
of execution times, all depicted future-event sets show only the values of the clock attributes
for event notices, and arrows point to their predecessors and successors.
Suppose that the FES is maintained as a doubly linked list as in Figure 5.4 with deletion
from the low end, and insertion from the high end, where the number in each circle denotes
the scheduled execution time for the corresponding event and where the simulation succes-
sively schedules four events with desired execution times 51, 42, 34, and 28 before it deletes
the event notices with the most iminent execution time. Note that insertions made in this
order take 4 + 7 + 12 + 15 = 38 comparisons. More generally, inserting a new event notice
in a doubly linked linear FES that already contains N event notices takes O(N) worst-case
computing time, but deletion times are constant, independent of N.
Recall from Section 5.3 that ga (N) denotes mean computing time expended per inser-
tion, whereas gb (N) denotes mean computing time per deletion. Clearly, their values depend
on the data structure adopted for the FES and how the scheduling procedure operates on it.
In the present setting ga(N) is a constant, independent of the number of entries N in the
FES. However, empirical studies have repeatedly shown that gb(N) varies with the form of
the interevent-time distribution and cannot be easily characterized as a function of FES size,
(e.g., McCormack and Sargent 1981 and Chung et al' 1993). Because of these limitations on
200 CHAPTER 5. SEARCH, SPACE, AND TIME
First insert
4 comparisons
4 Second insert
7 comparisons
34 Third insert
12 comparisons
Fourth insert
28 15 comparisons
Delete @ : no comparisons
Figure 5.4 Inserting and deleting event notices in a doubly linked linear futute-event
set (entries are clock attribute values)
average behavior our assessment of alternative methods of managing the FES concentrates
on worst -case analyses. In particular, we focus on how computing time is affected as the size
of a simulation grows.
Consider the open-loop queueing system in Figure 5.1 with r ~ 1 types of arrivals,
where interarrival times are random and where each arriving job has k tasks of which
task i must be performed by one of the mj servers of type i for i = 1, ... , k. Assume
that the relationship between arrival and service rates is such that the simulation finds all
servers busy almost all of the time. This high traffic intensity environment characterizes
many manufacturing and telecommunications systems. Moreover, it implies that service
completion at one station (deletion from the FMS) immediately induces the scheduling of
service for this server and a task waiting in its buffer (insertion in the FMS).
During its tenure in the system, each job induces the scheduling of 1 + k events, one
for the next arrival and k for completions at each of the k banks of servers. Suppose that the
FES is a single linear doubly linked list of event notices ordered by desired execution times.
Then, as previously stated, gb(N) is relatively constant, regardless of the number of event
notices N in the FES. Since virtually all servers are busy at any moment in simulated time,
the FES contains approximately 1 + ml + ... + mk event notices. It also contains r event
notices, one for each distinct arrival type. Therefore, the scheduling of an additional event
notice takes at most m 1 + ... + mk + r comparisons. Since this occurs k times per job during
the simulation, worst-case computing time per completion is proportional to k 2 iii + kr,
where expression (5.2) defines iii.
For fixed k and r, this reveals that worst-case computing time grows linearly in iii,
the mean number of servers per station; but, for fixed iii and r, worst-case computing time
5.4. FUTURE-EvENT SET 201
grows as k 2 , where k denotes the number of stations in series. For this type of list, series
queueing problems clearly demand more computing time than parallel queueing problems
do, as k grows relative to iii 1/2.
EFFICIENCY
As the remainder of this chapter shows, other methods of managing the FES can be
expected to consume considerably less computing time than a single linear linked list as the
number of simultaneously scheduled events in the FES grows. However, we cannot totally
dismiss the value of this data structure. When there are few simultaneously scheduled events,
it is known that this form of event management is computationally more efficient on average
than all others that have been considered. For example, results in Jones (1986) indicate that
a linear linked list is best for fewer than 10 simultaneously scheduled events.
One approach to reducing list-processing time relies on multiple linear lists in the FES,
one for each type or class of event. When scheduling an event of type i, one peforms:
SCHEDULING
When an event terminates execution, control passes to the timing routine, which
performs:
1. Search the list of header addresses to identify which event type has the smallest value
for its clock attribute.
r
@ First inse~t:
~ 1 companson
28 Fourth insert:
8 comparisons
Delete @: 2 comparisons
Figure 5.5 Inserting and deleting event notices in a doubly linked multiple linear
FES (entries are clock attribute values)
Levell
Level 2
Level 3
Level 4
Level 5
5.4.3 HEAPS
The concept of a binary heap provides another data structure for managing the FES
(Williams 1964, Evans 1988). Consider a directed tree all of whose edges point toward its root
node 1. Figure 5.6 illustrates the concept, where for present purposes we again regard the
numbers at each node as the execution times for events. The children of node v at level i are
the nodes at level i + 1 connected to v by an edge, and v is the parent of each of its children.
A node with no children is called a leaf The depth of node v is the number of edges in the
path connecting v to the root 1. A heap is a rooted tree each of whose nodes v has a value
key( v) that is the smallest among the keys of all nodes in its subtree. A heap in which each
node has at most two children is called a binary heap.
The data structure associated with a binary heap is an array in which nodes are stored
in order from top to bottom; its root occupies position 1, its children occupy positions 2
and 3, and, more generally, the nodes at depth i occupy positions 2i , i + 1, ... , i+ 1 - 1.
If the binary heap is maintained so that its N elements always occupy the first fleft-justified
positions as in Figure 5.6, then every element of the tree h~s depth no greater than Llog2 N J.
The bidirectional edges in Figure 5.6 emphasize that the list maintains predecessor
and successor addresses at each node and is thus doubly linked. In conformity with our
definition of a binary heap and for visual clarity, Figure 5.7 displays unidirected edges.
In terms of the FES, a node represents an event notice and key( v) denotes the value
of the clock attribute of event notice v. To insert or delete an event notice, one relies on
procedures akin to Algorithms SIFTUP(x) and SIFTDOWN(x). The first takes an element
x of the tree whose key(x) has been decreased and moves it up the tree to its appropriate
place. The second takes an element x whose key has been increased and moves it down the
tree to its appropriate place.
204 CHAPTER 5. SEARCH, SPACE, AND TIME
Algorithm SIFTUP(x)
Until SUCCESS:
Repeat
If x is the root, SUCCESS
Otherwise:
Let y be the parent of x
Ifkey(y) :::: key(x), SUCCESS
Otherwise:
Swap entries in x and y.
Algorithm SIFTDOWN(x)
Until SUCCESS:
If x is a leaf, SUCCESS
Otherwise:
Let y be the child of x with minimal key
Ifkey(y) :::: key(x), SUCCESS
Otherwise:
Swap entries in x and y.
• Performs SIFTDOWN(y).
5.4. FUTURE-EvENT SET 205
Figure 5.7 shows a binary heap FES for the same event notices displayed in the single
linear list of Figure 5.4 and in the multiple linear list in Figure 5.5. The successive insertion
of event notices with times 51, 42, 34, and 28 takes 1 + 2 + 3 + 3 = 9 comparisons and
o+ 1 + 2 + 2 = 5 switches, in contrast to 38 comparisons and one link in the single linear
list case and 16 and one link in the multiple linear list case. The single link comparisons
operation in each of the linear list cases corresponds to the final step in the search, where
the new event notice is chained to the list. Link and switch operations are comparable in
computing time.
The subsequent deletion of the first event notice from the FES in Figure 5.7e takes
one leaf-to-root transfer, three switches, and three comparisons. A leaf-to-root transfer is
comparable in computing time to a switch. Although more work than for deletions in either
Figure 5.4 or 5.5, the combined work for insertion and deletions for the binary heap favors
this approach to list management over the single and multiple linear list approaches.
Since the particular clock times in Figures 5.7a through 5.7e dictate the numbers of
comparisons per insertion and deletion, it is of interest to consider more global results. For
four successive entries into a heap with 19,20,21, and 22 nodes, the worst-case numbers of
comparisons are Llog2 19J = 4, Llog 2 20J = 4, Llog 2 21J = 4, and Llog 2 22J = 4, respec-
tively. For deletion following these four insertions, the worst-case number of comparisons
is Llog 2 23 J = 4.
More generally, with D maintained as a binary heap with N entries, insertion and
deletion each take O(log2 N) computing time, an unequivocal advantage over single and
multiple linear lists as I ---,)- 00. Also, canceling a particular event notice in a heap follows
the same steps as a deletion and therefore has O(log2 N) time. However, there is at least
one limitation of this formulation that needs to be overcome. As just described, the binary
heap makes no provision for priority order when two or more events have the same desired
execution time. This can be overcome as follows. Let OLD denote the old event notice in the
heap and let NEW denote the new event notice. If OLD and NEW have the same execution
times but NEW has a priority order that favors it over OLD, swap the locations of OLD and
NEW in the heap. Otherwise, do not swap them.
SPACE
Suppose that a simulation attempts to schedule an event when its FES already holds
N event notices. Then the simulation programming language must provide for upwardly
resizing the arrays and reconstituting the heap in the augmented array. While choosing
N large reduces the frequency of resizing, it may also lead to considerably unused, but
committed, space over long periods of simulated time. An alternative approach provides
memory space incrementally, as needed.
A binary heap with N entries has Llog 2 NJ levels, where level i accommodates i-I
event notices for i = 1, ... , N - 1. Figure 5.6 illustrates the concept for N = 19, where
Llog 2 19J = 5 and levels 1 through 4 have I, 2, 4, 8 entries, respectively, and level 5 has
four entries and space to accommodate 12 additional entries. When the FES has exactly i-I
206 CHAPTER 5. SEARCH, SPACE, AND TIME
a. First insert @: I comparison and no switches b. Second insert @: 2 comparisons and I switch
~~
11/ 34 ,-\
'~9. I~~
c. Third insert
6
entries in its i levels, and an event is to be scheduled, the dynamic space allocator finds a
block array oflength i+ 1 for level i + 1 and connects it pointerwise to level i, much as in
the example in Figure 5.6. The address of the leftmost entry at level i + 1 now becomes
the trailer for the list. Since the space at this level is a block array, the location of the next
unoccupied record at level i + 1 is implicitly determined.
5.4. FUTURE-EvENT SET 207
In summary, each time it runs out of space this FES doubles its size. Moreover, it takes
O(i) computing time to link the new space at level i + 1 to the old space.
For the prototypical simulation described in Figure 5.2 with r 2: 1 arrival types, each
+
job passing through the system takes O(2k log2 (km r» list processing time to maintain an
FES structured as a binary heap, where the constant 2 merely emphasizes that deletion as well
as insertion has a worst -case bound proportional to k log2 (km + r). As the number of visited
stations increases, this computing time grows as k log2 k. Conversely, as the average number
of servers increases, the bound grows as log2 m. As k, m, and r increase, these properties
make clear the benefit that a binary heap offers for FES management when compared to the
O(k 2m + kr) worst-case timefor the single linearlist of Section 5.4.1 and the O(km + r) +
O(k(k + 1) worst-case time of the multiple linear list approach in Section 5.4.2.
It is known that as N, the number of scheduled events in an FES maintained as a
heap, increases, the average computing time required to maintain the heap is O(lOg2N)
(e.g., Jones 1986). However, it is also known that for small N a heap is considerably less
efficient than a linearly linked list for FES management. Presumably, the large setup time
encountered each time a heap is modified accounts for its relatively poor performance for
smallN.
Finding and deleting the event notice corresponding to the next event for execution
takes constant computing time regardless of the number of entries in the FES. To insert a
new event notice with desired execution time T in the FES (scheduling), one:
• Scans the FES backwards starting from DU) and inserts the new event notice in its
appropriate location.
During a scan, the procedure keeps a COUNT of the number of unsuccessful com-
parisons it has performed. If the COUNT reaches a predetermined number [ and j > 1,
the procedure alters DU - 1) to point to the last scanned event notice, resets the COUNT
to zero, and continues scanning the FES until success or until the COUNT again reaches [.
Alternatively, if j = 1 and COUNT reaches [, the procedure increases the size of the D array
to M' = 2K + 1 - 1 = 2M + 1, reinitializes its entries, and continues scanning the FES until
success.
The expanded tree is initialized by setting its leftmost leaf (Le., D(M')) to point to the
pseudo-event notice at the rightmost end of the FES and D(l), ... ,D(M' - 1), the pointers
at all other nodes of the tree, to point to the pseudo-event notice at the leftmost end of the
FES. By assigning the "unused" pointers D(l), ... , D(M' -1) to the header entry in the FES
at the moment of resizing, the procedure can later reassign them, one at a time, whenever
COUNT = [ and j > 1. Algorithm H-L describes the major steps for insertion.
ALGORITHM H-L
Purpose: To insert an event notice into the FES using Henriken's Algorithm.
Given: j, K, M, and{D(l), ... , D(M)}.
Method:
Start scan at DU).
COUNT+- O.
Repeat:
COUNT +-COUNT+1
scan the next event notice
ifCOUNT=I:
if j > 1, reset DU - 1) to point to the last scanned event notice
otherwise:
increase size ofD from M = 2K - 1 to M' = 2K+I - 1
set D(M') to point to the trailer event in the FES and D(l), ... ,
D(M' - 1) to point to the header event in the FES
j -+ M'
5.4. FUTURE-EvENT SET 209
COUNT~ 0
Until success.
Whereas a binary heap has the property that the key for each node is no greater than
the key for any node below it in the tree, a binary search tree has the property that the key
for each node is no greater than that for any element in the original node's left subtree but
is no smaller than that for any element in the original nodes right subtree.
As I decreases the number of scans until success diminishes, as does the frequency of
resizing D. However, decreasing I increases the likelihood of increasing M, the size of D, and
thereby increasing the cost of reinitializing D. Henriksen (1977) suggests I = 4. Kingston
(1986a,b) describes procedures that reduce the cost of initalization and, in finding the next
event in the FES, for reducing the size of D.
Figure 5.8 displays the steps for insertion and deletion from an FES based on Hen-
riksen's Algorithm using the four successive insertions with clock attribute times 51, 42, 34,
and 28 followed by a deletion, as in Figures 5.4, 5.5, and 5.7. Each insertion induces at most
Llog 2 7J = 2 comparisons to find the pointer to the location at which to start the list search.
In addition to the comparisons, insertion requires two pointer changes in Figures 5.8a and
5.8c. Note that no comparison is made with the trailer clock entry of 00.
In an FES with N elements, Henriksen's Algorithm takes 0(1) computing time to find
the next event to execute and O(log(N / I)) + 0(NI/2) +0(1) worst-case time to insert anew
event notice (Kingston 1986a, 1986b). However, substantial empirical evidence indicates
that insertion takes mean computing time proportional to log2N for given I and that this
result is insensitive to distributional properties for a wide variety of simulations (Henriksen
1994 and McCormack and Sargent 1981).
In the context of simulating a queueing system as in Table 5.1 with r arrival types, these
results suggest O( (k + 1)(klii + r )1/2) worst-case computing time and an average computing
time proportional to average (k + 1)log2 (klii + r) for fixed t. As the average number of servers
per station, Iii, increases for fixed k, this computing time grows as Iii 1/2 at worst and as log21ii
on average. As the number of stations k increases for fixed Iii, the computing time grows
as k 3 / 2 at worst and as klog 2 k on average. When compared to the single or multiple linear
list approaches with standard scanning, the benefits of Henriksen's Algorithm are apparent.
Algorithm H -L is prototypical of the approaches to event management in SLX, GPSS/H,
AweSim, and SLAM.
Table 5.1 summarizes the bounds on computing time for managing the FES by the four
data structures just described. However, at least one additional issue remains to be discussed,
namely, an FES with few event notices. As Section 5.4.1 intimates, a linearly linked list is most
efficient on average for these. Hence, a language that employs a binary heap or Henriksen's
Algorithm may consume more time than necessary to manage an FES with few entries on
average. However, we anticipate that any excess computing time will be small in absolute
210 C HAP TE R 5. SEA RCH, SPA eE, AND TIM E
At most 2 comparisons to
find pointer, 1 comparison
to insert
At most 2 comparisons
to find pointer, 1
comparison to insert
At most 2 comparisons
to find pointer, 4
comparisons to insert,
1 pointer shift
8
(e) First deletion
o comparisons to
delete 0
Figure 5.8 Inserting and deleting event notices in an indexed future-event set: Hen-
riksen's Algorithm (entries in list are clock attribute values; entries in index array are
ordered pointers; dashed arrows denote pointers before shift during search)
terms. Moreover, we can regard this excess as a relatively small penalty when compared to the
efficiencies that heap-like structures and Henriksen's Algorithm offer for large future-event
sets. The circumstances that are yet to be investigated fully are those in which an FES has
few events notices most of the time and occasionally, but rarely, grows substantially in size.
Do these rare but substantial excursions favor simple or sophisticated structures?
Since studies of more sophisticated heap structures for FES management fail to reveal
unequivocal superiority for anyone ofthem (e.g., Jones 1986 and Chung et al. 1993), it is
not possible to choose a simulation programming language based on its universally accepted
computing time superiority. Nevertheless, it is clear that for a given problem, GPSS/H and
SLAM, based on Henriksen's Algorithm, and SIMAN, based on the binary heap concept,
execute faster than SIMSCRIPT 11.5, which relies on multiple doubly linked linear lists.
5 .5 . BROADENING THE CLASS OF DELAY MODELS 211
Table 5.1 Managing the future-event set for a saturated system (k := number of stations in
series, rn := average number of servers per station, r := number of distinct arrival types)
CAPACITATED TRAVEL
_ I k-l
1:=- Llj.
. k - 1 j=l
Since there are at most (k - I)J event notices associated with the arrival of a job at a
station or the arrival of the conveyance back at its home station, the FES contains at most
r + kfit + (k - I)J event notices.
If each pallet has unit capacity, then each job is responsible for k - I interactions with
the FES for pallet arrivals and for an additional k - I for their return to their originating
stations. Therefore, the total number ofFES interactions is k + I + 2(k - I) = 3k - I, so
that, for example, heap insertion and deletion times per job each are O«3k - I) 10g2(r +
kfit + (k - I)J)).
212 C H A PTE R 5. SEA RCH, S PAC E I AN D TIM E
If pallet capacity at each station is e > 1 and a pallet moves from station i to station
i + 1 only when full, then we conceive of each job as inducing (k - I) Ie interactions for
pallet arrivals and (k - I)le for returns, so that, for example, heap insertion and deletion
times per job each are 0(((1 + 2le)k - 21e) log2(r + kin + (k - 1)/)).
UNCAPACITATED TRAVEL
If transit requires no pallet, cart, etc., the number of jobs in transit from station to
station is unbounded, and therefore our analysis uses a different approach.
Assume that upon completing service at station j, a job travels to station j + 1 with
nonnegative transit time for j = 1, ... , k - 1. Two scenarios are possible, capacitated travel
and uncapacitated travel. Let L j (t") denote the number of jobs in transit at time t" from
station j to station j + 1. Then the arrival of a job at its destination constitutes an event and,
hence, must be scheduled. Accordingly, at simulated time t" the FES contains r + B (t" ) + L ( t" )
event notices, where, as before, r denotes the number of scheduled arrival event notices and
Scheduling an event now takes ga(r + B(t") + L(t")) average computing time, whereas selec-
tion takes gb (r + B (t") + L (t" )) average computing time, where, as before, each simulation
language's procedure for scheduling and selection determines the forms of ga(·) and gb(·).
Unlike the model of Section 5.1, this broader model puts no upper bound on the
number of event notices in the FES. Let l/Wtj denote mean transit time for a job from
station j to j + 1 for j = 1, ... , k - 1 and let
Wa
Vj:=-.
Wtj
For an arbitrarily selected time t", the mean number of jobs in transit in an uncapacitated
buffer system (ej = 00, j = 1, ... , r) is
where
1 k-l
- ~ I
v:= k-l ~ Vj.
J=l
Note that long transit times relative to interarrival times at state 1 imply a large mean number
of jobs in transit.
5 .5 . BROAD E N I N G THE C LAS 5 0 F D E LAY MOD E L 5 213
Since jobs in transit from one station to the next are in an infinite-server system, we
can think of this extended model as a sequence of2k - 1 stations where the odd-numbered
stations each have finite numbers ofservers and the even-numbered ones each have an infinite
number of servers. At an arbitrarily chosen simulated time r, the FES for the extended model
has mean number of event notices
Moreover, each job passing through the system has 2k scheduling interactions and 2k
selection interactions with the FES.
For the single linear list approach to FES management in Section 5.4.1,
whereas
average selection time per job = O(2k).
Since no competitive simulation language uses this data structure, these results are included
merely for purposes of comparison with the more commonly employed data structures.
For the multiple linear list FES of Section 5.4.2, we treat all transit arrivals at station
j as forming a separate class of events for j = 2, ... ,k. Therefore, the extended model has
2k event classes, one for arrivals, k for service completions, and k - 1 for station-to-station
transit completions. Then
whereas
since the first entries in all2k event lists must be compared for each job's 2k selections.
For an FES based on the binary heap concept of Section 5.4.3 and given the number
of busy servers B (r) and the number of jobs in transit L ( r ), a single scheduling takes
o (logz (r + B( r) + L( r)) average computing time, as does a single selection. The inequality
x ~ 0,
enables us to write
L(r) 1
log2(r + B(r) + L(r)) :::: logz(r + km) + - - - . -1- . (5.12)
r + km oge2
214 C H A PTE R 5. 5 EAR CH, 5 PAC E I AND TIM E
Therefore,
=0 ( 2klo (r+km)+
2kii
.---
2ii 1
.-- ,
1)
gz r / k + m loge 2 r / k + m loge 2
and
= 0 ( 2k 10 (r + km) + 2kii
.-- - 1 2ii 1)
.-- .
gz r/ k + m loge 2 r/ k + m loge 2
For fixed r, m, and ii, these bounds grow as k logz k. As ii increases relative to r / k + m for
fixed r, k, and m, the bounds become increasingly larger than need be. Nevertheless, with
regard to average scheduling and selection times per job, the binary heap approach maintains
its edge over single and multiple linear list approaches.
Recall that empirical studies (Henriksen 1994) show that scheduling an event using
Henriksen's Algorithm (Section 5.4.4) when N event notices are in the FES takes average
computing time proportional to logz N. Also, selecting an event takes 0(1) time. Based on
these properties, applying Henriksen's Algorithm for managing the FES for our (2k - I)
station model has
=0 ( 2klo (km+r)+
2kii
.---
ii 1
.-- ,
1)
gz r / k + m loge 2 r / k + m loge 2
whereas
These results continue to imply an advantage for binary heaps and Henriksen's Algorithm
for scheduling and selection times.
An alternative extension ofthe model in Section 5.1 assumes that the number ofstations
that a job visits varies during its passage through the system. At least three modalities exist
for this behavior:
1. Jobs make one pass through the system but skip some stations.
5 .5 . BROAD E N I N G THE C LAS 5 0 F D E LAY MOD E L 5 215
Since Modality 1 induces k or fewer interactions per job with the FES, the results of Sections
5.4.1 through 5.4.4 continue to apply.
For Modality 2, let
k 00
LL1Wij/ = O(k)
j=l 1=0
as the number of stations grows, then the earlier results again continue to apply. In particular,
the assumption holds if Wijl = 0 for I greater than a specified integer.
Modality 3 requires more thought. Assume that quality-assurance testing follows each
station's service. Thus the extended model has 2k stations where mj is the total number of
testers after station j, each with mean testing time 1jw;j' such that wajmjw;j < 1. As a
consequence, the FES has at most k(iii + iii') + r event notices, where
_,
m := k1 (m ,1 + ... + mk') .
For convenience of exposition, assume that every job that completes service at station
j has probability p of failing the subsequent quality-assurance test, independent of type
and the number of times it has previously failed the test. Then the mean numbers of passes
through station j and through its ensuing test are each 1j (1 - p). Therefore, the mean
number of interactions per job with the FES is 1 + 2kj(l - p).
For the multiple list approach to FES management in Section 5.4.2,
whereas
Average selection time per job for binary heaps has the same time complexity, but Henriksen's
Algorithm has O(2k + 1) average selection per job.
• Space management and list processing consume a relatively large proportion of the
time expended in executing a discrete-event simulation program.
• Every simulation language provides a timing routine for maintaining its future-event
set (FES), the list of records of scheduled events to be executed in the future.
• In a highly congested system, space needs for the FES increase linearly with the number
of stations in series and linearly with the average number of series per station.
• GPSS/H and SLAM use Henriksen's Algorithim (Section 5.4.4) to maintain their FESs.
SIMAN uses an algorithim based on a heap concept (Section 5.4.3). SIMSCRIPT U.S
uses multiple linear lists (Section 5.4.2).
• When jobs of different types have i.i.d. interarrival times, an opportunity may exist
for reducing the space the FES requires. This is especially true if the inter arrival times
have the exponential distribution.
• A job passing through all k stations in series in a simulation has interactions with the
FES that take O(k log k) time for a heap-like structure and for Henriksen's Algorithm.
5.7 EXERCISES
rfi? 5.1 If one generates a character interarrival time separately for each of the r input
buffers, the FES necessarily contains at least r event notices.
a. Using the exponential property, devise an alternative interarrival scheme that requires
a single event notice in the FES to discount for these events. Justify your proposal.
b. For the two methods, what is the difference in the numbers of event notices?
rfi? 5.2 If w denotes the mean number of characters per packet, then direct sampling from
EO/A) to generate interarrival times implies that an average of w event notices are filed and
5.8. REFERENCES 217
removed from the FES to fill the packet and move it from its input buffer to the output buffer.
The same average holds for the method ofExcercise 5.1. Devise a sampling procedure that
reduces the number of insertions and deletions from the FES to one each per packet while
preserving the i.i.d. exponential property of the interarrival times and that allows sampling
in time independent of w, as w becomes large. Hint: See Sections 8.13 and 8.19.
5.8 REFERENCES
Arguelles, M.e., and G .S. Fishman (1997). Reducing the frequency of future event set search
in manufacturing simulation, Operations Research Department, University of North
Carolina at Chapel Hill, in preparation.
Chung, K., J. Sang, and V. Rego (1993). A performance comparison of event calendar
algorithms: an empirical approach, Software-Practice and Experience, 23, 1107-1138.
Evans, J.B. (1988). Structure ofDiscrete Event Simulation, Ellis Horwood Limited, Chichester,
England.
Henriksen, J.O. (1977). An improved events list algorithm, Proceedings of the 1977 Winter
Simulation Conference, H.J. Highland, R.G. Sargent, and J.w. Schmidt, editors, 547-
557.
Henriksen, J.O. (1983). Event list management, a tutorial, Proc. Winter Simulation Conference,
IEEE and SCS, Piscataway, N.J., 543-551.
Henriksen, J.O. (1994). Personal communication.
Jones, D.W. (1986). An empirical comparison of priority-queue and event-set implementa-
tions, Comm. ACM, 29, 300-310.
Kingston, J.H. (1986a). Analysis of Henriksen's algorithm for the simulation event set, SIAM
~ Comput, 15,887-902.
Kingston, J.H. (1986b). The amortized complexity of Henriksen's algorithm, Bit, 26,156-
163.
Knuth, D. (1973). The Art ofComputer Programming: Sorting and Searching, Addison-Wesley,
Reading, MA.
Kollerstrom, J. (1974). Heavy traffic theory for queues with several servers. I, J. Appl. Prob.,
11, 544-552.
McCormack, W.M. and R.G. Sargent (1981). Analysis of future event set algorithms for
discrete event simulation, Comm. ACM, 24, 801-812.
Williams, J.w.J. (1964)."Algorithm 232:' Comm. ACM, 7, 347-348.
CHAPTER
Every discrete-event simulation experiment with random input generates random sample
paths as output. Each path usually consists of a sequence of dependent observations that
serve as the raw material for estimating the true values of one or more long-run performance
measures, hereafter called parameters. Two phenomena, sampling error and systematic error,
influence how well an estimate approximates the true value of a parameter. Random input
induces sampling error, and the dependence among observations often enhances its severity.
Systematic error arises from the dependence of the observations on the initially chosen state
or conditions in the simulation. The presence of random and systematic errors implies that
all estimates need to be interpreted with qualification.
This chapter addresses both types of error. It describes how to assess systematic error
in point estimates and how to reduce its influence. It also shows how to gauge the extent
of sampling error in the point estimates, principally, by constructing asymptotically valid
confidence intervals for the corresponding true values of the parameters. A confidence interval
is an interva~ rather than a point, estimate of a performance measure. An asymptotically valid
100 x (1 - 8) percent confidence interval is one that includes the true parameter value with
probability 1 - 8 for 0 < 8 < 1 as the sample-path length t -+ 00.
220 CHAPTER 6. OUTPUT ANALYSIS
While the width of a confidence interval indicates how well the corresponding point
estimate approximates the true value, this interpretation has a justifiable statistical basis only
ifsystematic error is negligible and the confidence interval is computed in a manner consistent
with achieving the property of asymptotic validity. Accomplishing these objectives calls for
considerably more effort than merely assessing error when the data consist of independent
and identically distributed (i.i.d.) observations. As a consequence, simulation results are
often reported with little if any supporting analysis, thus undermining conclusions based on
the values of point estimates. This need not be so.
To make it easier for a simulationist to assess systematic and sampling error, this
chapter focuses on easily implementable procedures, but grounded in statistical theory. This
is especially so for confidence intervals, for which we describe readily accessible software,
LABATCH.2, that performs the computation with minimal user effort. We also describe the
automatic procedure used within Arena.
Three factors influence the extent to which initial conditions affect how well an average
based on sample-path data of finite length approximates its corresponding long-term system
average. They are s, the state assigned to the system at the beginning of a simulation; k, the
point on the sample path at which data collection for estimation begins; and t, the length of
the sample path, used to compute the finite sample average.
In principle, selecting an s that induces convergence of the sample path to steady-state
behavior for as small a k as possible is desirable. Since little is known a priori about the
underlying stochastic structure of the sample path, this is rarely possible. Customarily, s is
chosen for computational convenience. For example, beginning a simulation with an arrival
to an empty and idle system relieves the simulation user of the need to compute initial queue
levels, times to the completion of service, and scheduled execution times, as described in §4.
Suppose a simulation generates a sample path Xl. ... , Xt' of length t'. Since the
influence ofinitial conditions on X j tends to decrease in importance as j increases, discarding
data XI, ... , Xk-I for some k :::: t' at the beginning ofthe path and using the remaining
t := t' - k + 1 observations Xt, ... , XI' for estimation usually reduces systematic error. In
principle, the more one discards of the sample path, beginning at its origin, the smaller is
the systematic error in estimates based on the remaining data. This observation encourages
substantial truncation; but doing so can be unnecessarily costly unless tempered by the need
to reduce sampling error as well. In particular, since the width of a confidence interval tends
to decrease as t- I / 2 , one is encouraged to use a substantial portion of the sample path to
reduce sampling error.
This last action runs counter to the tendency for excessive truncation. For a fixed total
path length, this discussion makes clear the need to choose a warm-up interval k - 1 in a
6 ,1 , WAR M - U PiN TE RV A L 221
way that makes systematic error negligible while providing a valid basis for computing a,
hopefully, narrow confidence interval.
In a discrete-event simulation, the sequence {XI, ' , . , X t ,} may represent one of many
phenomena. For example, for i = 1, ... , f', Xi maybe equal to:
Alternatively, Xi may denote a function of one or more of these random quantities. For
example, {Xi := I(w,oo)(Wi ); i = 1" .. t'} denotes a 0-1 sequence, where Xi = 0 if
Wi :::: w and Xi = 1 if Wi > W; or
{ Xi = f:
q=1
I(q-l,q](Q((i -1)Ll»I(q-l,q](QCiLl))); i = 1, ... , t'}
is a 0-1 sequence, where Xi = 0 if queue lengths differ at times iLl and Ci + 1) Ll, whereas
Xi = 1 if they do not.
To illustrate the problem of initial conditions, we focus on a sample path of waiting
times generated in the SIMSCRIPT 11.5 airline reservation example in Chapter 4, where Xi
denotes the waiting time of the i th customer to begin service. Figure 6.1 a displays the first
100 waiting times (in black) for a single sample path. Since the simulation began with all
m = 4 reservationists idle and no callers waiting, the first four waiting times are necessarily
zero. To include these data in the estimating procedure would induce a downward systematic
error or bias in the sample waiting time time average as an approximation to the long-run
waiting time time average. Figure 6.1a also displays (in bold black) the sequence of truncated
time averages
- t'-J'+I :=
XJ'I 1 L Xi,
t'
1 :::: j :::: f', (6.1)
, f' - " + 1 '=J
, ,
where XjV - HI omits the firstj - 1 waiting times. This graph shows a tendency for
Xj I ,t'-H I initially to increase as j
increases, reflecting the reduction in systematic error that
truncation induces. However, as j continues to increase, XjV - HI fails to stabilize in the
222 CHAPTER 6. OUTPUT ANALYSIS
4 ·
4 -
3 -
W.l1Ing .
Hmo .
2 ·
1 •
20 40 60 60 100
C. n=1000, t'=100
4 ·
3-
Waiting
Hmo
2·
1·
0 20 100
40 60 80
tth Customer to begin ..me.
Figure 6.1 Waiting times for airline simulation (black Xjni> bold black
Xjn,t'-H]')
6.1. WAR M - U PiN TE RV A L 223
neighborhood of any particular value. This behavior for large j is a consequence of the fact
that random error in the time average Xj1 ,t'-j+l has variance proportional to l/(t' - j + 1)
and, therefore, exhibits increasing variation as j approaches t'.
As Figure 6.1a shows, the presence of sampling error limits one's ability to detect
systematic error from a single sample path. To reduce this sampling error, we can resort to
multiple independent replications. Suppose that we generate a second run of the simulation
with the same initial conditions but employ a pseudorandom number sequence disjoint
from that used on the first sample path. This strategy allows us to regard the sample paths
as statistically independent. Using the last pseudorandom numbers listed in Figure 4.3 as
the seeds for the new sample path accomplishes this. Let us call each such run a replication
and observe that one can generate n independent replications each oflength t' by employing
the last pseudorandom numbers on replication i as the seeds for replication i + 1 for
i = 1, ... , n - l.
To help us understand the value of multiple replications, let
and
For the moment, we take xji) to be the j th waiting time on the i th of n replications each of
length t', which are the rows in Table 6.1. Suppose that each replication begins in the same
initial state s E S. Then
- 1 ~ (i)
X jn1 := - L-t Xj , 1 :::: j :::: t', (6.2)
n ;=1
- (i)
X.,.
J,t - J+l
= 1
t' _ k + 1
L. X
t'
(i)
I'
1 :::: i :::: n, (6.3)
I=J
-
X· , . '= -1
J,n,t -J+l .
L X.,.
n
-(i)
J,t -J+l
= ,
1
. +1
L X-
f
Inl (6.4)
n ;=1 t - ] I=j
defines the grand truncated average, which omits observations 1, ... , j - 1 on each replica-
tion. As noted in Chapter 3, the distribution of Xjil converges to an equilibrium distribution
224 CHAPTER 6. OUTPUT ANALYSIS
2 t'
as j -+ 00, say, with mean J.L and variance (12 independent of sand j. However for finite
j ~ I:
and
SJ := var(X~l)
(12. J
I S(O) = s) = var(X~2)
J
I S(O) = s) = ... = var(X<.n)
J
I S(O) = s), (6.6)
where J.Lsj (# J.L) and (1~ (# (12) denote the conditional mean and variance, respectively, of
waiting time j, given the initial state S (0) = s. Moreover, each column average in Table 6.1
has conditional mean
2
- (1sj
var(X jn1 I S(O) = s) = - ,
n
the presence of systematic error for all j :::: 20. Figure 6.Ic based on n = 1000 reveals
even more. It shows that systematic error decreases monotonically as j increases from 1 to
100, suggesting that a not inconsequential systematic error may exist for initial path length
t'> 100.
Figure 6.2 presents comparable information for the longer initial path length t ' =
1000. For n = 1, Figure 6.2a offers little benefit over Figure 6.Ia. However, for n = 10,
Figure 6.2b suggests that systematic error becomes relatively unimportant in Xjn1 for j ::::
200. Figure 6.2c confirms this for n = 1000. In practice, a warm-up analysis rarely employs
more than 10 replications. Our use of n = 1000 is merely for illustration.
Figures 6.1 and 6.2 also reveal that the ability to identify a warm-up interval k - 1
such that systematic error is relatively incidental for j :::: k depends crucially on taking a
sufficiently long initial sample path length t'.
How does a simulation user choose suitable nand t ' prior to simulation for a warm-up
analysis? Occasionally, characteristics of the problem indicate the extent of variation across
replications for a given j and the extent of dependence along a sample path. Since this is
rarely so, an iterative solution often is the only alternative. One starts with an initial (n, t ' )
2-tuple and iteratively increases nand t ' until the succession of graphs, as in Figures 6.1
and 6.2, suggests a warm-up interval k - 1 such that for j :::: k, Xjn1 appears relatively
uninfluenced by initial conditions.
We now summarize several important observations regarding k, n, s, and t':
• As the warm -up interval k increases for a fixed t ' , systematic error decreases. However,
random error increases, especially as k approaches t'.
• Averages based on n independent replications {X jnl, 1 :::: j :::: t'} provide a basis for
discerning the extent of systematic error when all replications start in the same state.
• Starting the simulation in a state S E S for which the conditional mean {/lsj, j :::: I}
is monotone in j enhances our ability to distinguish systematic error from sampling
error in analyzing {X jn1 , 1 :::: j :::: t'}. Although there is no guarantee that a state
exists with this property, it is known that the empty and idle state induces the property
for the conditional means of queue length and waiting time in many single-server
queueing problems.
226 CHAPTER 6. OUTPUT ANALYSIS
•. n=l , 1'=1000
30
20'
W.~ l ng 15 .
time
10 ·
5 ·
b. n=10, 1'=1000
10
C. n=looo, 1'=1000
10
8 -
6 ·
Wolting
tim.
4 -
2 -
0
200 400 600 800 1000
Figure 6.2 Waiting times for airline simulation (black Xjnl> bold black
Xjn ,t' -j+l)
6.1. WAR M - U PiN TE RV A L 227
Starting all n replications in the same initial state S E S enables us to draw inferences
about an appropriate warm-up interval k - 1 from a sequence of estimates {Xjnd of the
conditional mean function {JLsj}. This approach can be especially revealing when {JLsj} is
monotone in j, particularly if a priori information enables a simulation user to select a state
S that induces this monotonicity and that favors rapid convergence, relative to that from
2
-
MSE(X jn1 ; S, .•• , S) = -ansj + (JLsj - 2
JL) ,
an uninformed choice of S can, for fixed j, result in a large contribution (JLsj - JL)2 to the
mean-square error that remains regardless of how large n becomes. To limit this possibility,
these practitioners resort to an alternative approach.
Suppose the i th independent replication begins in state Si E S for i = 1, ... , n, where
Sl, ••• ,Sn are distinct and presumably span the state space S. For example, replication i of
the airline reservation simulation might begin with an arrival to a system with qi callers
waiting for or in service, where qi < qi+l for i = 1, ... ,n - 1 and where Xjil denotes the
waiting time of the (qi + j)th caller on replication i for j ~ 1. Then Xjn1 has expectation
nl "L..d=l
,n . l",n 2 d
JLsij, vanance 1i2 L...i=l a sij ' an mean-square error
Although the contribution ~ L:7=1 (JLsij - JL)2 is again independent of n for fixed j,
it is the average of n squared deviations, presumably some small and some large, which
hopefully make a smaller contribution than (JLsj - JL)2 when this latter quantity is large.
While this rationale has an inituitive appeal, this alternative has an advantage for
detecting systematic error only if MSE(X jn1 ; Sl, ..• , sn) < MSE(X jn1 ; s, ... , s) and the
graphical depiction to which it leads gives a more definitive picture of conditional mean
behavior as a function of j. In practice, the latter property is less likely to materialize. If S
induces a monotone {JLsj} but at least one of the Si'S does not, then the analyst faces the
additional problem of distinguishing between changes in direction in {Xjnd attributable to
nonmonotonicity and changes due to sampling fluctuations.
There are systems for which a single initial state for all replications may limit the
analyst's capacity to perform a comprehensive warm-up analysis: Suppose that the state
228 CHAPTER 6. OUTPUT ANALYSIS
space S is the union of two disjoint subsets SI and S2 such that a simulation that begins in a
state s in Si tends to remain in Si for an extraordinarily long simulated time before moving
to a state in Si(mod 2) + 1 for i = 1,2. For example, a system with equipment whose times
between failures and repair times are large relative to their processing times might have states
with all equipment operating in SI and states with at least one inoperative machine in S2.
Unless t ' is sufficiently long, starting all n replications with a state in SI is likely to induce a
warm-up analysis that fails to account for transition to S2.
Most discrete-event simulation runs generate sample paths on three generic types of
stochastic processes, waiting time {Wi, i ::: I}, queue length {Q(r), r ::: O}, and resource
utilization {B( r), r ::: O}. If a warm-up analysis based on the waiting-time data concludes
that deleting WI, ... , Wk-I from the data makes Wk, Wk+ I, ... relatively free of the influence
of initial conditions, the analyst customarily deletes {Q (r), 0 :s r :s rk-I} and {B (r), 0 :s
r :s rk-d from their respective sample paths and treats all Q(r) and B(r) for r > rk-I as
also independent of these initial conditions, where Section 3.4 defines r j.
Alternatively, if a warm-up analysis based on the queue-length data concludes that
deleting {Q (r), 0 :s r :s r*} from the data makes Q (r) for r > r* relatively free of the
influence of initial conditions, then the analyst customarily deletes {B ( r), 0 :s r :s r*} and
{Wi; i = 1, ... , N(O, r*)} from their respective sample paths and treats B(r) for r > r*
and Wi for i > N(O, r*) as also independent of initial conditions.
Justification for these procedures comes from the implicit assumption that from an
arbitrarily selected initial state the resource utilization and waiting-time (queue-length)
processes exhibit convergence rates to equilibrium no smaller than that for the queue-length
(waiting-time) process. If an equilibrium exceedance probability pr[ Q(.) > q 1as well as a
mean queue length I-LQ are to be estimated, it also implicitly assumes that starting from an
arbitrarily selected state, I(q.oo) (Q( r)) converges at a rate atleast as great as that for Q( r) as
r ~ 00. Similar assumptions hold when exceedance probabilities for resource utilization
and waiting time are to be estimated. Theoretical results based on spectral structure for
single-server queues support these assumptions.
We now summarize the steps to estimate the length of a suitable warm-up interval:
seeds. On each subsequent replication, use the final seeds of the previous replication as
the starting seed.
5. Compute and plot {X jn1 , 1 :::: j :::: t'l and {Xjn,tl-Hl, 1 :::: j :::: t'l.
6. If the graphs reveal a suitable warm-up interval k -1, use that choice in a new independent
run to collect a larger sample path to assess sampling error. See Sections 6.6 through 6.8.
7. If the graph fails to reveal a suitable warm-up interval, increase t', either continue execu-
tion and data collection of the first n independent replications or simply execute n new
independent replications with the new length, and go to step 5.
Step 1. preamble
Between lines 33 and 34, insert:
define N as a variable
, , N := no. of independent replications
Step 2. main
Between lines 15 and 16, insert:
readN
for I = 1 to N do
Between lines 19 and 20, insert:
loop
Step 3. ACCOUNTING
In line 13, delete:
stop
Between lines 14 and 15, insert:
ifNUM >= K and NUM < = K+T-l call WARM_UP...ANALYSIS
always
Step 4. Merge WARM_UP ...ANALYSIS in Figure 6.3 with AIR-EV.sim in Figure 4.2.
The output in SIMUlS will consist of n = N tableaus as in Figure 4.3 followed by the
summary data {X jn1 , 1 :::: j :::: t'l and {Xjn,tl-Hh 1 :::: j :::: n}.
In addition to generating the data of interest, the WARM_UP ...ANALYSIS routine in
Figure 6.3 resets the state of the system back to the empty and idle state at the end of each
replication. It does this by removing and destroying each event notice in the event lists and
removing and destroying all CALLERs waiting in the QUEUE. Note that f.ev.s(·) denotes the
first event notice in event list ev.s(·). To guarantee nonoverlapping pseudorandom number
streams, the routine assigns the final pseudorandom numbers on the last replication as the
230 C HAP TE R 6. 0 U T PUT A N A L Y SIS
seeds for the next replication. As currently written, the amended program produces a tableau
as in Figure 4.3 for each of the N replications. We leave as an exercise the task of aggregating
the N tableaus into a single comprehensive summary.
, '(April 1998)
NJ = n.ev.s(i.COMPLETION)
for J = 1 to NJ do
let FIRST = f.ev.s(i.COMPLETION)
cancel the COMPLETION called FIRST
destroy the COMPLETION called FIRST
loop
for J = 1 to n.RESERVATIONIST
6.1. WARM-UP INTERVAL 231
NJ = n.QUEUE
for J = 1 to NJ do
remove the first PERSON from QUEUE
destroy the CUSTOMER called PERSON
loop
Assign the final pseudorandom numbers from this replication as the initial
seeds for the next replication.
if COUNT = N
reserve Y(*) as T
A. Use Xkn,t'-k+l as a point estimate ofJL andkn,t'-k+l (8) as an approximating 100 x (1-8)
percent confidence interval for JL, where
(6.7)
(6.8)
and in-l (1 - 8/2) denotes the 1 - 8/2 critical value of Student's t distribution with n - 1
degrees of freedom.
B. Select t > t', restart the nth simulation in the state prevailing when x~~) was collected,
collect k + t - t' - 1 additional observations X~~l' ... , Xk~t-l' and compute the trun-
cated sample average Xk7) (see expression (6.3» as a point estimate of JL, compute an
•
estImate v.(n) f
t
X- (n) • th etruncated sampIe-path d ata X(n)
0 tvar kt usmg k '
X(n)
k+i"'"
X(n)
k+t-l'
and compute
(6.9)
as an approximating 100 x (1 - 8) percent confidence interval for JL, where the degrees
of freedom I (t) - 1 depend on the method employed for computing V,tn) .
C. Start a new independent simulation run, n + 1, in the same initial state as the preceding
·
n replicatIOns, co11ect X(n+I)
k ' ••• ,
X(n+l) ft .
k+t-l a er a warm-up mterv
al k -1, use X-kt
(n+l) as a
point estimate of JL andC k~~N(8) as an approximating 100 x (1- 8) percent confidence
interval for JL.
for considerably more demanding computational procedures. Section 6.6 describes these
procedures, and Section 6.7 describes software, available on the Internet, for implementing
the procedures with minimal effort for the simulationist.
Since the graphical method for selecting a warm-up interval k contains no formal
statistical testing procedure for deciding whether or not systematic error remains after trun-
cating k - 1 observations, it is clearly a subjective approach. Most importantly, picking k too
small affects Options A and B in different ways. For Option B, the influence of any residual
warm-up error diminishes as t ~ 00. By contrast, this error remains constant under Op-
tion A as n ~ 00, implying that Option B is more forgiving than Option A with regard to
understating the warm-up interval.
Regardless of computational convenience, any assertions that a simulationist makes
regarding the statistical errors in Xknt or Xkt are supportable only if the methodology for
deriving Aknt(8) and Cktl(t) (8) rests on well-established statistical theory. For fixed t, the
interval estimate A knt (8) is asymptotically valid if and only if
6.3 FORMALISMS
Although the analysis in Section 6.1 relies exclusively on sample data for a particular sim-
ulation model, it offers an invaluable introduction to the assessment of systematic error.
However, the perspective is a limited one. The next several sections describe a more formal
setting for assessing error. The formalisms apply to data generated by many different types
of discrete-event simulation, and this high level of generality overcomes the limitation of
Section 6.1 by providing the reader with a considerably more comprehensive basis for error
analysis.
Again consider a single sample path Xl> ... , Xk+t-l with finite time average
_ 1 k+t-l
X kt := -
t
L
i=k
Xi (6.12)
as an approximation to the long-run average JL. Let X denote the sample space for the X j
and let {Fj(xls), x E X} denote the conditional d.f. of Xi given that the simulation starts
234 CHAPTER 6. OUTPUT ANALYSIS
in state S(O) = s E S (Section 6.1), so that expressions (6.5) and (6.6) take the equivalent
forms
and
Suppose that Xi has the equilibrium dJ. {F(x), x EX} and thatthe long-run average
/-i equates to the equilibrium mean of Xi; that is, /-i = Ix
x dF(x). For expression (6.12) to
be a useful basis for inferring the true value of the unknown /-i, the underlying stochastic
process must have several properties. These include:
• Let
- 1 k+t-l
/-iskt := E(XktIS(O) = s) = - L 1 xdFj(xls). (6.13)
t j=k x
• Let
2 -
a skt := var(XktIS(O) = s).
For every s E S and each fixed t :::: 1, there exists a positive constant at2 independent
of sand k such that
(6.15)
(6.16)
as t -+ 00. (6.17)
6.4. INDEPENDENT REPLICATIONS 235
~ pr (
likt - ILl
r::'2I;:::: z) as t ~ 00 (6.18)
"a&,/t
if and only if ILskt ~ IL at a rate proportional to t- I / 2 or faster. For many stochastic processes
encountered in discrete-event simulation,
Theorem 6.1.
Let N «(1\, (12) denote the normal distribution with mean (11 and variance (12. Let
{xji) , 1 :::: j :::: t' = k + t - I} for 1 :::: i :::: n denote n independent realizations or
236 C HAP TE R 6. 0 U T PUT A N A L Y SIS
sample paths of the process {X j} each of length k + t - 1. Suppose that expression (6.20) holds
for the conditional mean and that the conditional variance has the representation
(6.21)
where
(6.22)
Then
PROOF. Part i follows from the classical Central Limit Theorem for i.i.d. random variables.
For part ii, let
X knt - tL
Aknt:= J a/ /n
and
tL - tLskt
Bknt := r::2I::' (6.23)
valin
so that
Substituting (6.20), (6.21), and (6.22) into (6.23) and (6.24) shows that the condition
kiln n -+ 00 as k -+ 00 and n -+ 00 suffices for Bknt -+ 0. Also, a;kt -+ a/ as k -+ 00.
- ~
Therefore, A knt converges to (X knt - tLskt)/ Vaskt/n w.p.I, which converges to a normal
random variable from N (0, 1). 0
covers JLskt> not JL, with approximate probability 1 - 8 for large n, where <1>-1(1 - 8/2)
denotes the 1 - 8/2 point of the standard normal distribution N (0, 1). To achieve this same
coverage rate for JL, Theorem 6.1 ii asserts that the warm -up interval k must grow faster than
In n as the number of replications n increases.
Expressions (6.20), (6.21), and (6.22) characterize the conditional means and variances
of the sample means of many stochastic processes encountered in discrete-event simula-
tion. This generality encourages us to adopt this characterization as we learn more about
computing a valid confidence interval.
Since the variance a/ is unknown, Theorem 6.1 is of academic but not of operational
interest. The availability of multiple independent replications proves especially helpful in
making it operational.
Corollary 6.2.
For the specification in Theorem 6.1, fixed t ::: 1, and sint as defined in expression (6.8),
(i knt - JL)/ Jsint/ n ~ N (0, 1) ifk/In n ~ 00 as k ~ 00 and n ~ 00.
PROOF.
- r::;-;:
Let Zknt := (Xknt - JLskt)/ VSknt/n and note that
(6.25)
Since Sfnt/as2kt ~ 1 as n ~ 00 w.p.l and a t2/ as~t ~ 1 as k ~ 00, then as in Theorem 6.1
kiln n ~ 00, as k ~ 00 and n ~ 00, ensure that Zknt converges to Aknt, which has
N (0, 1) as its limiting distribution. 0
(6.26)
RECURSIVE COMPUTATION
( 1) - 1- i Xk,i-I,t
1- (i)
+ iXkt' 1 .::: i .::: n,
Xkit ={
0, i = 0,
and
i- 2 2 1 - (i) - 2
2 { -
. -1sk,l-I,t
· + -. (kt
X -X·
k,l-I,t) , 2'::: i .::: n,
Skit = I - I
0, i = 1
allow recursive computation of Xkit and Sfit' respectively, without the need to store Xk:) , ... ,
Xk7). This facility is especially useful when space is limited.
Since the recursion for sL
is the sum of two nonnegative quantities of roughly the
same magnitude and both are independent of n, it induces a smaller numerical round-off
error than the more commonly encountered space-saving formula (Neely 1966)
2
Sknt = --=-
n
1[~-
1
(i) 2
~(Xkt)
i=1
- 2 ]
- nX knt .
This representation is the difference of two quantities each of which increases with nand
thus can exhibit substantial round-off error when the two quantities are close in value.
BROWNIAN MOTION
Let {Z ( r), r :::: O} denote a stochastic process in ffi with continuous parameter rand
with the properties:
i. pr [Z(O) = zol = 1
6 .4 . I N D E PEN DEN T REP L I C A TI 0 N 5 239
iii. For 0 ::::: s < r, the increment Z(r) - Z(s) has the normal distribution with mean
01 (r - s) and variance 02( r - s).
Then {Z(O) = Zo; Z(r), r > O} is called Brownian motion or a Wiener process starting
at zoo Most importantly, {Zj := Z(n - Z(j - 1); j = 1,2, ... } is a sequence ofi.i.d.
normal random variables with mean 01 and variance O2 • If 01 = 0 and O2 = 1, then {Z (0) =
Zo; Z(r), r > O} is called standard Brownian motion starting at zoo
Theorem 6.3.
For each i = 1, ... , n and each fixed k :::: 1, suppose that the process {Xii 21+ j' j :::: I}
with Xyl as in Theorem 6.1 satisfiesAWA witha 2 = O'~ andd = f,1,. Thenforfixedn :::: 1 and
k ::: 1 as t ~ 00,
ii. (n - 1)sint/O'~ ~ X;-p where X;-l denotes the chi-squared distribution with n - 1
degrees offreedom.
iii. (Xknt - f,1,)/Jsint/n ~ rn-I> where rn-l denotes Student's t distribution with n - 1
degrees offreedom.
SKETCH OF PROOF. As a consequence of AWA, .Jt(Xi!l - f,1,) /~, ... , .Jt(Xi;l - f,1,) / ~
converge w.p.l to n independent random variables each from N(O, 1). The limits in parts i,
ii, and iii follow from this property. D
this approach to confidence interval computation has a natural appeal, once one selects the
number of replications n and the warm-up interval k.
For completeness, we describe the necessary and sufficient conditions that must exist
between nand t for attaining desirable limiting behavior as these two quantities increase
simultaneously. We also describe the necessary and sufficient conditions that must exist
among k, n, and t as all three increase.
Theorem 6.4.
Assume {xjl) , 1':::: j .:::: k + t - I}, ... , {xjn), 1.:::: j .:::: k + t - I} as in Theorem 6.1.
Itskt - It
J a}kt/ n
Although Theorems 6.3 and 6.4 collectively offer a method of generating an asymp-
totically valid 100 x (1 - 8) percent confidence interval for It, its implementation in practice
is problematic. Given an upper bound on total computing time, any attempt to realize the
asymptotic properties that accrue as t increases can only come at the expense of having
n diminish. Conversely, any attempt to realize the asymptotic properties that accrue as n
grows large can only come at the expense of having t diminish. If we were to adopt the latter
course, we would have to ensure that the truncation interval k also grows faster than In n,
so that Corollary 6.2 holds. If we adopted the former course (Option B), we would need
an alternative way of estimating a ~ that ensure an asymptotically valid confidence interval
for It. Indeed, Sections 3.3.4 and 3.5 have already raised this issue for estimating long-run
average utilization, queue length, and waiting time. In the current context, if one has an
estimator Vt based on a single sample path of length t such that
Vt -+ a~ as t -+ 00 w.p.I, (6.27)
then for n = 1 and fixed k, the distribution of (X kt - It)/ y'Vr/t converges to N(O,l) as
t -+ 00. Recall that a Vt satisfying expression (6.27) is called strongly consistent.
6.5. STRICTLY STATIONARY STOCHASTIC PROCESSES 241
(6.28)
revealing the conditional mean function {ExjIX; (X j), j 2: I} and the autocovariance function
{R j - i := cov(Xi , X j ); i, j = 1,2, ... } to be functions of the index difference j - i, but
not of the absolute locations i and j in the index set. Moreover, expression (6.28) shows that
an intimate relationship exists between this conditional mean function and the covariance
242 C HAP TE R 6. 0 U T PUT A N A LY SIS
(6.29)
corr(
Xi, )
Xj = Pi-j := -R;-j
-,
Ro
i, j = 0,1, ... , (6.33)
2 - - 2
at := varX t = E(Xt - JL)
1
LR
t
="2 i- j
t i,j=l
1 t-l
= 2" L
t j=l-t
(t -ljI)R j • (6.34)
6.5. S T RIC TL Y S TAT ION A RY S Toe HAS TIC PRO C E SSE S 243
------------------a. ----------~----~~
0.8 . • a • .90
•
•
~
0.6 . •
1. •
1> •
0.4 .
•
••
••
0.2 .
• ••
•• .....
............... __. . . . . . . . . . A-
0 10 20 30 40 50
j
b.
0.75 a a ·.90
0.5
. • ... • .....
. • • • • • . . • . ............. ---
0.25
~
1. 0
1>
-0.25
-0.5
-0.75
0 10 20 30 40 50
2
LO- jjt)R
/-1
Ro
+ - j • (6.35)
t t j=1
'-v-'
due to variance
due to correlation
Ro from each
between observations
observation
244 CHAPTER 6. OUTPUT ANALYSIS
This partition reveals two distinct contributions to at2 • If Xl. X 2 , ••• were i.i.d., then
the correlations between observations would be zero and a,2 = Rolt. However, congestion
generally induces dependence in waiting time, queue length, and utilization sequences,
and this dependence frequently manifests itself as positive correlation. As a consequence,
a,2 > Rolt for most queueing-related processes. Moreover, as a system becomes more
congested, this positive correlation grows, usually increasing the relative contribution to a,2
made by the underlying correlation structure.
The condition limHoo ta,2 = a~ < 00 in expression (6.16) implies that
t-l
Ro L (l-Ijllt)pj ~ a~ as t ~ 00. (6.36)
j=l-t
For this to hold, limj-+oo Pj = 0 is necessary but not sufficient. However, the condition
t-l
Ro L Pj ~ a~ < 00 (6.37)
j=l-t
is both necessary and sufficient. This property implies that, in addition to the correlation
between Xi and X i+j converging to zero as j ~ 00, it must dissipate sufficiently fast so that
the summation in expression (6.37) converges. An equivalent characterization is possible
in terms of the conditional mean. See expression (6.28). Hereafter, we occasionally refer to
a~1 Ro as variance inflation.
To illustrate the implications of the limit (6.37), consider the autocorrelation function
for which
(6.39)
and
a~ l+a 1 + PI
= = (6.40)
Ro 1- a 1 - PI
Table 6.2 shows how varXt becomes inflated as a increases. For example, a nearest-
neighbor correlation of a = .10 results in a 22 percent increase in the variance of X t over that
to be expected if the XI, X 2, .•. were i.i.d. More generally, the entries in Table 6.2 reveal that
treating X t as the average of i.i.d. data when it is not can result in a substantial overstatement
of the accuracy of Xt •
Since a~1 Ro < 1 for a < 0, var Xt is less than would occur if the data were i.i.d.
6 .5 . S T RIC TL Y S TAT ION A RY S Toe HAS TIC PRO C E SSE S 245
Although autocorrelation functions for utilization, queue length, and waiting time are
rarely, if ever, literally of this geometric form, they often have geometric bounds. For example,
a waiting time sequence, Xl, X 2 , ••• for the stationary M/M/I queueing model with arrival
rate).. and service rate w (> )..) has traffic intensity v := )..jw, mean /-t = vjw(1 - v),
variance Ro = v(2 - v)jui(1 - V)2, and autocorrelation function (Blomqvist 1967)
00 [ V Ji (2i - 3 ) ! . . ..
Pi = i~3 (1 + V)2 i!Ci _ 2)! (I - ] - 1)(1 - ] - 2), j = 0, I, ... , (6.41)
Pi ~
[
(1
4v
+ V)2
Ji '
j = 0, I, ... . (6.42)
For example, v = .90 and .95 give 4vj(1 + V)2 = .9972 and .9993, respectively, leading to
relatively slow decreases in the bound (6.42) as the lag j between two waiting times increases.
Moreover,
· t varX- t =
11m 2
0'00 = 2(
V
)4
(
V
3
- 4v
2
+ 5v + 2), (6.43)
t-'>oo W 1- v
1 3 2
( )(
2-v I-v
)2 (v - 4v + 5v + 2) (6.44)
To assess how well Xt approximates fL, we need an estimate of a&,. The batch-means method
offers one option. Let bet) denote a positive integer « t), let let) := Lt/b(t)J, and let
aCt) := l(t)b(t). Our version of the batch-means method fits within the context of Option B
in Section 6.2. It partitions the sequence Xl, ... , Xa(t) into let) nonoverlapping batches
each of size b(t),
(6.45)
Yjb(t)
1
:= bet) 8
b(t)
X(j-l)b(t)+i, j = 1, ... , let), (6.46)
1 I(t)
(6.48)
and, among all such choices, to select one that makes the width of the interval relatively
narrow and that is computationally efficient. We first describe an application of the batch-
means method. For a simulation of the MIMII queueing model begun in the steady state with
interarrival rate v = .90, service rate unity, for t = 107 customers, and 8 = .01, Figure 6.5a
shows{(X tj , C1(tj)(8)): tl = 35, tHl := 2tj; j = 1, ... , 18} U {(Xt, C1(t)(8))} for mean
waiting time in queue (fL = 9), and Figure 6.5b shows the corresponding statistics for the
probability of waiting (fL := pr(Wi > 0) = .90). These statistics were computed using LA-
BATCH.2, an implementation of the batch-means method. It is available in C, FORTRAN,
and SIMSCRIPT II.5 on the Internet at http://www.or.unc.edu/~gfish/labatch.2.html.LA
BATCH.2 can be applied either interactively to data generated during a simulation or after
simulation termination to stored sample sequences generated by the simulation.
6.6. BATCH-MEANS METHOD 247
(a) Series 1
20 -
p-
15 -
Mean
waiting
-1- -1--1-- H -H
time 10 -
--j-- --....---
5 -
o 0 5 10 15 20
Interim review I
(a) Series 1
20 -
15 -
-p--I--I-+-H+-'-
Mean
waiting
time 10 -
5 -
o 0 5 10 15 20
Interim review I
Figure 6.5 LABATCH.2 sample means and 99% confidence intervals for ABATCH
rule; simulation starts in steady state
The graphs allow us to assess how well the point estimates {X t " ••• , X/" , Xt } approx-
imate f.-L. For small j the Xt j are unstable. However, the sequences stabilize with increasing
j. At the same time, the confidence intervals first widen with j and then decrease. By j = 14
in each figure, stabilization of Xt j and the width of the confidence intervals suggest that the
error of approximation is relatively small. We return shortly to a discussion of this initial
widening of confidence intervals.
248 CHAPTER 6. OUTPUT ANALYSIS
Figure 6.6 shows LABATCH.2-generated tableaus that provided the data for the graphs
in Figure 6.5. For each series, the "Final Tableau" presents results computed at the end of
the simulation; in particular, the point estimate Xof J1 based on all t = 10 7 observations,
the estimated standard error of X, JB*W(L, B)/t, where the numerator is based on the
first t'(107) = 9,175,040 observations, a confidence interval [Lower, Upper] based on
Cz(I) ( . 0 1) in expression (6.48), and a rough measure of relative error (Upper-Lower) I IXI for
X. Section 6.6.3 explains why W(L,B) is based on t' (107 ) rather than 107 observations.
Figure 6.6 reveals an estimated error of ± 100 x .0302/2 = ± 1.51 percent relative
to the sample mean waiting time and an error of ± 100 x .002416/2 = ± .1208 percent
relative to the sample exceedance probability. As a rule of thumb, a simulationist may regard
an entry under IUpper - Lowerl/lXI ::: .20 as implying relatively high accuracy.
Readers concerned principally with results as in the Final Tableau may skip to Sec-
tion 6.7 for a description of how to implement LABATCH.2 or to Section 6.6.5 for an account
of how Arena/SIMAN uses the batch-means method. The remainder of this section together
with Sections 6.6.2 through 6.6.9 describes details that influence the extent to which an
application of the batch-means methods leads to asymptotically valid confidence intervals.
For each series, an "Interim Review Tableau" in Figure 6.6 lists results for each review j
based on tj = L * B observations, where L denotes number of batches, B denotes batch size,
and tHI = 2tj. Section 6.6.5 describes the mechanism for increasing Land B. The entries
under Sqrt[B*W(L,B)] provide a sequence of estimates A of (Yoo that become increasingly
stable as j increases. Figures 6.7a and 6.7b show the graphs for these entries for each series.
Most notable is the initial growth followed by fluctuation about the theoretically known
limits (Yoo = 189.5 and (Yoo = 1.308 in Figures 6.7a and 6.7b respectively (Blomqvist 1967).
This initial growth pattern is responsible for the widening of confidence intervals for J1 for
successive small j. Section 6.8 provides an additional way of assessing convergence in Figure
6.12b.
Why do the estimates of (Yoo behave as in Figures 6.7a and 6.7b? To the potential user of
the batch-means method, this behavior and the initial widening of the confidence intervals
can be puzzling. A description of the sampling properties of VI explains these phenomena.
When XI,"" X t are i.i.d., with varX i < 00, the assignment bet) = 1 and let) = t makes
CI (I)(8) an approximating confidence interval, based on t - 1 degrees of freedom, whose
error of approximation is generally negligible, say, for t ::: 100, regardless of the parent
distribution of the Xi. When {Xi} is a dependent sequence, as commonly occurs in discrete-
event simulation, no comparable rule of thumb applies, since two properties now affect the
error of approximation. As before, one is the marginal distribution of the Xi; the other is
the correlation between Xi and X j for all i #- j in the sample. An analysis of the properties
of VI reveals how these errors arise.
6.6. BATCH-MEANS METHOD 249
Ca)
Final Tableau
Mean Estimation
***************
(t = 10000000 )
99.0%
Standard Error Coni idence Interval
Series Sqrt [B*W(L.B) It] Lower Upper (Upper-Lower) I I X I
Cb)
Interim Review Tableau
ABATeH Oata Analysis for Series 1
99.0%
Confidence Interval
Review L*B Lower Upper Sqrt [B*Iri(L.B) ] p-value
99.0%
Confidence Interval
Review L*B Lower Upper Sqrt[B*W(L,B)] p-value
Figure 6.6 LABATCH.2 output for MIMII queueing simulation (Series 1: waiting
time in queue, Series 2: 1:=wait, O:=no wait)
250 CHAPTER 6. OUTPUT ANALYSIS
2SO .
200 •
~
J
flSO :
~
rr -
fIl 100 ·
SO ·
0
0 5 10 15 20
Interim review J
1.75 :
1.5 :
1.25 :
~
t
1:
~O.75 :
rr .
fIl
0.5 :
0.25 :
0
0 5 10 15 20
Interim review J
t 2 2
EVt = - - ( ab - at ), (6.49)
1- 1
which for positively auto correlated sequences is usually negative. IfE(Xi - f.1.)12 < 00 and
{Xd is ¢-mixing with ¢i = 0(i-9), then expression (6.49) takes the form (Goldsman and
6.6. BATCH-MEANS METHOD 251
where
I> cov(X
00
y := -2 1, Xl+i)'
i=1
The sequence {Xd is said to be ¢-mixing if there exists a sequence of real numbers
{¢z} with ¢z --* 00 as 1 --* 00 such that for all subsets A and B <; X and all i, j 2: 1
with the property that MSE(Vt ) --* 0 if and only if I(t) --* 00 and b(t) --* 00 as t --* 00.
This property is called mean-square convergence.
Expression (6.49) leads to the representation
where Et has mean zero and variance (6.51). Hereafter, we collectively refer to the errors due
to finite t and to ignoring correlation as systematic variance error. Expression (6.50) shows
that systematic variance error behaves as O( (l + 1) / t) = O( 1/ b), whereas expression (6.51)
shows that JvarE t behaves as 00/ 11/2), revealing the tradeoffbetween the two types of error
that a choice of 1 and b induces. LABATCH.2 makes this choice automatically, thus relieving
the user of a major burden. Sections 6.6.3 through 6.6.5 describe why this choice leads to a
strongly consistent estimator of a~ and an asymptotically valid confidence interval for th.
Since ba; < tal2 < a~ for a substantial number of stochastic processes, systematic
error variance tends to induce a downward bias in Vt, as an estimator of a~, that dissipates
252 C HAP TE R 6. 0 U T PUT A N A LY 5 I 5
as t increases; hence the behavior in Figures 6.7a and 6.7h. Notice that after the systematic
variance error becomes negligible, the remaining fluctuations in each graph tend to vary
around some constant level and diminish in magnitude. This behavior signals that systematic
variance error is negligible. Reduction of the magnitude of fluctuations reflects the var Et =
0(11 l) property induced by the ABATCH rule (Section 6.6.5) that LABATCH.2 employed
when choosing number of batches and batch size on each review.
Mean-square error convergence implies convergence in probability of Vt to a~. In the
current context, this means that for given E > 0
We then say that Vt is a weakly consistent estimator of a~. However, this property does not
ensure that C1(t)(8) is an asymptotically valid confidence interval for /1-. For this to be so, Vt
must be a strongly consistent estimator of a~. To achieve this property, we must impose
additional restrictions on the evolution of ((l(t), bet))}.
Assume that there exists a constant A. E (0, !) such that
where {Z(s), s ::: O} denotes standard Brownian motion (Section 6.4). This is called the
Assumption of Strong Approximation (ASA). A A. close to ! signifies a marginal distribution
for the Xi close to the standard normal and low correlation between Xi and Xj for all i i= j.
Conversely, A. close to zero implies the absence of one or both of these properties. See Philipp
and Stout (1975).
Theorem 6.5 implies that b(t) must grow at least as fast as t 8 , where e > 1 - 2A..
Conversely, let) must grow sufficiently fast to ensure that the summation L:i=dl(i)]-q
converges. Since A. is usually unknown in practice, we are unable to confirm that our choice
of ((let), bet)} satisfies the requirements. Nevertheless, the guidance is unequivocal. If Xi
has a highly nonnormal distribution or Xl, X 2 , ••• have high dependence (A. close to zero),
batch size must grow faster than would be required if the distribution of Xi were close to
the normal and Xl, X 2 , ••• exhibited little dependence (A. close to!).
6 .6 . BAT C H - MEA N S MET HOD 253
If a simulationist computes only one estimate, Wl(t)b(t) , based on the total sample
record of length t, then, regardless of the batch size assignment rule, the analysis pro-
vides no information about the extent to which the desired asymptotic properties hold
for Vt = bet) Wl(t)b(t) as an approximation to a~. As Figures 6.6 and 6.7 show, a sequence
of interim reviews overcomes this limitation by computing and displaying results for over-
lapping segments of the sample record of successively increasing lengths tl < t2 < ... .:::: t.
The approach has considerable value when the cost per observation is high and there is
doubt, before experimentation, about how many observations to collect. Moreover, choos-
ing tHI = 2tj for j = 1,2, ... with given tl allows LABATCH.2 to compute the sequence
of estimates Wl(tl)b(t.), Wl(t,)b(t,), ... , Wl(tj)b(tj)' Wl(t)b(t) for each series in OCt) time. If LA-
BATCH.2 is implemented dynamically, the space requirement is O(log2 t). Maintaining an
O(t) computing time is essential for the single sample path approach to achieve greater sta-
tistical efficiency than the multiple independent replications approach. If generating the data
takes O(t) time, then no increase in computational time complexity arises. The O(log2 t)
space complexity is particularly appealing when t is large and interim reviews are desired
for estimates of more than one mean.
To understand the statistical implications of our choice of {tj}, we consider more gen-
eral schemes tl < t2 < .... For a sequence ofi.i.d. random variables Xl, X 2, ... , this choice
implies corr(Xtj Xt,+ j ) = J t j I ti+ j for i ::: 0 and j ::: l. More generally, if corr( Xl, X 1+ j) =
Ijl • - - •
a , for some -1 < a < I, then hmj-->oo corr(X tj , Xt,+j) = hmj-->oo Jtjlti+j. These
observations suggest that we choose e := tHdtj sufficiently large so that estimates on
successive reviews avoid substantial redundancy. We choose e = 2, which implies corr
(.X t , Xt . ) = 2- i / 2 in the independent and asymptotic (as j ---+ 00) cases. For example,
} I+}
corr(X J Xt}+l ) = -1212 = .7071 (in the i.i.d. case). Any growth factor less than 2 would
I ,
induce higher correlation. Moreover, any factor other than 2 would substantially change the
space complexity log2 t.
Let lj := l(tj) and bj := b(tj) and recall that systematic variance error dissipates as
O(llbj ). This implies that choosing b j ex tj would diminish this error most rapidly. We
illustrate the benefit and the limitation of this approach using the FNB rule to define the
batching sequence {(I j, b j), j = 1,2, ... }. Given (11, bd, this rule fixes Ij = 11 for all j and
doubles the batch size, b HI = 2bj , on successive reviews; hence the title, FNB, for a fixed
number of batches.
Appendix A describes the principal steps for implementing the rule with tHI := 2tj
for j = 1, ... , J(t), where
J(t): = 1 + Llog(tlllbd/log2J
254 CHAPTER 6. OUTPUT ANALYSIS
implying that Cl, (8) is an asymptotically valid confidence interval for JL. However,
implying that Vt](I) does not converge in mean-square as t ---+ 00 and, therefore, lacks
the desired statistical property of consistency. Appendix A graphically illustrates how the
absence of mean-square convergence results in a sequence of estimates of a~ whose sampling
fluctuations fail to dampen as t ---+ 00.
whereas column "HalfWidth" in the Arena final tableau displays (U - L) /2 (e.g., Figure 4.14).
Although the latter quantity is usually called the half-length in statistical analysis, we retain
the half-width notation merely for consistency with Arena labeling.
At the end of a run of t observations, Arena tests the batches for independence using
the procedure in Section 6.6.8. If rejected, Arena enters (Corr) in the Half Width column,
signifying that the batches are correlated. If accepted, Arena computes and enters the 95
percent half-width rZ(tJ-l(.975)jVa(t)/t, where aCt) := l(t)b(t) denotes the number of
observations used to compute Va(t). Note that the computation uses all the data if r ::: 320
and r /16 is integer. For t ::: 320, aCt) / t > .955; for t > 1920, a(t) / t > .99.
Let M ( T ) denote the number of value changes in a time-persistent phenomenon such
as queue length, in a simulated time interval (0, r]. For a sample path of t simulated time
units, Arena enters (Insuf) in the Half Width column if M (t) < 320. Otherwise, it maintains
batches at simulated time r ::: inf[z ::: 0 : M(z) ::: 320] with
value changes per batch. IfH is rejected, it enters (Corr) in the HalfWidth column. Otherwise,
it enters rZ(t)-1 (.975)jVa(t)/ t, where a(t) = LI(M(t) )b(M(t))J is the number of observa-
tions used to compute Va(t). As before, 20 :.s I(M(r)) :.s 39, and t'(M(t))/M(t) ::: .955
for M(t) ::: 320 and::: .99 for M(t) ::: 1920.
For the bounded number of batches in the Arena method, expressions (6.50) and
(6.51) imply that Va(t) has coefficient of variation
jvarVa(t) 2[I(t) + 1]
y(Va(t)):= EVa(t) --+ [l(t) - 1]2 as t --+ 00,
where
2[I(t) + 1]
.2354:.s [let) _ 1]2 :.s .3411.
This suggests persistent and relatively substantial fluctuations in Va(t) regardless of how
large t is. An analogous result holds for Vt'(M(t)). Section 6.9 describes how an Arena user can
specify batch size and confidence level and perform a post-simulation batch-means analysis
on stored sample data. It also discusses the differences between Arena's and LABATCH.2's
use of the batch-means method.
256 CHAPTER 6. OUTPUT ANALYSIS
Within LABATCH.2, the SQRT rule offers an alternative that ensures convergence for
Vt.ltdefines {Uj' bj), j ~ I} such that lj+l/lj == ..tiandbj+Ifbj == ..ti.Morespecifically,
for given II and bl> it sets
~ b, ,~{
ifb l = 1,
b, :"ru" + .5J ifb l > 1,
(6.60)
Choosing (/1, bl)from 13 in Table 6.3 ensures that 2l l b l = llbl> so that tj = ljb j = 2j - l l l b l
and, therefore, t j+ If t j = 2, as desired.
Appendix A.2 describes the principal steps for the SQRT rule for j = 1, ... , J(t).
Under this rule, Vt ](,) --+ 0 as t --+ 00, ensuring the desired mean-square convergence. Also,
the rule has an optimal property with regard to the standardized statistic
X t - jL
(6.61)
Zlb:= JWlb/ 1
with d.f. Fib. Appendix A.2 shows that l(t) ()( t l / 2 and b(t) ()( t l / 2 ensures the fastest
convergence of Flb(Z) to 4>(z) for each Z E (-00,00). Since for large t we use the normal
d.f. 4>, in place of the unknown d.f. Fib, to compute a confidence interval for jL, this last
property implies that the actual coverage rate for confidence intervals converges to the desired
theoretical coverage rate 1 - 8 as rapidly as possible.
AppendixA.2 also illustrates how the rule works for the MIMll example and compares
its performance with that of the FNB rule. The comparison especially in Figure 6.8a reveals
that the FNB rule offers an initial benefit but the SQRT rule ultimately offers the advantage
of mean-square convergence.
If the specified sample path length is t = 201 - IZl b l for ot > 1 and (/1, bd as in Table
6.3, then a(t) = t. Recall that a(t) is the number of observations used by the batch-means
method (Section 6.6). More generally, for any t ~ 500, LABATCH.2 automatically selects
(/1, b l ) such that a(t)/t is maximal. This maximum always exceeds .89. See Appendix A.3.
The FNB and SQRT rules each have desirable and undesirable features. By employing
a test for independence to choose between them on successive reviews, LABATCH.2 exploits
the better properties of each and avoids their most serious limitations. It does this by means
of two hybrid rules LBATCH and ABATCH.
6.6. BATCH-MEANS METHOD 257
! ~ 38 54
2 3,6 39 55
3 4 41 58,87
4 6 43 61
5 Z,14,21,28 44 62,93
Z 10, 15,20,25,30,35 46 65
~ 11 48 51,68,85
9 13 49 69
10 14,21,28 50 71
12 17,34,51,68,85 51 60,72,84,96
14 15,20,25,30,35 53 75
15 21,28 54 57
17 24,36,48,60,72,84,96 55 78
19 27,54 56 79
20 21,28 58 82
21 25,30,35 60 68,85
22 n,62,93 61 86
24 34,51,68,85 62 66
25 28 63 89
26 37 65 92
27 38,57 66 93
28 30,35 67 95
29 41,82 68 72,84,96
31 44,66,88 70 99
32 45 72 85
33 47 82 87
34 36,48,60,72,84,96 84 85
36 51,68,85 85 96
37 52 88 93
af1 is defined in expression (6.59) and hI in expression (6.60).
For underlined quantities, see Section 6.7.4.
Let Ho denote the hypothesis: On review j) the I j batches Y 1bj , ... , Yljb j are i.i.d. The
LBATCH and ABATCH rules both use the outcome of a test of Ho to switch between the
FNB and SQRT rules on successive reviews. The effect is to retain the desirable properties
of each basic rule while reducing the influence of their limitations. The principal features of
these hybrid rules are:
LBATCH RULE
350
... ,
I
..
\
300 . \
\
250 ·
-------------------------------- ~
100 -
•
50 -
o ~~~~=-----------------------------~
o 5 10 15 20
Interim review j
1.75
1.5
1.25 ~
~
J
fm 1
EC"
In 0.75 ~
0.5 ~
0.25 :
0
0 5 10 15 20
Interim review J
Figure 6.8 LABATCH.2 estimates of a oo (ABATCH rule: heavy line, FNB rule: thin
dashed line, SQRT rule: thin line, a oo = 189.5: heavy dashed line)
6 .6 . BAT C H - MEA N S MET HOD 259
and:
ABATCH RULE
By initially fixing Z, the LBATCH rule allows batch size, b, to increase at the maximal
rate when Ho is rejected, thus dissipating systematic error in Vlj as fast as possible. Once
Ho is accepted, the rule switches to the SQRT rule to dissipate the error in coverage rate as
rapidly as possible. By testing Ho on every review, the ABATCH rule takes into consideration
the possibility of Type II errors on successive replications. In the present context, Type II
error denotes the random acceptance of Ho when it is false. The LBATCH rule ignores this
source of error, whereas the ABATCH rule allows the procedure to correct itself. Because of
this self-correcting property, we favor the ABATCH rule.
As a consequence of this testing, batch size and number of batches on review j (> 1)
are random. To acknowledge this property, we denote them by B j and L j respectively. Let
K j denote the number of test rejections of Ho on reviews 1, ... , j. Then the LBATCH and
ABATCH rules induce
2(j-K j )/2Z I
~
if j - K j is even,
Lj { 2(j-Kj -I)/2f[ (6.62)
if j - K j is odd,
and
2(j+K j -2)/2 b i
~
if j - K j is even,
Bj { 2(j+K j -I)/2b I (6.63)
if j - K j is odd,
and
asj ~ 00.
Recall that aCt) = tJ(t), where J(t) is defined in Section 6.6.4. Provided that its
conditions are met, Theorem 6.6 gives a strongly consistent estimator of O'~ and the basis
for the asymptotic validity of the confidence interval
(6.64)
We conjecture that there is a large class of problems that satisfy these conditions.
On review J(t), LABATCH.2 actually reports the confidence interval eLJ(t) (8) in
expression (6.48), which differs from VLJ(t) (8) principally by substituting Xt , based on
all the data, in place of Xa(t), based on the first aCt) observations. If aCt) = t, then
C LJ (t)(8) = V LJ (t)(8) and Theorem 6.6 applies. If t > aCt), then we need to reconcile
the difference between CLJ(r) (8) and VLJ(t) (8) with regard to asymptotic validity. We do this
in Appendix A.3.
For purposes of comparison, Figure 6.8 displays {J
B j W LjBj ; j = 1, ... , J(107)}
for the ABATCH, FNB, and the SQRT rules. The dissipation of systematic error under the
ABATCH rule mirrors that under the FNB rule, but its sampling fluctuations are considerably
more attenuated.
6.6.8 TESTING Ho
Because of stationarity (Section 6.5), Y1b, ... , Ylb have the autocorrelation function
To test Ho on the batch averages Y1b, ... , Ylb, we use the von Neumann ratio (von
Neumann 1941, Young 1941, Fishman 1978, 1996)
(6.65)
i=1
6.6. BATCH-MEANS METHOD 261
estimates the first lagged autocorrelation WI. Inspection reveals that Cz is itself an estimator of
WI adjusted for end effects that diminish in importance as the number of batches I increases.
If {Xi, i ::: O} has a monotone nonincreasing autocorrelation function (e.g., Figure 6.4a),
then in the present setting WI is positive and decreases monotonically to zero as batch size b
increases. If for some I and b, Ho is true for Y lb , ... , Y Zb , then WI = 0, and more generally,
the monotone property implies corr(Yib , Y jb ) = 0 for all i =f j.
If Y1b-fL, ••• , Ylb-fL are i.i.d. from N(O, 1), then under Ho, Cz has mean zero, vari-
Ub lIb
ance (I - 2)1(12 - 1), and a distribution that is remarkably close to normal for I as small
as eight. For i.i.d. nonnormal Y lb , ... , YZb under H o, Cz has mean zero. As I increases,
[(12 - 1)/(1 - 2)] x var Cz --+ 1 and the skewness, E(Cz - Ecd I[E(C z - ECZ)2j3/2, and
excess kurtosis, E( Cz - ECZ)4 1[E( Cz - ECz )2]2 - 3, converge to zero.
Under the assumption of a monotone nonincreasing autocorrelation function for
{Xi, i ::: OJ, a one-sided test of size f3 is in order. In particular, if Cz ::: <1>-1 (1 -
(3)J(I- 2)/([2 - 1), Ho is accepted. Otherwise, it is rejected. The one-sided test protects
against accepting Ho when the sample autocorrelation, Cz, between Y ib and Yjb for all
Ii - j I = 1 is "too large" to be attributed to sampling variation.
For the ABATCH rule, Figure 6.9a shows {L j; j = 1, ... , l(l07)} and Figure 6.9b
displays
which we call the p-value sequence. In particular, Pj provides a credibility index on review
j by estimating the probability of observing a C L j' under H o, larger than the one computed
from Y IBj ' ... , Y LjBj • A small P j implies low credibility for Ho. LABATCH.2 makes its
decision on review j as follows. If Pj < f3 on review j, for example for a user-specified
f3 = .10, then LABATCH.2 rejects Ho and uses the FNB rule on review j + 1. This implies
Lj+1 = L j , as Figure 6.9a shows for j = 4 through 8,11, and 16. If Pj ::: f3, then
LABATCH.2 uses the SQRT rule on review j + 1, so that L j+t! L j == ../2. Figure 6.9a
illustrates this behavior for j = 1,2,3,9,10,12 through 15, 17, and 18. The long run
of successes beginning on review 12 suggests that batch sizes greater than El2 = 10240
make the residual correlation between batches negligible. When the LBATCH rule is used,
LABATCH.2 makes its acceptanceirejection decisions according to that rule.
Suppose that {Xd has an autocorrelation function that exhibits damped harmonic
behavior around the zero axis (e.g., Figure 6.4b), or that {Xd is an i.i.d. sequence. In the
damped harmonic case, the one-sided test accepts Ho when negative correlation is present.
262 C HAP TE R 6. 0 U T PUT A N A LY 5 I 5
300 ·
250 ·
200 .
Number
of
batches 150 ·
100 .
50 ·
0
0 5 10 15 20
Interim review J
0.8 ·
0.6 ·
p·value
lor Ho
0.4 ·
0.2 ·
0'0~-------=~----~--~1~0'---------'1~
5 ----------~2~
0
Interim review J
Figure 6.9 LABATCH.2 output for Series 1 using the ABATCH rule
In the ij.d. case, review J (t) produces final results with B (t) > 1 when a unit batch size
suffices and gives a statistically better estimate of a ~. LABATCH.2 provides information that
enables a simulationist to infer the presence of either of these cases and to take advantage of
this knowledge.
6.6. BATCH-MEANS METHOD 263
Once LABATCH.2 completes its last review J(t), it computes the p-value
P: := 1- <I>( V~
t=:lC; ) ,
where
for the hypothesis Ho applied to the original observations XJ, ... , Xt. It also computes an
approximating 100 x (1 - 8) percent confidence interval
(6.66)
and sample standard deviation Jw:. 1 and displays them in the Interim Review Tableau for
a series below the title "If data are independent:' For example, see Figure 6.6, where the
p-value for each series is 0.0000, thereby rejecting Ho.
Whenever this final row displays P:
> {3, the specified significance level for testing
H o, three possibilities arise:
In summary, while LABATCH.2 automatically provides its Final Tableau based on the
concept of asymptotically valid confidence intervals, a perusal of the entries in the row below
"If the data are independent" for each series offers an opportunity for obtaining a tighter
confidence interval.
20 ·
15 -
. ····l·· TT ··rt+·
Mean
waiting
time 10
··I··t·t.H..•..•...
5
o ~~------~-------------- ________________~_
o 5 10 15 20
Interim review j
Figure 6.10 LABATCH.2 Sample means and 99 percent confidence intervals for
Series 1 using the ABATCH rule; simulation starts in empty and idle state
6.7. LABATCH.2265
However, this observation in no way mitigates the value of the assessment when we know
for a fact that Xt may contain systematic bias as a result of starting in an arbitrarily chosen
state and possibly choosing an inadequate warm-up interval.
6.7 LABATCH.2
implements LABATCH.2, where Table 6.4 defines its arguments. As an example, suppose
they assume the values
IN-UNIT = 0,
OULUNIT = 15,
T = 1000,
S_NUM = 2,
PSLVECTOR = pointer to data vector,
DELTA = .01, (6.68)
266 CHAPTER 6. OUTPUT ANALYSIS
RULE = 1,
BETA = .10,
LUPPER= 30,
SCREEN = O.
erages at the .10 signifiance level. LABATCH.2 begins its first iteration with the number of
batches no greater than LUPPER=30. SCREEN=O suppresses the interactive screen feature.
In practice, all but the values of T and S_NUM can be set once and the subroutine used
repeatedly in different settings.
Testing (Section 6.6.7) determines whether the batch size on review j + 1 increases
by a factor of 2 (rejection) or approximately -Ji (success). A doubling of batch size aims at
reducing any residual systematic variance error detected on review j as fast as possible. A -Ji
increase signals that the number of batches is also increasing approximately by a -Ji factor.
This growth in both batch size and number of batches as the sample path length grows is
a necessary condition for obtaining a strongly consistent estimator of a~. Our subsequent
description ofLABATCH.2 uses the definitions in Table 6.4.
As already mentioned, LABATCH.2 provides two ways of accessing data for statis-
tical analysis. One requires the user to insert a call statement into the data-generating
program that executes the call each time it produces a new data vector. Calling and exe-
cuting BATCH_MEANS each ofT times that a data vector with S_NUM entries is generated
results in O(S_NUMxT) computing time and O(S_NUMx log2 T) space being used to gen-
erate the LABATCH.2 output. Both complexities arise from choosing rules that cause either
Bj+1 = 2Bj or Bj+1 ~ -JiBj on successive reviews j = 1,2, .... The space bound is par-
ticularly appealing when T is large. Yarberry (1993) and Alexopoulos et al. (1997) describe
the basis for these complexities.
The other option allows LABATCH.2 to read its data from a file, giving the software a
considerably broader range of application than merely for in-line generated sample records.
We illustrate how the in-line option works in the context of the M/M/1 example, but stress
the applicability of the approach to stored sample data.
If IN_UNIT = 30 and OUT _UNIT = 15 (Table 6.4), then a main program needs
to call BATCH-11EANS just once to cause LABATCH.2 to read its sample data from a file
c.30 c.IS
called fort.30 and to write its output to for1.lS • While the O(S_NUMxT) time and
SIMU30 SIMUIS
O(S_NUMx log2 T) space bounds remain for LABATCH.2, they do not tell the whole story.
In particular, the input file requires space proportional to S_NUM x T, which for S_NUM as
small as 1 can be substantial for sufficiently large T.
Programs written in C, FORTRAN, or SIMSCRIPT II.s can implement the second
option without qualification. Any program that provides access to and execution of a C,
FORTRAN, or SIMSCRIPT II.S subroutine can take advantage of the first option. In a sim-
ulation environment, a user-written program in a language that provides standard linkages
for incorporating a subroutine generally consumes less time calling BATCH-11EANS and
analyzing data than a program generated at the icon level in a point-and-click environment.
268 CHAPTER 6. OUTPUT ANALYSIS
1 35 X_BAR 0.1660D+020.1000D+01
C. V. (X_BAR) 0.4557D-01 O.OOOOD+OO
Sqrt [B*W(L,B)] 0.4475D+01 O.OOOOD+OO
continue[y/n]? y
2 70 X_BAR 0.1810D+020.1000D+01
C. V. (X_BAR) 0.3993D-01 O.OOOOD+OO
Sqrt[B*W(L,B)] 0.6047D+01 O.OOOOD+OO
continue[y/n]? y
3 140 X_BAR 0.1914D+02 0.1000D+01
C. V. (X_BAR) 0.3833D-01 O.OOOOD+OO
Sqrt[B*W(L,B)] 0.8680D+01 O.OOOOD+OO
continue[y/n]? y
4 280 X_BAR 0.1886D+02 0.1000D+01
C. V. (X_BAR) 0.4158D-01 O.OOOOD+OO
Sqrt[B*W(L,B)] 0.1313D+02 O.OOOOD+OO
continue[y/n]? y
5 560 X_BAR 0.1111D+020.9250D+00
C. V. (X_BAR) 0.1686D+00 0.4118D-01
Sqrt[B*W(L,B)] 0.4432D+02 0.9014D+00
continue[y/n]? y
6 1120 X_BAR 0.7254D+010.8812D+00
C. V. (X_BAR) 0.2174D+00 0.3415D-01
Sqrt [B*W(L,B)] 0.5278D+02 0.1007D+01
continue[y/n]? y
7 2240 X_BAR 0.6706D+01 0.8862D+00
C.V.(X_BAR) O.1952D+OO O.4135D-Ol
Sqrt[B*W(L,B)] 0.6196D+02 0.1734D+01
continue [y/n] ? y
8 4480 X_BAR 0.7556D+01 0.8830D+00
C. V. (X_BAR) 0.1647D+00 0.2981D-01
Sqrt[B*W(L,B)] 0.8328D+02 0.1762D+01
continue[y/n]? y
9 8960 X_BAR 0.6747D+01 0.8770D+00
C. V. (X_BAR) 0.1366D+00 0.1553D-Ol
Sqrt[B*W(L,B)] 0.8721D+02 0.1289D+01
continue[y/n]? y
10 17920 X_BAR 0.7817D+01 0.8888D+00
C. V. (X_BAR) 0.1080D+00 0.1106D-01
Sqrt [B*W(L,B)] 0.1130D+03 0.1316D+01
continue[y/n]? y
11 35840 X_BAR 0.9513D+01 0.9001D+00
C. V. (X_BAR) 0.1255D+00 0.8205D-02
Sqrt[B*W(L,B)] 0.2260D+030.1398D+01
continue[y/n]? y
12 71680 X_BAR O.9668D+01 0.8973D+00
C. V. (X_BAR) 0.1136D+00 0.6581D-02
Sqrt [B*W (L, B)] 0.2941D+03 0.1581D+01
continue [y/n] ?
6.7.3 IMPLEMENTATION
BATCH~EANS(IN_UNIT,OUT _UNIT,S_NUM,T,DATA,DELTA,RULE,BETA,
LUPPER,SCREEN);
in a SIMSCRIPT 11.5 program calls BATCH~EANS. In addition to reserving space for the
double S_NUM x 1 array DATA in the main program, a user must also include the statements
LABATCH.2 also allows a user to choose any underlined (II, b l ) in Table 6.3 as the initial
number of batches and the initial batch size by specifying a sample path length T = 2a l l b l
for the selected II and bl and where a is a positive integer. In this case, LABATCH.2 uses 100
percent of the data to compute the final BW(L,B).
6.8 . A I RLIN ERE 5 E RV A T ION PRO B L EM 271
6.7.5 CODING
Xi
Parameter Datum for
Series to be estimated ith observation
J-Lw Wi
2 pr(W > 0) 1(0.00) (Wi)
3 pr(W> 1) 1(1.00) (Wi)
4 pr(W > 2) 1(2.00) (Wi )
5 pr(W> 3) 1(3.00) (Wi )
6 pr(W > 4) 1(4.00) (Wi)
7 pr(W > 5) 1(5,00) (Wi)
8 pr(W > 6) 1(6,00) (Wi)
9 pr(W > 7) 1(7,00) (Wi)
10 pr(W> 8) 1(8,00) (Wi)
11 pr(W > 9) 1(9,00) (Wi)
12 pr(W> 10) 1(10.00) (Wi ).
Step 1. preamble
Between lines 33 and 34, insert:
"Vector for data transfer to batch_means
"
272 C HAP TE R 6. 0 U T PUT A N A LY 5 I 5
Step 2. main
Between lines 1 and 2, insert:
reserve DATA(*) as 12
Step 3. ACCOUNTING
Between lines 9 and 10, insert:
DATA(ll) = 1
endif
if DATA(1) > 10
DATA(12) = 1
endif
call BATCH~EANS(O,15,T,12,DATA(*),.0I,I,.10,30,O)
The call to the BATCH~EANS routine transfers the pointer to the DATA vector with 12
entries for analysis.
Figure 6.12a displays the final tableau for a run with warm-up interval K = 200 and
sample path length T = 2 X 106 . This choice ofT induced LABATCH.2 to choose 11 = 13
and b 1 = 9 and to produce results on J(T) = 15 interim reviews. Figure 6.13 shows graphs
for JBW(L,B) based on the interim review tableaus for Series 1 through 12. All graphs
reveal the dissipation of systematic variance error well before review 15. Figure 6.14 shows
the final point estimates and corresponding confidence intervals for {pr(W > w); w =
0, 1, ... , 10 minutes}.
Figure 6.12b offers a particularly revealing illustration of how convergence occurs for
Xtj = X and [W(L(tj)' B(tj))f /2 = [W(L,B)j1/ 2 for j = 6, ... ,15 based on entries in the
LABATCH.2 tableau for waiting time (series O. It shows how both quantities converge to a
relatively small neighborhood as sample-path length increases. Note that t6 = 9 x 13 X 25 =
3744, whereas tIS = 9 x 13 X 214 = 1,916,928. We began at review 6, rather than review
I, to focus on the ultimate convergence.
Our inclusion of Figures 6.12 through 6.14 here and Figures 6.5 through 6.8 in Section
6.6.1 is intended to inform the reader about the potential uses of LABATCH.2 output.
Since Practical considerations may limit how much output for each data sequence can be
presented and digested, we recommend, as a minimum, a display as in Figure 6.12a and, for
each sequence, a display as in Figure 6.12b.
Section 6.6.5 describes how Arena automatically employs the batch-means method with
Student's t distribution to compute an approximating 95 percent half-width for each mean
of interest. For t = 2 x 106 waiting times, execution of the Arena airline reservation program
in Figures 4.12 and 4.13 yielded a sample average waiting time of 4.229 and 95 percent half-
width of .1309. For queue length it gave a sample average of 4.1189 and 95 percent half-width
of .1295. For this t, expression (6.55) implies only l(t) = 20 batches but b(t) = 100,000
observations per batch.
Arena also provides an option for a post-simulation batch-means analysis for user-
specified batch size and confidence level. As illustration, consider the WaiLTime.DAT file
274 CHAPTER 6. OUTPUT ANALYSIS
declared in Figure 4.13. At the end of a simulation run, a user clicks on "Output" on the Tools
menu, on "Analyze;' and on "Batch/Truncate Obs'vns ... ," and then enters WaiLTime.DAT,
as the file name, the desired number of observations to be truncated, the desired batch size,
and the name of the file, suffixed by .fit, in which the batch averages are to be stored. The
user again clicks on Analyze and then on Conf. Interval on Mean, and on Classical ... , and
then enters the name of the .stl file and the selected confidence level.
Final Tableau
Mean Estimation
***************
(t = 2000000 )
99.0%
Standard Error Confidence Interval
Series X sqrt[B*W(L,B)/t] Lower Upper (Upper-Lower)/IXI
5 +4. 426E-001 +2. 717E-003 +4. 355E-00l +4. 496E-001 +3. 178E-002
Figure 6.12 (a) LABATCH.2 final estimates for the airline reservation simulation
using the ABATCH Rule
6 .9 . BAT C H MEA N 5 I N ARE N A 275
Since the approximating 99 percent confidence interval for waiting time (Series 1) in
Figure 6.12a is based on an LABATCH.2 determined batch size of 4608 for the SIMSCRIPT
U.s airline reservation model, the batch-means analysis for the Arena data was performed
for a batch size of b(t) = 5000, implying l(t) = 400 batches. It yielded an approximating
99 percent half-width of .1370 for waiting time, which compares to the LABATCH.2 half-
width of .1290 in Figre 6.12a for Series 1. Although based on two independent sample paths
generated by two different simulation programs, the estimates are reasonably close. However,
LABATCH.2 automatically determined its batch size, whereas a user must provide a batch
size for the Arena option.
Given the WaiLTime.DAT file, a user can overcome this limitation on knowing an
appropriate batch size by using LABATCH.2. The WaiLTime.DAT file has binary mode.
Arena provides a capability for converting these data to scientific notation and exporting
them to a new file that can serve as input to LABATCH.2. To make this conversion, a user
clicks on Tools, Output Analyzer, File, Data File, and Export, and then enters the name of
the .DAT file and name of the receiving file.
For these data with maximal initial number of batches LUPPER = 30 (Section 6.7),
LABATCH.2 computed a final 99 percent confidence interval [4.039,4.359], which gave
a half-width of .130, based on L(t) = 208 batches and B(t) = 9216 observations per
batch. The larger L(t) compared to l(t) = 20 in the automatically generated Arena 95
80
12
t ) · = 13x9x 2 j - 1
78
14
76
74
S 13
~
d. 72
~ 9
II
S 70
~ IS
CQ
,...:: 68
::r
-~
If 66
64
10
62
60
4 4.2 4 .4 4 .6 4.8 5.2 5.4
-
X,=X
J
~,
i",. L
(c) and (d) ,.
--I --I
--, .. " ..
--I M .. ..
--,
.. ..
--, --, "
percent analysis implies that in addition to accounting for the dependence among batches,
the LABATCH.2 estimate of ta~ has smaller variance.
The .fIt file requires about 16t bytes of space to store a record of observations containing
t waiting times. This excessive space need arises because Arena also stores the times at which
each observation was collected and retains eight-byte double-precision accuracy for each
entry. In the present case 16t = 2 x 8 x 2 X 106 = 32 megabytes. In comparison, LABATCH.2
requires O(810g 2 (t» space to perform its analysis on t waiting times in double precision.
Had we also wanted to do an Arena analysis for queue length, at the .99 significance
level, the additionally required space would have substantially exceeded that used for the
waiting times because of the need to store data each time the time-persistent queue-length
variable changes value. Therefore, we do this by using the Arena automatically generated
queue-length statistics. Recall that these were a sample-average queue length 4.119 and a 95
percent half-width .1259. Multiplying the automatically displayed half-width by <1(1)-1 (1 -
8/2)/<1(1)-1 (.975) converts a 95 percent half-width to a 100 x (1 - 8) percent half-width,
where equation (6.55) defines l(t), the number of batches, and <1(1)-1 (1 - 8/2) denotes the
1 - 8/2 critical value of Student's t distribution with l (t) - 1 degrees of freedom. In the
present case, 8 = .01 gives a 99 percent half-width .1771, but based on only let) = 20
batches.
Several additional differences distinguish the Arena and LABATCH.2 results with re-
gard to interpretation. For each series, LABATCH.2 provides a Final Tableau, inclusive of all
interim reviews, from which an analyst can assess the stability of the final estimate, BW(L,B),
of a~ and therefore the stability of the corresponding half-width. Arena's approach provides
0.8 -
0.6 -
pr(W > w)
0.4 -
0.2 -
o -O~
' ------~
2 ------~
4 ------~
6------~8--------
10
-----
Figure6.14 Estimate of {pr(W > w); w = 0, 1, ... , 1O} in AIR_EV.sim using the
ABATCHrule
278 C HAP TE R 6. 0 U T PUT A N A LY 5 I 5
no comparable basis for assessment. For reasons of space, the Final Tableaus corresponding
to the series in Figure 6.12 have been omitted here. However, the Final Tableaus in Figure
6.6 for the MIMll model, and their corresponding plots in Figure 6.7, attest to their value
for assessing stability.
A second difference relates to ratio estimators. In a simulation, such as the airline
reservation problem, executed for a fixed number of waiting times, the sample average
queue length has a random denominator and thus is a ratio estimator. LABATCH.2 can be
used to produce a confidence interval that accounts for this property (Section 6.11). Arena
produces a half-width that does not account for this property.
6.10 PREBATCHING
The LABATCH.2 with IN_UNIT = 0 requires a call to the BATCH~EANS subroutine after
each vector of observations is collected. An alternative design can be formulated that would
pass segments of each individual series at the moments of interim review, thereby reducing
the number of calls to BATCH~EANS substantially. However, this alternative requires a
space allocation to store the segment for each series between reviews. A second alternative
has more appeal. It reduces computing cost by prebatching the data. Let
c
Xj = c- 1 L Xc(j-l)+i, c = integer::: 1, j = 1,2, .... (6.69)
i=1
Suppose that Xl, X 2, ••• is the input sequence to LABATCH.2 in place of Xl, X 2, •••• Then
LABATCH.2 is executed no more than t / c times, thereby reducing computing time with no
increase in required space. However, prebatching may induce a loss of statistical efficiency in
estimating a! by inducing larger batches than the correlation, structure in {X j } warrants.
Therefore, this approach has its greatest appeal in the presence of high correlation, which,
regardless of prebatching, would inevitably induce large batches. Prebatching can reduce
cost significantly when multiple sequences are being analyzed.
Recall Option B in Sections 3.4 and 3.5, where data collection begins when job M completes
service and ends when job M + N completes service. Then expression (3.51) with s = rM
and r = rM+N - rM gives the sample average waiting time
(6.70)
6.11. RAT I 0 EST I MAT ION 279
where N = N( T:M+N) - N( T:M), and expression (3.49) gives the sample average queue length
as
(6.71)
Since M and N are fixed, W( T:M, T:M+N) is the ratio of a random quantity and a
deterministic quantity, and LABATCH.2, operating on WM+l, ... , WM+N, provides an as-
sessment of how well W(T:M, T:M+N) approximates the long-run average waiting time JLw.
However, Q(T:M, T:M+N ) under Option B is the ratio of two random quantities, J,';+N Q (u )du
and T:M+N - T:M. Therefore, direct application of the batch-means method does not provide
an assessment of how well Q( T:M, T:M+N) approximates the long-run average queue length
JLQ. However, an indirect application ofLABATCH.2 can provide the ingredients for making
this assessment.
Several indirect methods exist for assessing accuracy in the present case, and we de-
scribe them in the order of the increasing effort they require. First, there is Little's law (Section
3.5.1), which provides an alternative for estimation JLQ using Series 1 in Figure 6.12a. Since
A = 1, that approach yields the point estimate 4.251 and the interval estimate [4.122, 4.380].
Relatively little effort is required to compute these quantities. However, Little's law provides
no alternative if, for example, the objective is to estimate pr [Q (T:) > q] for some q > o.
The remaining indirect methods make use of the observation that expression (6.70)
has the equivalent form
1 M+N
- L !,'i Q(u)du
Q(T:M, T:M+N) = _N_i=_M_+_l_'_-l_ __ (6.72)
1 M+N '
- L (T:i - T:i-d
N i=M+l
which allows us to regard the numerator as the sample average of the N random variables
r'M+l Q(u)du, ... , J'tM+N-l
JT:M
r'M+N Q(u)du and the denominator as the sample average of the N
random variables T:M+l - T:M, ... , rM+N - T:M+N-l. To exploit this representation, we resort
to a more general formulation.
Let Xl, •.• , X t and Y1 , ••• , Yt denote sample records collected on two phenomena of
interest during a simulation. Let Xt and Yt denote their respective sample means and Rt :=
Yr/X t their sample ratio. Assume JLx ,eO. With reference to Option B, Yi = JrM+I_l
r'M+i Q(u)du
and Xi = T:M+i - T:M+i-l for i = 1, ... , t := N. Our objective is to assess how well Rt
approximates R := JL Y/ JL x .
Under relatively mild conditions,
2aoo (X,Y)
t varR-t --+ hxy := R z [a~(x)
--z- +a~(x)]
-- as t --+ 00,
JLy JLxJLY JL~
280 CHAPTER 6. OUTPUT ANALYSIS
where
2 • -
aooeX) := hm t varXr,
t-+oo
2 a~eX)
Yx:= --2-'
f..Lx
2 a~eY)
Yy:= --2-'
f..Ly
aooex, Y)
Pxy := aooeX)aooeY)'
Therefore, a~ey)ltf..Li approximates varR t with relatively small error for large t if
where « denotes "much less than." For example, yy Iyx = 10 implies -4.95 «pxy «
5.05, whereas yY Iyx = 100 implies -49.995 « PXy « 50.005. Since PXy E e-1, 1),
the conditions are easily satisfied for these examples. In short, if the numerator Yt has
a considerably larger coefficient of variation than the denominator Xt, then the error of
approximation is relatively small in approximating var Rt by a~ey)ltf..Li. If a~eY) denote
the batch-means estimate of a~eY), then a~ey)ltX; is our approximation to var Rt . For
the queue length example, tXt = iM+N -iM, sothattheestimateist a~ey)/eiM+N - i101)2.
The photocopying problem in Section 1.4 illustrates ratio estimation in practice. For
each scenario a simulation was executed for t = 1000 weeks, about 20 years of five-day
weeks. Here we use data for Group 3 eTable 1.1) and for Scenario 1, the current operating
6.11. RATIO ESTIMATION 281
along with Ja;)Y)lt = 39.96 and Ja'&:,(X)lt = .3876 via LABATCH.2, as estimates of
JvarYt and JvarX t , respectively. Since
A A 39.96 124.0
yyjYx = - - x - - = 19.05,
676.0 .3876
1 < -1 (YX
- - -yy) «PXy« -1 (YX
- + -yy) ,
2yy Yx 2yY Yx
which cannot be satisfied. In summary, the approximation works best for yY » Yx. The
batch-means inplementation in Arena implicitly uses this variance estimate in computing
the half~length for sample averages that are ratio estimates.
A third indirect method of coping with randomness in denominator as well as
numerator requires more effort but does not rely on condition (6.73). LABATCH.2-
generated tableaus for the three input series Xl, ... ,Xt ; Yl. ... , Yt ; and Zl, ... , Zt, where
Zi := Xi - Yi , provide the basis for this assessment.
Assume that {Xd and{Yd obeyASA (Section 6.6.2). Thenast ---+ 00, Gt := Yt-RX t
has the properties
G t ---+ 0 w.p.I,
t varG t ---+ a~(G) := R2a~(X) - 2Raoo (X, Y) + a~(Y)
= R2a~(X) - R[a~(Z) - a~(X) - a~(Y)l + a~(Y)
< 00,
Gt d
---+ N (0, 1),
-ja'&:,(G)lt
282 CHAPTER 6. OUTPUT ANALYSIS
where
where e := <1>-1(1 - 8/2) and where the argument of the square root is nonnegative as
t -+ 00 w.p.1. Most importantly, this confidence interval remains asymptotically valid for
R when strongly consistent estimates replace a~(X), a~(Y), and a~(Z). The tableaus
in LABATCH.2 for the three series XI, ... , X t; Y1 , ••• , Yt ; and Z I, ... , Zt provide these
estimates.
Figure 6.15 shows the final tableau for Series 13 (numerator), Series 14 (denomi-
nator), and Series 15 (difference) for the airline reservation simulation, whose remaining
output appears in Figure 6.12a. The average queue length /l-Q has point estimate Rt =
4.142 = 2.2876 x 10- 3 /(6.944 x 10- 4 ) and 99 percent approximating confidence interval
[4.103,4.270] based on the interval (6.74), where (3.362 x 10-5 )2, (5.072 x 10-7 )2, and
(3.386 x 10-5 )2 are the estimates ofa~(Y)/t, a~(X)/t, anda~(Z)/t, respectively. The rel-
ative length of the confidence interval is (4.270- 4.013)/4.142 = .0621. Also, LU-I (1-8/2)
replaces <1>-1(1 - 8/2), where L' denotes the minimum of the final number of batches in
estimating a~(X), a~(Y), and a~(Z).
For our first indirect method based on Little's law, recall the confidence interval [4.122,
4.30]. Since yy = 16.53 and Yx = 1.033 based on entries in Figure 6.15, our second indirect
method seems worth applying. It leads to the confidence interval
2.789 2.963]
[ .6944' .6944 = [ 4.016, 4.267].
6.12. LESSONS LEARNED 283
Final Tableau
Mean Estimation
***************
(t = 2000000)
99.0%
Standard Error Confidence Interval
Series X sqrt [B*W (L, B) It] Lower Upper (Upper-Lower)/IXI
Figure 6.15 LABATCH.2 output for ratio estimation for airline reservation problem
In summary, all three methods give relatively similar confidence intervals in this case of mean
queue-length estimation.
• A simulation run ofa delay system tends to generate sample paths made up of sequences
of dependent events. The dependence increases with the level of congestion or delay
in the system.
• As a consequence of this dependence, the initial conditions, or state S(O), that prevail
at the begining of a simulation run influence the course of the sample path that evolves
as simulated time r evolves. However, the influence of these initial conditions S(O) on
the state of the system S( r) at time r tends to diminish as r increases.
• Multiple replications are helpful in choosing an adequate k. Starting with the same ini-
tial conditions on each simplifies the analysis. Also, choosing an initial state that causes
the influence of the initial state to diminish monotonically simplifies the analysis.
• The batch-means method provides one technique for incorporating this dependence.
• LABATCH.2 also can be used to infer the accuracy of ratio estimates (Section 3.4). See
Section 6.11.
• Arena automatically provides a 9S percent confidence interval for each sample average.
For a single sample path (n = 1) it uses another variant of the batch-means method.
However, its assessment of the adequacy of the estimate of the variance of the sample
average is more limited than in LABATCH.2.
6.13 EXERCISES
You now have at least one working simulation program for one or more of the four problems
described in the Exercise section of Chapter 2. The program relies on either the event-
scheduling or process-interaction approach. The exercises described below are designed
to estimate a suitable warm-up interval k - 1 and to assess how well finite-sample aver-
ages approximate corresponding unknown long-run averages. For the latter assessment, use
LABATCH.2, if possible, either in-line or operating on data files after the simulation's exe-
6.13. EXERCISES 285
The objective is to estimate Amax> the arrival rate for external trucks that maximizes
profit as defined in Exercise 2.2. This calls for a simulation program developed in Exercise
4.2 and a sequence of simulation runs executed for different values of A in (0, A*), where
A* = ~ trucks per minute denotes the maximal allowable arrival rate at the crusher for
external 50-ton trucks.
~ 6.1 Initial Conditions. Each distinct value of A introduces a different level of conges-
tion and, hence, a different interval for dissipating the influence of initial conditions. Since
congestion increases with A, the length of a suitable warm-up interval should also increase
with A and be largest for A** := maximal arrival rate used in experiments. Take A** = .9A*
to determine this maximal warm-up interval.
a. Execute n = 10 independent replications each for t' = 100 hours with A = A** and each
starting with the same initial conditions and parametric values, specified in Exercises
2.1,2.2,4.2,4.3,4.5, and 4.6. For each stream j, use its last pseudorandom number on
replication i as the seed for stream j on replication i + 1 for i = I, ... , n - 1.
b. Using the methodology of Section 6.1, prepare graphs of sample average throughput per
five minutes and crusher queue length and use the graphs to choose the k that makes the
influence of initial conditions negligible. Write a short report justifying your choice of k.
Use tables and graphs to support the choice. Label each table and graph with appropriate
titles and identify all variables used therein.
a. On each run, compute the quantities listed in Exercise 4.2e and the sample average profit
apart from the unknown factor A in Exercise 2.2.
b. On each run, compute 99 percent confidence intervals for long-run average profit and
crusher queue length and relative assessments of the accuracy of their sample averages.
286 CHAPTER 6. OUTPUT ANALYSIS
i-I
Ai = - - A** for i = 1, ... ,9.
8
d. Let [A', A"] denote the interval that your results to part c suggest contains Amax. Continue
to make runs for selected values in [A', A"] to refine your estimate of Amax. As guidance
for when to stop, use your point and interval estimates oflong-run average profit.
e. Prepare a report identifying your choice of Amax using graphs and tables to support your
choice.
f. In your report, describe the extent to which your estimates of a~ are stable for sample
average profit and crusher queue length for each A.
To compete with other oil-loading ports, the port authority plans to institute a rebate
program based on total port time. This is the summation of waiting, towing, and loading
times. If a tanker's port time exceeds 48 but is no more than 72 hours, the authority will pay
its owner a rebate of A dollars. If it exceeds 72 but is no more than 96 hours, the rebate is
3A dollars. In general, if it exceeds 24i but is no more than 24(i + 1) hours, the rebate is
(2i - I)A dollars. From Exercise 2.3, A = 10,000 dollars.
a. Execute n = 10 independent replications each for 1000 tankers and each starting with
initial conditions specified in Exercises 4.7 and 4.8. Use your orignal run as replication
1. For each stream j, use its last pseudorandom number on replication i as the seed for
stream j on replication i + 1 for i = 1, ... , n - 1.
b. Using the methodology of Section 6.1, prepare graphs of sample averages of port times
for tanker i for i = 1, ... ,1000 and use the graphs to choose the warm-up interval k
that makes the influence of initial conditions "negligible:' Write a short report justifying
your choice of k. Use tables as well as graphs to support your choice. Label each graph
and table with appropriate titles and identify all variables used therein.
~ 6.4 Estimating Long-Run Average Rebate. The purpose of this exercise is to estimate
f..Lr := sample average rebate per tanker and f..L~ := sample average rebate per tanker that
received a rebate (Exercise 2.3).
6.13. Ex ERe I S E S 287
a. Using the warm-up interval determined in Exercise 6.3, generate a sample path oflength
k + t - 1 = 20, 000 tanker departures.
d. Using the methodology of Section 6.11, compute a 99 percent confidence interval for M~.
f. Your report should also describe the extent to which estimates of a~ are stable for each
sample sequence.
The purpose of Exercises 6.5 and 6.6 is to generate sample-path data using the
simulation program developed in either Exercise 4.12 or Exercise 4.13 to estimate the
minimal mean delay M(A, m) in definition (2.6) and the A at which it occurs for each
m E M := {8, 16, 24, 32}. Recall that A denotes character-arrival rate to an input buffer
and m denotes maximal packet size. Recall that.30 :s r A :s 1 and m E {8, 9, ... , 32}, where
r = 10 denotes the number of input buffers.
iff? 6.5 Initial Conditions. For each fixed m, delay time varies with A, but not necessarily
in a monotone way. In particular, small Aimplies that some characters wait a long time in their
input buffers until being transferred to the relatively uncongested output buffer. Conversely,
large A implies that characters have a relatively short wait in their input buffers, but, because
of congestion, have a long wait in the output buffer. While small Ainduces dependence among
no more than m characters in an input buffer, the low congestion in the output buffer induces
little dependence among characters from different input buffers. However, congestion in the
output buffer for large A does create dependence among characters in different input buffers
and needs to be taken into consideration when deciding on a warm-up interval.
Therefore, for each fixed m, the length of a suitable warm-up interval k m - 1 can be
expected to increase with A and be largest for A* (m), the maximal character-arrival rate used
in experiments. Take A*(m) = 0.95 x poir, where Po is determined in Exercise 2.sb. Since
monotone behavior for delay time is not apparent for varying m but fixed A, the task of
identifying a suitable warm-up interval becomes more challenging. To resolve this problem:
a. For each m E M, execute n = 10 independent replications each for t' = 1,000 trans-
mitted nonoverhead characters with (A = A* (m)) and each starting with the same initial
conditions and parametric values as in Exercises 2.5 and 4.12. For each stream j, use its
last pseudorandom number on replication i + 1 for i = 1, ... , n - 1.
b. Using the methodology of Section 6.1, prepare graphs of sample average delay time
separately for each m E M and use them to estimate suitable truncation points {k m -
288 CHAPTER 6. OUTPUT ANALYSIS
1, m EM}. Write a report justifying your choices. Use tables and graphs to support your
choice. Label each table and graph with appropriate titles and identify all variables used
therein.
4f? 6.6 Estimating Long-Run Average Delay Time. For each m E M, carry out a se-
quence of experiments to estimate the function (fL(A, m), 0 < A < polr} where Po is
derived in Exercise 2.5b. Use the estimated warm-up interval k m - 1 of Exercise 6.5 for all
runs with size m input buffers. For each run, generate a sample path of length k m + t .- 1
where t = 20, 000 transmitted nonoverhead characters.
c. If the objective is to compute a point estimate, [l(A, m) that is within ± 10 percent of the
unknown f.L(A, m), how well have you succeeded? Use quantitative evidence to justify
your answer.
d. Use the results in part a to identify an interval [a(m), b(m)] s:; (0, polr) for A in which
you estimate min). f.L(A, m) is located. Then for each m E M, compute estimates of
f.L(A, m) for each
for each m E M. Use graphs and tables to support your choices, especially those
{Amin(m), m EM}.
f. Provide evidence that your choices of (T~ for each (A, m) combination is stable. If some
are not, explain why.
g. For the data generated in part d, plot estimates of (Too versus Ai = {a(m) + O.li[b(m) -
a (m)]}po/rfor i = 1, ... , 10 and eachm E M. Explain the behavior in (Too as functions
of A and m.
6.13. Ex ERe I 5 E 5 289
The purpose of Exercises 6.7 and 6.8 is to generate sample-path data using the
simulation program developed in either Exercises 4.14 or 4.15 and for each c in C =
{.Ii; i = 1, ... , 9} to use these data to estimate the minimal long-run average total cost
(2.7) as a function of m, the total number of available lines, and r, the number of lines
dedicated to handed-off calls. Since Ah = 4, As = 2, and w = 1 calls per minute, m must
exceed 6 and m - r must exceed 2 in order for the mean number oflost calls per minute to
remain bounded.
,if? 6.7 Initial Conditions. For m transmission lines, r of which are dedicated to handed-
off mobile calls, let
and
Y; = I 0
if call i is a mobile call and it is handed off,
otherwise,
and
Z; = I 0
if call i is a standard call and it is denied service,
otherwise.
(6.75)
Then in equilibrium
and
290 C HAP TE R 6. 0 U T PUT A N A LY 5 I 5
c. Examine the extentto which this choice of k in part b suffices for all r E {O, 1, ... , m -- 2}
and m E {7, 9, 11, 13, IS}. If you conclude that this choice is inadequate for these other
(m, r) 2-tuples, perform additional warm -up analyses to identify more suitable intervals.
Provide evidence to support your choices.
1f? 6.8 Estimating Loss Rates. Carry out a sequence of independent sampling experi-
ments to estimate the loss rates (3s(m, r) and (3h(m, r) for each r E {O, 1, ... , m - 2} and
m E {7, 9,11,13, IS}. Each experiment is to be run for t = 10,000 calls, regardless of type
after the warm-up interval k -1 chosen in Exercise 6.7b or 6.7c has elapsed. There are several
available ways of estimating C(m, r, c) in expression (2.7). One collects the data
Then
_ 1
L
~ k+t-l
C(m, r, c) = X kt := - Xi (6.76)
t i=k
provides an estimate of C(m, r, c). To estimate this quantity with these data requires 432
sample paths, one for each (m, r, c) triplet.
An alternative approach reduces the required number of sample paths. It relies on the
Yi and Zi defined above. Since Xi = Yi + Zi, expression (6.76) is algebraically equivalent
to
(6.77)
where
_ 1 k+t-l
Ykt =-
t
L
i=k
Yi
6.13. Ex ERe I S E S 291
and
_ 1 k+t-l
Zkt =-
t
L
i=k
Zi.
However, for each fixed (m, r), {C(m, r, c), c E c} can be computed from a single
replication, thus reducing the number of replications to 48.
If we merely want point estimates, the second data collection scheme would be un-
equivocally superior. However, we also want to assess the statistical error in each C(m, r, c).
That can be done straightforwardly using LABATCH.2, for example, for each of the 432
runs. However, with a moderate amount of additional programming, it can also be done via
LABATCH.2 for the second 48 sample-path data collection scheme. Since
and since
where
we need estimates of O'~(Y), O'~(Z), and O'oo(Y, Z). For example, using the data
{(Yi , Zi, Yi - Zi), k ::=: i ::=: k + t - I} as input on each call to LABATCH.2 produces
estimates of a~(Y), a~(Z), and a~(Y - Z), where the latter is an estimate of
Therefore,
provides an estimate ofO'~(Y, Z), and [a~(Y) + 2caoo (Y, Z) + c2a~(Z)] It provides the
needed variance estimate. If L(Y), L(Z), and L(Y - Z) are the numbers of batches used on
292 CHAPTER 6. OUTPUT ANALYSIS
the final interim reviews in LABATCH.2, then a conservative approach to interval estimation
takes min[L(Y), L(Z), L(Y, Z)] - 1 as the degrees of freedom.
c. For each fixed m and c, identify your choice of r that minimizes C (m, r, c).
d. To what extent do the confidence intervals support your choice? Be specific in providing
justification.
6.14 REFERENCES
Alexopoulos, c., G.S. Fishman, and A.T. Seila (1997). Computational experience with
the batch means method, Proceedings of the 1997 Winter Simulation Conference, s.
Andrad6ttir, K.J. Healy, D.H. Withers, and B.L. Nelson, eds., IEEE, Piscataway, NJ.
Blomqvist, N. (1967). The covariance function of the M/G/I queueing system, Skandinavisk
AktuarietidskriJt,50,157-174.
CACI, Inc. (1983). SIMSCRIPT II.S Reference Handbook, CACI Products Company, La Jolla,
California.
Chien, C.H., D. Goldsman, and B. Melamed (1997). Large-sample results for batch means,
Management Science, 43, 1288-1295.
Chow, Y.S., and H. Robbins (1965). On the asymptotic theory of fixed-width sequential
confidence intervals for the mean, Ann. Math. Statist., 36, 457-462.
Fieller, E.C. (1954). Some problems in interval estimation, J. Roy. Statist. Soc., Series B, 2,
175-185.
Fishman, G.S. (1978). Principles of Discrete Event Simulation, Wiley, New York.
Fishman, G.S. (1996). Monte Carlo: Concepts, Algorithms, and Applications, Springer Verlag,
New York.
Fishman, G.S., and L.S. Yarberry (1997). An implementation of the batch means method,
INFORMS J. on Comput., 9, 296-310.
6.14. REF ERE NeE 5 293
Law, A.M. and W.D. Kelton (1991). Simulation Modeling and Analysis, McGraw-Hill, New
York.
Goldsman, D., and M.S. Meketon (1986). A comparison of several variance estimators for
stationary increment stochastic process, Technical Report, School of Industrial and
Systems Engineering, Georgia Institute of Technology.
Kelton, W.D., R.P. Sadowski, and D.A. Sadowski (1998). Simulation with Arena, McGraw-Hill,
New York.
Philipp, W. and W. Stout (1975). Almost sure invariance principles for partial sums of weakly
dependent random variables. Mem. Am. Math. Soc., 2.
Song, W.T. and B.W. Schmeiser (1995), Optimal mean-squared-error batch sizes, Man. Sci.,
41,110-123.
von Neumann, J. (1941). The mean square difference, Ann. Math. Statist., 12, 153-162.
Yarberry, 1.S. (1993). Incorporating a dynamic batch size selection mechanism in a
fixed-sample-size batch means procedure, unpublished Ph.D. dissertation, Dept. of
Operations Research, University of North Carolina, Chapel Hill.
Young, 1.c. (1941). On randomness of order sequences, Ann. Math. Statist., 12,293-300.
CHAPTER 7
different operating scenarios. Recall that a scenario denotes a set of specific values assigned
to input parameters and a collection oflogical system-operating rules.
As illustration, consider the airline reservation problem and the waiting-time results in
Section 4.22 for m = 4 and 5 reservationists with first-come-first-served queueing discipline.
Suppose management is willing to increase the number of reservations from four to five if
that action reduces mean waiting time by at least three minutes and if the proportion of
customers who wait is cut by .30. To make this an informed decision, an analysis needs to
assess how credible each difference is individually and how credible they are when taken
simultaneously. Section 7.1 describes the details.
This example illustrates issues that arise in many studies that examine simulated be-
havior for different values of input parameters or different operating rules. The issues are the
comparison of results generated on different experiments and the simultaneity of multiple
confidence statements made about these results. This chapter describes statistical procedures
for making these comparisions and simultaneous confidence statements. It presents them in
the special context in which a simulationist may wish to use them when analyzing simula-
tion output. Collectively, we refer to these procedures as credibility analysis, an elusion to the
frequent need, in making a decision, to assess how plausible it is to assume that a difference
of a particular magnitude actually exists.
Although space limitations restrict our discussion to the most basic of these issues, the
exposition addresses problems that a simulationist frequently encounters when preparing a
report for a management choosing among alternative resource configurations or operating
modes. Within the considerable statistical literature on these topics, Bechhofer et al. (1995)
provides a comprehensive account of the technical issues with special emphasis on selecting
the best among alternative systems. Matejcik and Nelson (1995a, 1995b) give one typl~ of
analysis of multiple comparisons within the special context of discrete-event simulation.
When a simulation study focuses on the difference between two sample averages each
generated under a different scenario, Section 4.22 shows how common pseudorandom num-
bers (cpn) can induce a higher level of statistical accuracy than would arise for independent
runs. The discussion there concentrates on the mechanics of implementing cpn. Section 7.7
and, in particular, 7.7.1 return to this subject, focusing on how some differences in input
scenarios tend to favor substantial variance reductions whereas others do not.
Sections 7.8 through 7.10 then introduce the reader to a second variance-reducing
technique. It is based on optimal-sample-path length (opt) for independent runs. The ac-
count reveals when opt induces a smaller variance for the difference of sample averages than
cpn and when the reverse occurs. In particular, a large disparity in individual sample-average
variances tends to favor opt over cpn.
Many other methods exist for reducing variance, including control variates, stratified
sampling, and antithetic variates; see, e.g., Fishman (1996) and Law and Kelton (1991). The
present account discusses only cpn and opt for several reasons. First, they are the two that
address differences in averages. Second, they each require a modest amount of effort to
implement. Third, space considerations limit what can be covered under this topic.
7.1. SIMULTANEOUS CONFIDENCE STATEMENTS 297
In what follows, we repeatedly make use of d.f.s and inverse d.f.s. Recall that <I> (. )
denotes the d.f. of a random variable from N(O, 1), and <1>-1(.) denotes its inverse. Also,
define G d (.) as the d.f. of a random variable from Student's t distribution with d degrees of
freedom and Td (.) as its inverse.
(7.1)
As an example, suppose that r parameters ILl, ... , ILr have been estimated by confidence
intervals. If Ai denotes the event that the ith confidence interval includes the ith unknown
ILi with probability
pr(Ai) = 1 - a,
then
(7.2)
How does simultaneity affect the lengths of the confidence intervals? For large numbers
of degrees of freedom (e.g., Section 6.6), interval length is proportional to <1>-10 - a/2).
Then
<1>-1 (0 + 0 - 8)I/r)/2)
v(8 r) .- ------'------,---------'-- (7.3)
,.- <1>-1 (1 - 8/2)
gives the ratio of simultaneous to individual interval lengths. For r = 2, v (.01, 2) = 1.089
and v(.05, 2) = 1.14l. For r = 11, v(.OI, 11) = 1.287 and v(.05, 11) = l.444. These
numbers indicate that claiming simultaneous coverage without correcting interval lengths
results in an overestimate of accuracy that increases with r for a given 8. For example,
v(.OI, 11) = l.287 implies that the simultaneous interval lengths should be 28.7 percent
longer.
298 CHAPTER 7. MAKING SENSE OF OUTPUT AND INCREASING EFFICIENCY
When two or more confidence intervals are computed from data generated on the same
simulation run, they are rarely independent, and expression (7.1) does not apply. Section
6.8 illustrates this case, where Figure 6.12a displays a 99 percent confidence interval for each
of the 11. exceedance probabilities, pre W > w), for waiting time for the airline reservation
problem using Series = w + 2 for w = 0,1, ... , 10 minutes. While characterizng the
quality of each corresponding point estimate separately, these intervals do not make a single
statement regarding all 11 point estimates taken together. Moreover, since they are based on
the same data, the intervals are dependent. To address this issue, we resort to simultaneous
confidence intervals based on Bonferroni's inequality.
Let Ai denote the event that Ai does not occur. In the present case, we may think of
Al as the event that the confidence interval for Series 2 on review 15 in Figure 6.12a covers
pr(W > 0), A2 as the event that the confidence interval for Series 3 on review 15 covers
pr(W > 1), etc. From the law of total probability,
and from the observation thatpr(Al' A 2)+pr(A 1 , A 2) = pr(A 2) and pr(A 1 , A 2) :::: pr(,4 1 ),
we have
This is a lower bound on the probability that both Al and A2 occur simultaneously.
Let B2 := Al n A 2. Then
and
so that
which is called Bonferroni's inequality. Since pr(Br ) = pr(A 1 , ••• , Ar), we have a lower
bound for all r events occurring simultaneously.
Again, let Ai denotes the event that the ith confidence interval includes the ith un-
known mean f.1,i with pr(Ai) = 1 - a. Then inequality (7.4) implies that simultaneous
coverage for j = r is at least 1 - ra. To achieve a 1 - 8 simultaneous confidence level, we
choose a as
a = 8/r, I (7.5)
For r = 2, v'(.OI, 2) = 1.090 and v'(.OS, 2) = 1.144. For r = 11, v'(.OI, 11) = 1.288 and
v'(.OS, 11) = 1.448. The ratios reveal that the interval lengths increase at roughly the same
relative rates as their corresponding ratios in the independent case. However, it is easily seen
that cp-1(1 - 8/2r) - cp ((1 + (1- 8)1/r)/2) increases with r.
For the 11 confidence intervals for exceedance probabilities in Figure 6.12a, pr(A i ) =
.01, so that
- Z- 8
(7.6)
Z(8):= Ja'&,(Z)/t'
- Z'-cp
Z' (A.) .- ~=o===;:= (7.7)
'I-' .- /a'&,(Z')/t'
300 C HAP TE R 7. M A KIN G SEN 5 E 0 F 0 U T PUT AND INC REA 5 I N G E FFie lEN C Y
with e := EZ and cp := EZ', each have degrees of freedom in excess of 100 (determined by
LABATCH.2), so that treating each as from N (0, 1) introduces negligible error.
Under the hypothesis HI(e') : e = e', the probability of the event
Al (e') := event of observing aN (0, 1) random variate no less than Z(e') in value
IS
pr[AI(e')] = <I>(Z(e')).
Az(cp') := event of observing aN (0,1) random variate no less than Z'(cp') in value
IS
pr[Az(cp')] = <I>(Z'(cp')).
Then for the joint event Bonferroni's inequality gives the lower bound
This lower bound gives considerable credibility to HI (3) n Hz (.30). However, suppose
that management is willing to increase the number of reservationists by one only if e' = 3
and cp' = .36. Then
which gives considerably less support for the joint hypotheses HI (3) n Hz (.36). Most impor-
tantly, it can alert management to the greater risk of error in assuming e' = 3 and cp' = .36
than assuming e' = 3 and cp' = .30.
The next section extends this form of credibility analysis as a function of increasing
mean difference.
The airline example of the last section compares mean waiting times for four and five
reservationists. The illustration takes advantage of the dependence induced by common
7 .2. COM PAR I N G Tw 0 MEA N S 301
pseudorandom numbers to reduce standard errors. This section addresses the more general
case of independence of results across experiments and replications. Section 7.5 further
extends these ideas to the case of single replications under each scenario. Section 7.7 returns
to the approach based on common pseudorandom numbers.
Recall that Section 6.1 defines Xt~l as the sample average of tl observations collected
sequentially on sample path i after deleting kl - 1 observations to reduce the influence
of initial conditions. Moreover, for nl independent replications expression (6.4) defines
X := Xklnltl as the arithmetic average of Xk~;l' ... , xt:l) , and expression (6.8) defines
S2(~) := sflnltl as the sample variance of an Xt~l' so that s2(X)/nl is an estimate of
varXklnltl'
By analogy, let Y denote the grand sample average and S2 (Y) the sample variance of the
sample averages Yk~I;" ... , Yi;t~) collected on n2 independent replications of the simulation
generated under a different scenario than for the first nl replications. Note that the first
set of replications each delete kl - 1 observations and use tl observations to compute each
Xt~l ' whereas the second set deletes k2 - 1 observations and thereafter uses t2 observations
to compute each Yi:;,. Presumably, kl and k2 reflect differences in the rates at which the
influences of initial conditions dissipate under the two different scenarios, and tl and t2
reflect differences associated with computing costs and possibly differences due to sampling
variation along sample paths. Assume that tl and t2 are sufficiently large so that we may
regard each Xt~l and each yi:;, as approximately normally distributed.
Comparing the sample averages X and Y is a commonly encountered objective in
simulation studies. Recall that X and Yare estimates of long-run averages /Lx and /LY,
respectively, and it is ofinterest to assess the extent to which /L x and /L Y differ as a consequence
of different scenarios in each experiment. An approximating 100 x (1- 8) percent confidence
interval for /Lx - /LY is
(7.8)
where
d = d(c, n, n2):=
[f;2 (1-
-- + ---
f;?]-I (7.9)
nl - 1 n2 - 1
with
gives the degrees of freedom for the critical value of Student's t distribution.
If varXi/tl = varYi;;, and nl = n2, then (X - Y)/ [s2(X)/nl + s2(Y)/n2r/2 has
Students's t distribution with nl + n2 - 2 degrees of freedom, and no issue of approximation
arises other than the assumption of normality. When either or both of these conditions
302 CHAPTER 7. MAKING SENSE OF OUTPUT AND INCREASING EFFICIENCY
are absent, this statistic does not have Student's t distribution with nl + n2 - 2 degrees
of freedom. Then, expressions (7.8 ) and (7.9 ) comprise Welch's sug~ested approach to
approximating the distribution of eX - Y)j [s2(X)jnl + s2(Y)jn2]1/ . See for example,
Kendall and Stuart (1961, vol. 2) and Scheffe (1970). Section 7.3 describes the basis for this
approximation.
o ExAMPLE 7.1
As illustration, consider two variants of a queueing system, the first ofwhich produces a
sample average waiting time X = 12.94 hours with sample variance S2 (X) = 30.43 based on
n 1 = 15 independent replications and the second ofwhich produces a sample average waiting
time Y = 8.734 hours with sample variance S2(y) = 15.07 based on n2 = 10 independent
replications. Then X - Y = 4.206 hours, and expression (7.8) yields an approximating 99
percent confidence interval [-1.094,9.506] for f,tx - f,ty based on d = 22.89 degrees of
freedom.
Cost considerations, external to the simulation study, lead management to conclude
that the operating environment that generated Y~21i" ... , Y~;t~) would be preferable to the one
that generated Xk:~2' ... , xt:! if f,tx ~ f,ty :::: 2. Therefore, management wants to know the
extent to which the simulation output provides evidence that this inequality indeed holds.
We first study this issue in a more general setting.
Let
and take the Student t distribution with d = 22.89 degrees of freedom as the approximating
distribution for Z(f,tx - f,ty). Given X, Y, s2(X)jnl> and s2(Y)jn2' suppose it is of interest
to determine how credible it is to assume that f,tx - f,ty :::: v for some specified v. Under the
hypothesis H(O) : f,tx - f,ty = 0, let
Then
pr [A(O)] = Gd(Z(O)),
where Gd(Z(O)) gives the probability of observing a standardized statistic no greater than
Z(O). Moreover, Gd(Z(O)) decreases monotonically with increasing O. Hence, GAZ(O))
provides a measure of credibility for f,t x - f,t y :::: O. The graph of this function in Figure
7.1 is revealing. It indicates Gd(O) = .87 for 0 = 2 hours, thus providing support for
7.3. RA T ION ALE FOR DE G RE E S 0 F FRE E D 0 M 303
management's action. However, if the decision point had been 8 = 4 hours, Figure 7.1
would offer considerably less support for the scenario that generated yi:;" ... , Yk~~~)'
To evaluate the credibility of {Lx - {Ly :s 8, we use 1 - Gd(Z(8)), the probabil-
ity of observing a standardized statistic no less than Z(8) under H(8). This probability
monotonically decreases with decreasing 8.
D
Let us now reflect on this form of credibility analysis. Graphically, it provides consid-
erably more food for thoughtthan a report that merely displays point estimates and, possibly,
standard errors. In particular, it allows management to assess the plausibility of conjectured
differences in means that are pivotal to its decision making. Most importantly, the graphics
are easily created with application software such as Microsoft Excel.
Expression (7.9) for degrees of freedom may well arouse the reader's curiosity. This section
describes its rationale. A reader willing to accept these dJ.s may proceed directly to Section
7.4.
Since we assume that tl and t2 are sufficiently large so that xk:l j , and
••• , xt:!
Y2!', ... ,YL~!) are normally distributed, X and s2(X) are statistically independent, (nl -
1)s2(X)/varXk:lj has the chi-squared distribution with nl - 1 degrees of freedom, denoted
by x 2(nl -1), and (X - {Lx)/ Js2(X)/nl has Student's t distribution withnl -1 degrees of
freedom, denoted by T(nl - 1). Likewise, y, S2(Y) are independent, (n2 - 1)s2(Y)/varYk~;2
is from x2(n2 - 1), and (Y - {LY)/Js2(Y)/n2 from T(n2 - 1).
But what about the standardized difference
If varXk:~j = varyi:l, and nl = n2, it is from T(nl + n2 - 2). However, this equality of
variances rarely arises in simulation practice. Welch's solution to this problem relies on
properties of the chi-squared distribution; in particular, a chi-squared variate Z with 1
degrees of freedom has EZ = 1 and var Z = 2/.
Therefore,
2E 2 Z
1--- (7.10)
- varZ'
304 CHAPTER 7. MAKING SENSE OF OUTPUT AND INCREASING EFFICIENCY
d= 22.89
0.8 +----------'~-----------__l
0.6
0.4
0.2
a
a 2 3 4 5 6
e
Figure 7.1 Credibility analysis for J-Ll - J-Lll > () in the photocopying problem
(Section 1.4)
Welch employs this equivalence to derive approximate degrees of freedom. Let a := var xt~l
and b := var Y~::2' Since
and
d(c,nb n 2) = [ --
C2
+
(1- C)2]-1 ,
nl - 1 n2 - 1
._ a/nl
c.- ,
a/nl + b/n2
and d(c, n, n2) in expression (7.11 ) is an estimate of this quantity with S2(X) and s2(y)
replacing a and b, respectively.
7 .4 . RAT loA N A LY 5 I 5 305
7 .4 RATIO ANALYSIS
Assume that X and f are independent and normally distributed with variances a/n] and
b/n2, respectively. Occasionally, it is of interest to estimate the relative difference R :=
f.L yj f.L x, assuming f.L x i= O. Since f - R X is normally distributed with mean zero and
variance b/n2 + R 2a/nJ> we have by analogy with the development in Section 6.11
~ 1-8, (7.11)
(7.12)
and compute an approximating 100 x (1- 8) percent confidence interval for R. The rationale
for this choice of d comes from the observation that
and
which, by analogy with the equivalence (7.10), leads to an approximating number of degrees
of freedom
b2 a2
4 +----;-4----
f.Ly(n2 - l)n2 f.Lx(n] - l)n]
where
and
.. a~(X)/tl
c := a~(X)/tl + a~(Y)/t2'
and expression (7.9) defines d(·, ., .).
As before, d varies with c, from a minimum ofmin(LJ(/,), LJ(/,) - 1 to a maximum
of LJ(/,) + LJ(/,) - 2. Setting d = min(LJ(/d, LJ(/,) - 1 would again lead to a wider
confidence interval and thus militate against any tendency to induce a coverage rate less than
1 - 8 because of the inherent approximations in the degrees of freedom.
decision making. When two scenarios are being compared, the accounts in Sections 7.2 and
7.4 provide a basis for accomplishing this. When there are more than two, organizing the
results becomes a greater challenge.
Formalisms exist in the statistical literature for making these multiple comparisons.
Banks et al. (1996, Chapter 13) and Law and Kelton (1991, Chapter 10) address these issues
within the special context of discrete-event simulation. The present account takes a more
illustrative approach, focusing on a particular example to describe concepts. The presump-
tion is that the particular issues raised in the example carryover to other problems studied
by discrete-event simulation. Our account is based on the concepts of simultaneity (Section
7.1) and the analysis of pairwise differences (Sections 7.2 and 7.4).
Recall that the purpose of the library photocopying simulation study in Section 1.4
was to assess the extent to which alternative operating policies affect long-run patron waiting
time. At current demand rates, these included:
SCENARIO
11 Replace two copiers on the third floor and two on the fourth floor with new copiers.
The replaced copiers have the highest failure rates.
The study also examined these scenarios with a fifty percent increase in demand (these
are Scenarios 2, 4, 6,8, 10, 12). Here we address only the current-demand case. Moreover,
we focus on Group 3 (Table 1.1), the time interval from 11 a.m. to 4 p.m., the busiest on a
daily basis.
Let f..ti denote long-run patron waiting time for Scenario i, so that interest focuses on
estimating f..tl, f..t3, f..ts, f..t7, f..t9, f..tll and comparing their point estimates. For each scenario,
a single run of t = 1000 weeks was made. This corresponds roughly to 20 years of weekday
operation. For each Scenario 2i -1 E {I, 3, 5, 7, 9, Il}, a sample average waiting time P,Zi-l
was estimated. Because the elapsed run time was fixed, the number of sample waiting times
in this average was random, so that P,Zi-l was a ratio estimate (Section 3.4). However, its
denominator had a coefficient of variation considerably smaller than that of its numerator,
and hence ignoring the randomness in the denominator introduced negligible error. This
308 CHAPTER 7. MAKING SENSE OF OUTPUT AND INCREASING EFFICIENCY
was true for all scenarios. See Section 6.11 for details of ratio estimation and, in particular,
on how to assess the importance of randomness in a denominator.
Table 7.la displays summary results for 1l2i-1 for i = I, ... ,6. The quantity &~ 2i-1
denotes an estimate of t varll2i-1 computed by LABATCH.2 and degrees of freedom are
one less than the number of batches determined by LABATCH.2. See Section 6.6. Although
the run length of 1000 weeks resulted in relative errors considerably larger than the .20
that Section 6.6.1 regards as desirable, the large number of runs dictated this limitation on
length. For visual comparison, Figure 7.2 displays the approximating 99 percent confidence
intervals.
NATURAL ORDERING
merely based on the knowledge that waiting time diminishes with decreasing failure rate
and/or adding resources. Therefore, the analysis principally focused on how large the
difference f.l-I - f.l-j is for f.l-I > f.l-j.
Table 7.lb gives estimates of differences between long-run average waiting on the
baseline Scenario I and the remaining five scenarios (Section 7.4). Of principal interest is
f.l-I - f.l-3, the greatest possible reduction in long-run average waiting time that can materialize
without adding or reassigning resources. Ofcourse, this is an ideal, since all copiers eventually
break down. Nevertheless, it is instructive to note that III - 113 = 3.635 minutes with an
approximating 99 percent confidence interval [2.656,4.613].
Table 7.1 b also reveals that reassigning old copiers and adding a single new copier to
the fifth floor (Scenario 7) induced an estimated reduction of III - 117 = 2.092 minutes
with approximating 99 percent confidence interval [.4242,3.759]. Also, adding two new
copiers on the third and also on the fourth floor (Scenario 11) induced a reduction of
III - Illl = 2.828 minutes with approximating 99 percent confidence interval [1.806, 3.849].
Recall that the structure of the problem allows no a priori inference regarding Scenarios 7
and II. Although the point estimates seem to favor Scenario 11 over Scenario 7, the overlap
in their confidence intervals raises a question.
The entries in Table 7.1 c for 117 - III I suggest that with current sample sizes a significant
difference between f.l-7 and f.l-ll is not supportable. We return to this issue presently. First, we
note that Table 7.ld estimates the difference f.l-3 - f.l-ll by 113 - Illl = -.8089 minutes with
approximating 99 percent interval [-1.221, -.3923], suggesting that it is not unreasonable
to expect Scenario II to reduce long-run average waiting time by at least 2 of the estimated
3.635 minute reduction achievable under the perfect-copier Scenario 3.
7.6. MULTIPLE COMPARISONS 309
Q) 6
E
:;:::;
g>5
:;:::;
.(tj
~ 4
Q)
en
as
....
I
Q)
3
~
c::
~ 2
en
c::
0
...J
1 -
0
3 5 7 9 11
Scenario
Implementing Scenario 7 would result in a smaller immediate capital cost than Sce-
nario 11. However, there is an issue of how much better it is than Scenario 1 and how much
benefit one gives up by not choosing Scenario 11. To shed light on this problem, consider
two hypotheses:
If HI and H2 were true, then Scenario 7 would induce a reduction of at least two minutes in
long-run average waiting time and would be within one minute of the average that would
obtain with Scenario 11. We now examine the credibility of these hypotheses.
For (i, j) = (1, 7) and (7, 11), let
Table 7.1 Long-run average waiting-time analysis for photocopying problem in Section 1.4
(time in minutes)
(a)
Relative error
Sample Standard 99%
Upper-Lower
mean error Confidence interval lil,l
fii .,j8-"!x,dt dJ. Lower Upper
(b)
Upper-Lower
fil - fii .,j8-"!x,1 + 8-"!x,i)/t c lil,-ilil
3 3.635 .3203 .9976 12.06 2.656 4.613 .5384
(c)
Upper-Lower
fi7 - fill J(8-"!x,7 + 8-"!x,.II)/t lil,-illli
(d)
and
Then
and
Table 7.2 gives these probabilities for selected 0 and <p. While there is some support
for ILl - 1L7 ~ 2 and 1L7 - 1L11 ::::; 1, there is considerably more for ILl - 1L7 ~ 1.5 and
1L7 - 1L11 ::::; 1.
Table 7.2 Credibility analysis for photocopier problem for long-run average waiting
time (minutes: seconds)
revealing that max (h, 1/ h) and p determine the level of variance reduction. In particular, for
given p, YRcpn increases monotonically as max(h, 1/ h) increases, thus limiting the appeal
of cpn. If p < 0, then variance inflation occurs, and cpn is to be avoided. Hereafter, we
assume p 2: O.
The quantity 100 x (1 - .JVRcpn) gives the percentage reduction in the length of
a confidence interval when cpn, rather than independent runs with tl = t2, is used. Table
7.3 displays 1 - JVRcpn as a function of selected hand p. For equal asymptotic variances
(h = 1), it reveals a 68 percent reduction for p = .90. However, max(h, 1/ h) = 10 leads
to only a 9.3 percent reduction for this same p. For p = .50 the reductions are 29.3 and 5.1
percent for max(h, 1/ h) = 1 and 10, respectively.
Recall that cpn in Section 4.22 estimates tVcpn = O'&,(Z) by &&,(Z), computed by
LABATCH.2 using the combined sample-path data Zi := Xi - Yi for i = 1, ... , t. Using
the sequence of differences in this way captures the correlations between XI, ... , XI and
Y I , •.. , Yt in a single variance correlation. However, expression (7.13) no longer applies for
7.7. COMMON PSEUDORANDOM NUMBERS REVISITED 313
degrees of freedom. In this case treating (X - Y)/ J(i~(Z)/t as a Student t variate with
degrees offreedom one less than the number of batches used to compute a~(Z) allows one
to compute an asymptotically valid 100 x (1- 8) percent confidence interval for /Lx -/LY.
A( )
p X Y =
a~(X) + a~(Y) - a~(Z) = .8656,
, 2Ja~(X)a~(Y)
a relatively small loss from .8906. Note that in this particular problem at least 50 percent of
the service times match regardless of the value of PI and P2.
Suppose the two runs were made with the same values for w, p, and m but two different
values of A, namely Al and A2. Then customer i has the same service time on each run, but
its intercall times differ. The extent to which this difference militates against a variance
reduction depends on the particular distribution being sampled and on the method used to
generate intercall times. Recall that intercall times in the example come from £(1/A).
314 CHAPTER 7. MAKING SENSE OF OUTPUT AND INCREASING EFFICIENCY
Let VI and V2 denote customer i's intercall times on the runs with Al and A2, respec-
tively. If the inverse transform method (Section 8.1) were used to generate these quantities
with the same uniform deviate U E (0, 1), then
1
VI = - Al In(I - U),
1
V2 =- A2 In(I - U),
so that
implying
corr(VI , V2 ) = 1.
We see that corresponding intercall times differ on the two runs but are nevertheless perfectly
correlated. While not as favorable as inducing the same intercall times, perfect positive
correlation contributes to a positive correlation between the output on the two runs, thus
continuing to give a benefit.
But what if a method other than the inverse transform method were used to generate
intercall times? With the exponential distribution, we are in luck. Recall from Section 8.9 that
all algorithms for sampling from E(I/A) actually sample from E(1) and then multiply the
result by 1/ A, thus ensuring perfect correlation. More generally, perfect correlation between
VI and V2 arises regardless of distribution if the number of uniform deviates required to
generate VI is independent of the intercall time parameters and V2 is computed as V2 =
a VI +b forsomea > Oandb. This includes samplingfromE(I/A) withvaryingA, N (fl, 0'2)
with varying fl and 0'2, gca, f3) with varying f3 but the same a, and W(a, f3) with varying
f3 but the same a. It also applies to the inverted Gamma and inverse Weibull distributions
for varying f3.
Suppose intercall times are drawn from Q(al, f3) and Q(a2, f3) on the two runs using
Algorithm GKM3 (Section 8.13) based on the ratio-of-uniforms methods (Section 8.6).
Recall that this method uses a random number of uniform deviates to generate samples. If
al = a2 and the same seed is used on the two runs, then both use the same pseudorandom
number deviates, and the seeds for the next generation are identical. However, if al =f:. a2,
generation of the two runs may require different numbers of uniform deviates so that the
seeds for the next generation differ. Then synchronization of pseudorandom numbers, so
vital to inducing positive correlation, is lost. In practice, it is ill advised to use the same seed
in this case, lest the practice unintentionally induce a negative correlation.
What about different logical operating rules? These include job routing through a
system and job selection for service. For example, suppose one run takes jobs for service in
7.S. OPTIMAL SAMPLE-PATH LENGTHS 315
the order of arrival, whereas the second run takes them in reverse order. As a consequence, we
anticipate that the waiting times for customer i on the two runs are negatively correlated, so
that sample average waiting times are negatively correlated, and therefore their difference has
larger variance than would arise for independent runs. Interestingly, the long-run average
waiting times are identical for both queueing disciplines.
Unless the implications for induced correlation are known and favorable, it is gener-
ally advisable to use independent runs, rather than cpn, when comparing different logical
operating rules.
What if we are comparing several sample averages as in Section 7.6? For pairwise
comparisons, the discussion in these sections continues to apply with the variance of each
pairwise difference being estimated as in Section 4.22 and simultaneity entering as in Section
7.l.
2th 2t
and
1 +h
t ---
1-
t ---
2 - 1 +h
(7.16)
Vopt
-
:= var(X - Y)
-
= [O'oo(X) + O'oo(Y)] 2 /2t
and variance reduction
var(X - Y)
VRopt := ----=----=- (7.17)
varX+varY
Table 7.3 shows the reduction in interval length that opt induces for selected
max(h, 1/ h). Clearly, there is a crossover point at which opt offers more of a reduction
than cpn. In particular,
As illustrations,
P 1 + 2p + 2J p(1 + p)
0 1
.25 2.618
.50 3.297
.75 4.791
.90 5.415
.95 5.622
1.0 5.828.
In particular, note that for all p E (0, 1) opt induces smaller variance than cpn if
max(h, 1/ h) > 5.828. Also, ! :::
YRopt ::: 1 with
~->{
1 asmax(h, l/h) --+ 1,
1
asmax(h, l/h) --+ 00,
2
Clearly, cpn with t1 = t2 = t has its greatest advantage when variances are equal,
!
whereas opt, with t1 + t2 = 2t, achieves its best variance reduction of when a~(X) and
a~(Y) differ substantially. The opt variance-reducing technique does have the limitation
that h is unknown and, in principle, must be estimated in some way. We defer discussion of
this issue until Section 7.10
Because of the independence of the sample paths X I> ... , XI, and YI> ... , Y12 , expres-
sion (7.13) can be used to estimate degrees of freedom for (X -y)/ Ju'&,(X)/t1 + u'&,(Y)/t2,
and an asymptotically valid 100 x (1 - 8) percent confidence interval can be computed for
JLx - JLy.
The foregoing discussion assumes that generating costs per observation are identical, or close
to identical, on each scenario. Cost is customarily measured in terms of cpu time expended
per simulation observation. If these costs differ substanially, then we need to reformulate
the opt approach and its comparison to cpn.
7.9. UNEQUAL SAMPLING COSTS 317
0 0 0
.25 .l340
.50 .2929
.75 .5000
.90 .6838
.95 .7764
1.0 1.0
2 .05l32 0 0
.25 .1056
.50 .2254
.90 .4709
.75 .3675
.95 .5101
1.0 .5528
4 .1425 0 0
.25 .06066
.50 .1255
.75 .1956
.90 .2407
.95 .2564
1.0 .2724
10 .2260 0 0
.25 .02507
.50 .05080
.75 .07724
.90 .09348
.95 .09896
1.0 .1045
318 CHAPTER 7. MAKING SENSE OF OUTPUT AND INCREASING EFFICIENCY
Let b l and b2 be the unit costs on runs 1 and 2, respectively, and suppose a total budget
constraint
and (7.18)
with
_ b
Vopt -
1 [ b 1/2 O"oo(X) + b21O"oo(Y)
/2]2 ,
l
As immediate consequences,
1 + bl as h-+O i.
b2
1 + b2 as h -+ 00 ii.
bl
bl
h 2 - 2ph +1 as - -+ 0
b2
iii.
vcpn
--+ bl
Vopt 1-2p/h+l/h 2 as - -+ 00 iv.
b2
(h 2 + 1)(1 + bI/b2)
as p -+ 0 v.
(hb~/2 /by2 + 1)2
(h - 1)2(1 + bI/b2)
as p-+l. vi.
(hb~/2 /b~/2 + 1)2
Limits i, ii, and v indicate that opt induces smaller variance than cpn. Limit iii shows
that opt leads to a smaller variance for p < h /2 and a larger variance for p > h /2. Therefore,
! !
limit iii favors opt for all h > 2. Conversely, limit iv favors opt for p < h and cpn for p > h.
This implies cpn for all h < 2.
Limit vi gives cpn its greatest potential advantage with regard to correlation.
Nevertheless, opt induces a smaller variance if
where
• For fixed p and g, opt gives the greater variance reduction for sufficiently large h.
• For fixed hand p, cpn gives the greater variance reduction for sufficiently large g.
• For fixed hand g, cpn gives the greater variance reduction if h > 1 + g + g1/Z +
J(l + g)Z + 2g1/z(l + g) for all p E [0,1].
• For fixed h and g, opt gives the greater variance reduction if h > g1/Z as p ~ o.
(7.20)
320 CHAPTER 7. MAKING SENSE OF OUTPUT AND INCREASING EFFICIENCY
a;,(X) 100
a;,(Y)
80
P =.50
60
40
p=.25
20
p =0
0
0 0.5 1.5 2 2.5 3 3.5 4
2
(foci:=
1.1m tivafl.Li,
A
ti~OO
7.12. L E S SON S LEA RNED 321
and
i = 2, ... , r.
If cost per observation is the same on all r runs, then for fixed rt = t] + ... + t" choosing
rt
t] = ,
1 + 1/ h2 + ... + 1/ hr
t]
tj = - j = 2, ... , r,
hj
gj := ~, j = 2, ... , r.
and
t]g]
tj = h-' j = 2, ... , r,
J
minimizes all var(!L] - !Li) for i = 2, ... , r. See expression (7.18). The commentary in
Section 7.11 regarding estimation of g and h continues to apply here.
• In computing a confidence interval for the difference of means based on two inde-
pendent runs made with different input scenarios, Welch's approximation provides a
means for computing degrees of freedom.
• Simultaneous confidence statements about pairwise differences for multiple runs, each
with a diferent scenario, provide a basis for weaving a coherent story about what the
data show.
322 CHAPTER 7. MAKING SENSE OF OUTPUT AND INCREASING EFFICIENCY
• Common pseudorandom numbers (cpn) can reduce the variance of the difference
of sample averages computed from simulation runs executed under different input
scenarios.
• The potential variance reduction of cpn decreases as the variances of the individual
sample averages diverge.
• opt also applies to multiple comparisons of pairwise differences in means where one
mean is common to all differences.
7.13 EXERCISES
QUARRY-STONE CRUSHING (EXERCISE 6.2)
~ 7.1 Exercise 6.2 provides estimates oflong-run average profit as a function of A, the
arrival rate of external deliveries to the crusher. Presumably, these estimates have allowed you
to estimate Amax> the rate that maximizes long-run average profit. For institutional reasons,
management is inclined to choose A = .15 as the permissible arrival rate, provided that this
action results in no more than a 1.5 cent reduction in profit per ton.
a. Let p(A) denote long-run average profit at rate A. Determine the credibility of the
hypotheses
~ 7.2 The port authority wants to reduce ILr, the average rebate per tanker. One plan to
do so replaces the tug by a new one that takes £ ( ~) time to berth an empty tanker, and £ ( ~ )
time to deberth a full tanker, and £ ( ~) to deadhead in either direction. As before, times are
in hours. Let ILr(old) and ILr,(old) denote the quantities estimated in Exercise 6.4 with the
old tug and let ILr (new) and ILr' (new) be the average rebates with the new tug.
7.13. Ex ERe I S E S 323
a. Rerun Exercise 6.4 with these new times to estimate J.Lr(new) and J.Lr' (new). Since the
system now has less congestion, the warm-up interval estimated in Exercise 6.3 should
suffice.
b. Perform an analysis to determine the credibility of J.Lr(old) - J.Lr (new)::::: dJ.Lr( old) for
each dE [.2, .75].
c. Perform an analysis to estimate how large management can expect the reduction in
J.Lr,(old) - J.Lr,(new) to be. What does this analysis reveal about waiting patterns for
the old and new tugs?
~ 7.3 This exercise provides an opportunity to evaluate the benefits of common pseu-
dorandom number streams for the case of rn = 8 maximal characters in a packet. Part a
establishes a baseline against which the results in part b, based on common pseudorandom
numbers, can be compared. Let ~min denote your estimate of A that minimizes mean delay
J.L(A, 8) in Exercise 6.6.
a. Use the results of the runs in Exercise 6.6 to compute point and 99 percent interval
estimates for the difference in mean delay J.L(A, 8) - J.L(~min, 8) for each (A =f=. ~min)
used for rn = 8.
b. Repeat the simulation runs for all A with the seeds used for the run with A = ~min
in Exercise 6.6 being the common pseudorandom numbers seeds on all runs. As a
consequence, results for the different A are correlated. Use these data to compute
point and 99 percent interval estimates of J.L(A, 8) - J.L().min, 8). Then for each fixed Ai
compare the statistical accuracies of those differences with those computed in part a.
~ 7.4 The set C = {.Ii; i = 1, ... , 9} of cost evaluation points in Exercise 6.7 is in-
tended merely to provide a perspective on the best choice of r for each rn. In reality, cost c takes
some value in (0, 1) but is unknown. Suppose management has the prior Beta distribution
Be(3, 1.11) (Section 8.14) for c.
b. For each (rn, r), compute an approximating 99 percent confidence interval for each
C(rn, r) and for the function {CCrn, r), r = 0,1, ... , rn - 2}.
324 C HAP TE R 7. M A KIN G SEN 5 E 0 F 0 U T PUT AND INC REA 5 I N G EF Fie lEN C Y
and
One approach, called Alternative A, to system specification for fixed m chooses r min (m ).
An alternative approach, called Alternative B, makes use of the piecewise constant
function {rmin(m, c), C E C}, where for each r E to, 1, ... ,m - 2}
d. For each m, compute the expected cost of Alternative R Hint: Start by computing the
probabilities of choosing each r for r E to, 1, ... ,m - 2}.
7.14 REFERENCES
Banks, J., J.S. Carson, III, and R L. Nelson (1996). Discrete-Event System Simulation, second
edition, Prentice-Hall, Upper Saddle River, New Jersey.
Bechhofer, R.E., T.J. Santner, and D. Goldman (1995). Design and Analysis for Statistical
Selection, Screening and Multiple Comparisons, Wiley, New York.
Fishman, G.S. (1996). Monte Carlo: Concepts, Algorithms, and Applications, Springer-Verlag,
New York.
Kendall, M.G., and A. Stuart (1961). The Advanced Theory ofStatistics, 2. Hafner, New York.
Law, A.M., and W. D. Kelton (1991). Simulation Modeling and Analysis, second edition,
McGraw-Hill, New York.
Matejcik, F.J., and RL. Nelson (1995a). Two-stage multiple comparisons with the best for
computer simulation, Operations Research, 43, 633-640.
7.14. REF ERE NeE s 325
Matejcik, EJ., and B.L. Nelson (l995b). Using common random numbers for indifference-
zone selection and multiple comparisons in simulation, Management Science, 41,
1935-1945.
Scheffe, H. (1970). Practical solutions of the Behrens-Fisher problem, J. Amer. Statist. Assoc.,
65, 1501-1508.
CHAPTER
Milestones in this development include the demonstrations in von Neumann (1951) of how
the principles of conditional probability could be exploited for this purpose, in Marsaglia
et al. (1964) of how a synthesis of probabilistic and computer-scientific considerations can
lead to highly efficient generating procedures, and in Ahrens and Dieter (1974a,b) of how a
bounded mean computing time could be realized for an arbitrary distribution.
Although the chapter describes procedures that are theoretically exact, the limitations
of working on a finite word-size computer inevitably produce results that differ in practice
from their theoretical ideals. The account notes where serious differences are most likely to
occur and emphasizes the need to employ methods that keep potential errors within tolerable
bounds.
Remarkably, all generating methods produce samples drawn from a specified distri-
bution by transforming a sequence of independent uniform deviates each randomly drawn
from U (0, 1). In practice, a sequence of (normalized) pseudorandom numbers (Chapter 9)
takes the place of the idealized sequence of uniform deviates, and inevitably, this substitution
induces an error of approximation. Chapter 9 describes in considerable detail how to control
the extent to which the distribution of k-tuples of these normalized pseudorandom num-
bers departs from the uniform distribution on the k-dimensional unit hypercube for each
k :::: 1. However, a more insidious source of error arises when the theoretically exact meth-
ods of this chapter use these pseudorandom numbers. Given several alternative methods for
transforming uniform deviates into a sample drawn from a particular distribution, some
are considerably more sensitive than others to the error of approximation that replacing
the deviates by pseudorandom numbers induces. In particular, a growing body of evidence
suggests that this sensitivity increases with the number of pseudorandom numbers that a
method requires to generate a single value from a specified distribution (e.g., Afflerbach and
Hormann 1990 and Hormann and Derflinger 1993).
In practice, this sobering discussion of error encourages two strategies. First, one
should always employ a pseudorandom generator whose error of approximation is no more
serious than the errors of approximation of available competing generators. Chapter 9 de-
scribes how to make this assessment and lists several generators that perform well according
to it. Secondly, when selecting a method to generate samples from a particular distribu-
tion, one should prefer those that require few pseudorandom numbers per sample. This last
stricture favors the inverse transform method (Section 8.1).
Today, many online computer program libraries provide programs for generating
samples from a wide range of distributions. Using these programs can save considerable
time and effort and, when appropriately implemented, can reduce the potential for incurring
serious numerical errors. The conscientious user of any such program will want to assure
herself or himself that the method on which it is based is technically sound and that its
implementation keeps the inevitable error within an acceptable limit. This chapter aims
at assisting the reader in making this evaluation by acquainting her or him with the exact
methodologies for generating samples and with their potential sources of error. Also, it aims
at providing the reader with the capacity to write a generating program, if necessary.
8 .1. I N V E R5 E TR AN 5 FOR M MET HOD 329
Theorem 8.1.
Let {F(z), a .::: z .::: b} denote a distribution function with inverse distribution function
ALGORITHM ITM
Table 8.1 lists selected continuous distributions and their inverse d.f.s. Note that using
the modified form allows one to gain computational efficiency while preserving the distri-
bution of Z. For those continuous distributions whose inverse dJ.s have closed forms, the
inverse transform method offers the most direct method of sampling. If no closed form is
available but F(z) can be easily computed, an iterative method can facilitate sampling. For
finite a and b,Algorithm BISECTION with k(z) = F(z) - U,Zl = a andZ 2 = b determines
Z=z.
If Z is unbounded with fez) > 0, then the Newton-Raphson method, as described
in Algorithm N-R with k(z) = F(z) - U, produces a solution. If {fez)} is bounded and
unimodal, then the modal value provides a reasonable initial value zoo In addition to the
numerical error inherent in working on any finite word-size computer, the bisection and
Newton-Raphson methods both induce an additional error based on the specified error
tolerances. Since making v smaller inevitably increases the number ofiterations until success,
one must inevitably balance cost and accuracy considerations here. See Devroye (1986) for
a more complete discussion of this issue.
ALGORITHM BISECTION
ALGORITHM N-R
Pa(a, 13) af3" /ZOl+1 z :::: 13 > 0, a> 0 13/(1 - U)l/OI 13 /u 1/01 0
Weibull
s:""
W(a, 13) (a/f3 01 )zOl-le-(z/!W a,f3 > 0, Z :::: 0 f3[-ln(1- U)Jl/Oi f3( -In U)l/OI 3:
rn
-I
I
0
0
W
W
.....
332 C HAP TE R 8. SAM P LIN G FRO M PRO BA B I LIT Y DIS T RIB UTI 0 N 5
Although ease of implementation gives the inverse transform method its appeal, it
is not necessarily the most efficient method of sampling from a particular distribution. Its
principal limitation is its heavy reliance on functional transformation. In particular, sam-
pling from Be(a, 1), Be (1 , /3), and Pa(a, /3) call for two transformations per sample. For
example, a sample from Be( a, 1) has the form exp( a-I In u). Whereas computers that incor-
porate algorithms for evaluating these transformations into their hardware offer the fastest
time implementation, the more common case is to have them evaluated by software with cor-
respondingly longer times. Later sections describe alternative sampling methods designed
to reduce the frequency of performing transformations and thus reducing computing time.
The inverse transform method offers one convenience that no other generating method
has. It allows one to generate a sample from the modified distribution
- F(z) - F(a')
F(z):= F(b') _ F(a') , a':::: a' .:::: z .:::: b' .:::: b, (8.2)
with the same ease as one generates a sample from the parent distribution {F(z),a .:::: z .:::: b}.
We refer to this alternative as restricted sampling. Replacing U by U' = F(a') + [F(b') -
F (a') 1U as the argument of the inverse dJ. accomplishes this result. Except for the additional
computation of F(a'), F(b'), and U', the times to generate Z from {F(z)} and {F(z)} are
the same.
The inverse transform method also applies to the case of discrete Z. Suppose that
F(z) = I qz,
0,
z = a, a
otherwise,
+ 1, ... , b,
(8.3)
where
qa-I = 0,
qz<qz+l, z=a,a+1, ... ,b-1,
ALGORITHM DI
Purpose: To generate Z randomly from the distribution {O < qa < qa+ I < ... < qb = I}.
Input: {qa, ... ,qb}·
Output: Z.
Method:
Randomly generate U from U(O, I} and set Z +- a.
While U > qz : Z +- Z + 1.
Return Z.
Observe that the principal work here is a sequential search in which the mean number
of comparisons until success is
ALGORITHM ITR
Implementation of this method can take at least two forms. Table 8.2 lists several
commonly encountered discrete distributions and shows how to evaluate each successive
probability Pz+I recursively from pz given Po. Then Algorithm ITR shows how to generate Z
from anyone of these distributions merely by specifying Po and c(z + I}. The discrete uniform
distribution Ud (a, fJ) is the exception here, merely requiring Z +- La + (fJ - a + l) U J. If
repeated generation occurs from the same distribution with the same Po, then computing
this quantity before generation begins, storing it, and reusing it as input save a major part of
the setup cost in computing Po. For example, computing Po for the binomial distribution
B(r, p} requires the operations Po +- exp[r In(l- p}].Aslater sections show, more efficient
generating procedures exist for each of these distributions in both the cases of varying and
constant input parameter values.
334 C HAP TE R 8. SAM P LIN G FRO M PRO B A B I LIT Y DIS TR I BUT ION 5
The discrete inverse transform method also allows one to generate Z from the restricted
distribution {(qz-qa'-l)/(qb'-qa,-d};z = a',a'+I, ... , b'},wherea :s a' < b':s bmerely
byinitiallysettingp +--- Pa', q +--- qa', and Z +--- a', and replacing U byqa'-l +U(qb' -qa,-d
in Algorithm ITR. Also, the method preserves the monotone relationship between U and
Z, which allows one to induce negative correlation by using U to generate Zl and 1 - U to
generate Z2. Table 3.3 illustrates the effect for the Poisson distribution.
If repeated sampling is to occur from a specified discrete distribution with finite support,
one can exploit other features of the inverse transform method to improve efficiency. Most
notable is the cutpoint method as described in Chen and Asau (1974). The present discus-
sion follows Fishman and Moore (1984), who give a detailed analysis of the efficiency of this
method. The procedure uses sequential search to determine Z, but begins the search at a point
in {a,a+ 1, ... , b} considerably closer to the solution Z on average than the point used by Al-
gorithms DI and ITR. It achieves this result by computing and storing m cutpoints or pointers
beforehand. Then each generation randomly selects an integer L = rm Ul and starts the
search at h. Algorithm CM describes the essential steps.
Since
mean no. of ~
distribution p.m.f. Po e(z + 1) = Pz+l/Pz comparisons ~
co
N
binomial en
per - z) ~
B(r, p) G)pz(1- py-z z=O,I, ... r (1- py 1 +rp (')
(1 - p)(z + 1) ...
(1)
0.-
geometric &:
(')
Qe(p) (1- p)pZ Z = 0,1, ... I-p p 1/(1- p) '"
(1)
......
(1)
hypergeometric &:
a, f3, n, z integer ...~
e)C~z) f3!(a + f3 - n)! (a - z)(n - z) S'
H (a, f3, n) a+f3~n>O 1 + na/(a + f3) t::
(":Il) (f3 - n)!(a + f3)! (z + 1)(f3 - n + Z + 1) a.
0
::I
max(O, n - f3 - 1)
'"
8
:::0 z :::0 min(a, n)
1\
negative binomial '1::!
1\
i(r + z) 1 r z per + z)
NB(r, p) r > 0, Z = 0, 1, ... (1- py l+rp/(1-p)
l(r)l(z + 1) ( - p) p Z+1 00
Poisson 1'0
AZe- A
peA) A > 0, z = 0, 1, ... e- A A/(Z + 1) I+A
z!
(")
uniform C
-I
1
Ud(a, f3) -- a<f3 z = a + L(f3 - a)JLJ "0
f3-a
Z
z = a, a + 1, ... , f3 -I
a and f3 integer
~
m
-I
I
0
0
w
w
U'I
336 C HAP TE R 8. SAM P LIN G FRO M PRO BA B I LIT Y DIS T RIB UTI 0 N S
1 1 1
em := -(lz - h + 1) + -(h - lz + 1) + ... + -(/m+1 - 1m + 1)
m m m
= (/m+1 - h + m)/m. (8.5)
ALGORITHM eM
lm:= 1 + Z - h
1
L
m
Elm = 1 + EZ - Eh = 1 + EZ - - Ij • (8.6)
m j=1
Table 8.3 lists em and Elm using the eight-point distribution in Fishman (1978, p. 459). As
an illustration, m = 4 leads to II = 1, lz = 4, h = 5, and 14 = 7. Also, EZ = 5.31 and
Eh = 17/4 = 4.25, so that E14 = 2.06. If space is not an issue, one may regard Elm - 1 as
the cost of sampling. Algorithm CMSET shows how to compute the points h ..... 1m in a
presampling step.
8 .2 . CUT POI NT MET HOD 337
ALGORITHM CMSET
The cutpoint method offers several additional features that make it attractive in prac-
tice. Of these, restricted sampling is one of the most important. Suppose that one wants
to generate a sample from the modified distribution {qi = (qi - qa,-d/(qb' - qa,-d;
a ::: a' ::: i ::: b' ::: b}. Generating U from U (qa'-I> qb') instead of from U (0, l) in Algo-
rithm CM achieves this result while preserving the efficiency of the method. In particular,
once the original tables of {qa, ... ,qb} and {II> ... , 1m} are computed and stored, one can
sample from them with varying a' < b' without incurring any new cost. No other method
of sampling from tables offers this advantage.
Pi qi m m+b em Elm
.01 .01 9 8.00 5.31
2 .04 .05 2 10 4.50 3.31
3 .07 .12 3 11 3.33 2.31
4 .15 .27 4 12 2.75 2.06
5 .28 .55 5 13 2.40 1.71
6 .19 .74 6 14 2.17 1.64
7 .21 .95 7 15 2.00 1.45
8 .05 1.00 8 18 1.88 1.44
16 24 1.44 1.19
338 C H A PT E R 8. SAM P LIN G FRO M PRO 8 A 8 I LIT Y DIS T RIB U,T ION S
If the p.m.f. of interest changes after one generates each sample, then neither the
cutpoint method nor the alias method (Section 8.4) can guarantee an 0(1) generating
time. For a commonly encountered form of changing k-cell p.m.f., Fishman and Yarberry
(1997) describe a generating procedure that takes O(log2 k) time. Also, see Fishman (1996,
Section 3.31).
This approach to sampling relies on mixtures of random variables to achieve its effectiveness.
Let Z denote a random variable on [a, b1with d.f. F that has the decomposition
F(z) = Lw;F;(z),
;=1
where
0< W; < 1, i = 1, ... , r,
r
Lw;=l,
;=1
and {FI (z), a :s al :s z :s b l :s b}, ... , {Fr (z), a :s a r :s z :s br :s b} also denote d.f.s. To
generate Z, one performs the steps in Algorithm COMPM.
ALGORITHM COMPM
At least two motivations exist for using this method. First, generation directly from
F may be difficult and expensive, whereas generation from {WI, ... , w r } and the chosen F;
may be simple and inexpensive. For example, suppose that
While the inverse transform method does not apply easily here, the composition
method, with
WI := ex, Wz := 1 - ex,
FI(z) := 1 - e- z/ f\ Fz(z):= 1- e-z/1h,
does.
The second motivation relates solely to the relative generating cost. A particularly good
example arises in randomly sampling from the exponential distribution E (1). Recall that the
inverse transform method (Table 8.1) requires the evaluation of a logarithm. If a computer
contains hardware for effecting this evaluation, then the inverse transform method is usually
the most efficient approach. If software, by way of a library subroutine, effects the evaluation,
the computation time increases. In this case, the rectangle-wedge-tail method in MacLaren
et al. (1964), based on the composition method, usually can generate an exponential sample
in less time. Define A > 0, r = 2k + 1, and
with
Figure 3.1 shows the decomposition. Here {f(z)} has 2k + 1 components of which the
first k, fr, ... , fb are rectangular (uniform) p.d.f.s on [0, Aj, [A, 2A], ... , [(k - 1)A, kAj,
respectively. Moreover, the probability of sampling from one of these is
(8.7)
Components k + 1, ... , 2k are the wedge-shaped p.d.f.s fk+l, ... , izb from which one
can sample by the acceptance-rejection technique, which Section 8.5 describes in detail.
Although the cost of this sampling is higher than the cost for fl, ... , fb the frequency with
340 CHAPTER 8. SAMPLING FROM PROBABILITY DISTRIBUTIONS
1.0 - - . - - - - - - - - - - - - - - - - - - - - - - - - ,
0.9
0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0.0 -+----1-I---I---f---jf----1---I---t--j-l---I---l----I=t==t=A=F=F;==r=..,.-..,......j
0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0
z
(8.8)
which can be made small relative to Wi + ... + Wk by an appropriate choice of)" and k.
If the tail component 2k + 1 is chosen, then Z ?: k)" with probability 1. Since
one can proceed as in Algorithm RWTE. In particular, one iterates until J ::::: 2k before
generating Z. The mean number ofiterations is 1/(1 - W2k+d. Actual implementation of
this algorithm depends heavily on the features of the computer to be employed.
ALGORITHM RWTE
1+-1+1
until J ~ 2k.
IfJ~k:
Randomly generate U from U (0, 1).
Z +- [kl + (J - 1) + U]A.
Return Z.
Otherwise:
Randomly generate Y from the distribution {fJ(z), (J - k - 1)1.. ~ Z
~ (J - k)A}.
Z +- kIA + Y.
Return Z.
This technique requires one to set two parameters k and A. As k increases for a fixed A,
the probability of iteration W2k+ I decreases, but the size of the tables needed for choosing J
from {WI. ••• , W2k+ d increases. As A increases, WI + ... + Wk in (8.7) eventually decreases,
which is undesirable from the viewpoint of computational efficiency. As an illustration of
the consequences of two choices, k = 80 and A = .05 leads to
revealing the dominance of sampling from one of the 80 rectangular distributions. Also,
note that the mean number of iterations is 1/(1 - e-sox.OS) = 1.0187. The choice k = 160
and 1..= .05 leads to
with a mean number of iterations = 1/(1 - e-160x.OS) = 1.0003. For a detailed account of
how to prepare a highly efficient computer program to execute this algorithm, see Ahrens
and Dieter (1974a).
The composition method of Section 8.3 also offers an alternative technique for generating a
sample from a table. The procedure requires exactly one comparison, regardless of the size
342 C HAP TE R 8. SAM PLIN G FRO M PRO BA B I LIT Y DIS T RIB UTI 0 N S
of the table (Walker 1974, 1977). This implausible, but nevertheless true, result makes this
approach at least as appealing as the cutpoint method from the viewpoint of computational
efficiency. Moreover, it is an application of the composition method of Section 8.3. Let Z
denote a random variable that assumes value i in T = {a, a + 1, ... , b} with probability
Pi. To generate a Z, the alias method first decomposes the support T into b - a + 1 2-tuples
(A a , Ba), (Aa+l> B a+ I ), .•. , (Ab, B b) such that
and assigns probabilities P(Ai) > °to Ai and P(Bi ) = 1- P(Ai) to Bi such that
1 b
Pi = b-a+1 L h(i),
J=a
(8.9)
ifi = Aj ,
ifi = B j ,
otherwise.
Expression (8.9) implies that selecting a 2-tuple with probability l/(b - a + 1) and then
choosing between Al and BI by Bernoulli sampling produces the desired result. Algorithm
ALIAS describes the procedure.
ALGORITHM ALIAS
Theorem 8.2.
Any discrete distribution with a finite number n of mass points can be represented as an
equiprobable mixture ofn distributions, each of which has, at most, two mass points.
8 .4 . A LI A S MET HOD 343
For the proof, see Kronmal and Peterson (1979), Dieter (1982), or Fishman (1996).
ALGORITHM ALSET
r1 +- .08,
r2 +- .32,
r3 +- .56,
r4 +- 1.20,
r5 +- 2.24,
r6 +- 1.52,
r7 +- 1.68,
r8 +- .40,
S +- {I, 2, 3, 8}, 9 +- {4, 5, 6, 7}.
Then
344 CHAPTER 8. SAMPLING FROM PROBABILITY DISTRIBUTIONS
Table 8.4 displays the corresponding probabilities where the row averages give the original
p.m.f. {PI, ... , Ps} and the column entries sum to unity for each stratum 1, ... , 8.
i/j 1 2 3 4 5 6 7 8 Pi
Al = 1 .08 .01
A2 = 3 .32 .04
A3 = 3 .56 .07
BI =A4 =4 .92 .28 .15
B2 = B3 = B4 = As =5 .68 .44 .72 .40 .28
Bs = A6 = 6 .60 .92 .19
B6 = B7 = As = 7 .08 .60 1.00 .21
A7 = 8 .40 .05
P(A j ) + P(B j ) 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00
t P(A j ) = first entry in column j; P(B j ) = second entry in column j; see expression (8.9) for
computation of {Pi> ... , ps}.
8.5 . Ace E PTA NeE - RE J E C T ION MET HOD 345
a = integer> 0, y 2: 0,
F(z) =
1 1 z a-I
ya-Ie-Ydy = 1 - e- z - e- z 2:)Z' Ii!),
.
z 2: O. (8.lOa)
(a - I)! 0 i=1
Although the bisection and Newton-Raphson methods can provide a solution, their com-
puting times grow at least linearly with a. A more direct approach employs the expansion
of the inverse d.f. (Fisher and Cornish 1960)
where
f(z) = cg(z)h(z),
where
and
LetZ denote a random variablewithp.d.f. {h(z)} andletU befromU (0, 1). ItU ::::: g(Z),
then Z has the p.d.f. {f(z)}.
rg(z) fi (u )du
h ( IU < (Z» = )0 u,Z, Z
Z Z - g pr[U ::::: g(Z)] .
(g(z)
10 fu,z(u, z)du = h(z)g(z)
and
since all trials are independent, the number of trials until success is a geometric random
variable with mean c, which explains why a small c is desirable. This procedure describes
one of the first probabilistic algorithms used on a computer.
ALGORITHM AR
Purpose: To generate Z randomly from the distribution {f(z) = cg(z)h(z), a :::: z :::: b}.
Input: {g(z), h(z); a :::: z :::: b}.
Method:
Repeat
randomly generate Z from the distribution {h(z)}
randomly generate U from U (0, 1)
evaluate g(Z)
until U :::: g(Z).
Return Z.
o ExAMPLE 8.1
(8.l2b)
h(z) = e- z ,
g(z) = e- Cz - 1)2/ 2 , (8.l2c)
and
c = J2e/1i = 1.3155.
Figure 8.2a shows the acceptance region (u :::: g ( - In v» and the rejection region
(u > g(-ln v».
D
348 CHAPTER 8. SAMPLING FROM PROBABILITY DISTRIBUTIONS
(a)
1.0
0.9
0.8 g(-lnv)
0.7
0.6
u 0.5
0.4
0.3
0.2
0.1
0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0
v
(b)
1.0
0.9
0.8
0.7
0.6
u 0.5
0.4
0.3
0.2
0.1
0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0
v
At least two implementations are possible. Version 1, which uses the inverse transform
method to generate the exponential deviate Z, requires a logarithmic evaluation for Z and
an exponential evaluation for g(Z). Alternatively, version 2 generates Y and Z from E (1)
and avoids the exponentiation. If a highly efficient algorithm is available for generating
exponential samples, then version 2 can be expected to be less costly.
VERSION 1
Repeat
randomly generate X and V from U (0, 1)
Z+---ln V
g(Z) +-- e-(Z-l)' /2
VERSION 2
Repeat
randomly generate Y and Z from E (1)
until Y ::: (Z - 1)2/2,
Return Z.
Half-normal generation provides one method for producing a sample from N (0, 1).
Let W denote a random variable from U (0, 1). Then
-Z 1'f 1
W <-,
Z* = { -2
Z otherwise,
where expression (8.11) defines g(z). Here the modifier "simple" means that the time to
evaluate gL (z) and gu (z) is less than the time to evaluate g(z). Note that for some Z, gL (z)
350 C HAP TE R 8. SAM PLIN G FRO M PRO BA B I LIT Y DIS T RIB UTI 0 N 5
may assume negative values or gu (z) may exceed unity. Algorithm ARS shows how to use
these bounding functions to reduce computing time. On each trial, this algorithm leads to
ALGORITHM ARS
Purpose: To generate Z randomly from the p.d.f. {fez), a :::: z :::: b} using the
acceptance-rejection and squeeze methods.
Input: p.d.f. {h(z),a :::: z :::: b}, functions {gLCz), g(z), gu(z); a:::: Z :::: b}.
Method:
Repeat
randomly generate X from U (0, 1)
randomly generate Z from {h(z)}
if X :::: gLCZ), accept
otherwise:
if X :::: gu (Z) : if X :::: g(Z), accept
otherwise: reject
until accept.
Return Z.
Let S denote the event X < g(Z), SL the event X :::: gL (Z), and Su the event
X :::: gu (Z). Then
= lb
(8.14)
pr(Su) min[l, gu(z))h(z)dz,
= lb
and, as before,
preS) g(z)h(z)dz = lie.
- - 1 -
EN = pr(SL, SuIS)[-(-) - 1) + pr(SL, SuIS), (8.16)
pr S
8.5. Ace E PTA NeE - RE J E C T ION MET HOD 351
where SL and S denote the events X > gL (Z) and X > g(Z), respectively. Since
and
it follows that
pr(Su) - pr(SL)
EN= .
pr(S)
To reduce the frequency of exponential evaluation, the squeeze method often employs the
inequalities (Exercise 8.1S)
x ::: O. (S.lS)
x-I
--slnxS-1+x, x ::: 0, (S.19)
x
or (Exercise 8.20)
o EXAMPLE 8.2
For the half-normal distribution in Example 8.1 with g(z) = C(Z-I)'/2, inequalities
(S.lS) leads to the lower and upper bounds
(S.21)
and
respectively. Moreover,
and the mean number of evaluations of g (Z) until success is EN = .1480. Figure 8.2b shows
{gL (z)}, {g(z)}, and {gu (z)} for z = -In v and 0 < v < 1. In summary, incorporating the
squeeze method into the acceptance-rejection method in this example reduces the mean
number of evaluations of g(Z} from 1.3155 to 0.1340. Of course, some of this saving is
expended in the two additional pretests for SLand Su.
o
The acceptance-rejection method incurs four forms of work: generation of Z from {h(z}},
generation of U from U (0, 1), evaluation of g(Z}, and repeated generation until success
occurs. The squeeze method reduces the frequency ofevaluating g (Z). The ratio-of-uniforms
method replaces the generation of Z and U by the generation of Z = al + a2Y / X, where
(X, Y) is uniformly distributed over a bounded region where al> a2 and the shape of the
region depend on {f(z)}. In principle, the work to generate (X, Y) is considerably less,
thus potentially reducing the computing time required to obtain a sample from {f(z)}.
Theorem 8.4 represents a generalization of the original proposal of Kinderman and Monahan
(1977) for the ratio-of-uniforms method and is used extensively by Ahrens and Dieter (1991)
and Stadlober (1989,1991) for generation from discrete distributions.
8 .6 . RAT I 0 - 0 F - U N I FOR M 5 MET HOD 353
Theorem 8.4.
Let {r(z), -00 < Z < oo} denote a nonnegative integrable function and let Q denote
the region
where
(8.26)
and
fw,z(w, z) = Jfx,Y(.JW, (z - ad.JW/a2), 0.::: w .::: r(z), -00 < z < 00,
ax ax 1
- 0
aw az 2y'w
J= ,
ay ay z - a] y'w 2a2
aw az 2a2y'w a2
so that
r(z) r(z)
fz(z) = 10 fw,z(w, z)dw = 2a21QI' -00 < Z< 00,
and
1 00
-00
fz(z)dz =
1
Z-IQI
a2-00
1 00
r(z)dz = l. D
The equations
= r2(Z)
J
x(z)
354 C HAP TE R 8. SAM P LIN G FRO M PRO BA B I LIT Y DIS T RIB UTI 0 N S
and
1
y(z) = (z - adX(z)/a2 = (z - al)r> (Z)/a2
define the boundary of Q, and for specified al and a2 every point in Q lies in the rectangle
(8.27c)
and
1
y* := sup[(z - adr> (z)/a2]' (8.27d)
z
ALGORITHM ROU
Purpose: To generate Z randomly from the p.d.f. {f(z), -infty < z < oo} using the
ratio-of-uniforms method.
Input: Function {r(z) = df(z), -00 < z < oo}, constants al E (-00, 00) and
a2 E (0,00).
Setup: x* +--supzr~(z),y* +--infz[(z-al)r!(z)/a2],and
y* +-- sUPz[(z - al)r~(z)/a2]'
Method:
Repeat
randomly generate X from U (0, x*)
randomly generate Y from U (y*, y*)
Z+--al+a2 Y / X
until X 2 ~ r(Z).
Return Z.
(8.28)
8.6. RAT I 0 - 0 F - U N I FOR M S MET HOD 355
Generating (X, Y) from P takes little time compared to the potentially greater time to
generate Z from {h(z)} in expression (8.11) using the acceptance-rejection method. While
the inclusive region P may assume a shape other than rectangular in order to make the ratio
IPI/I QI closer to unity, one must balance this reduction against the potentially greater cost
of generating X and Y from a less simple region. Section 8.13 describes how an alternatively
shaped inclusive region does indeed payoff for Gamma generation. The original proposal
in Kinderman and Monahan (1977) for this method chooses al = 0 and a2 = 1, and it
is this assignment we use in the next several sections unless an alternative assignment is
explicitly made. Section 8.15 shows how the judicious choice of al and a2 allows one to
sample from a simple region to generate samples from discrete distributions with bounded
mean computing times.
The acceptance check X 2 .::: real +a2Y / X) in Algorithm ROU can consume consider-
able time just as the acceptance check U .::: g(Z) in Algorithm AR can. Again, appropriately
chosen squeeze functions can reduce this time significantly.
o EXAMPLE 8.3
x* = 1, y* = 0, y* =.j2je,
IPI/IQI = 4/Fe = 1.3688.
Figure 8.3a shows the acceptance region. The acceptance test in Algorithm ROU takes the
form
X .::: e-(Y/2X)',
is close to the acceptanceprobabilitypr(S) = Jrr 12e = .7602 in Example S.l, but the ratio-
of-uniforms method requires no exponential deviate as the acceptance-rejection method in
Example S.l does.
D
Pretesting based on the inequalities (S.19) again improves efficiency. Let TL denote
the event
(S.31)
One accepts Z = Y I X if TL occurs on the first pretest, but rejects Z if u occurs on thet
second pretest, where
pr(Td = 1
~
",2/e
11 1
0 0
2X
v'I=X dydx
(S.33a)
= her (D / r G) = 4(2e)~ /15
= .621S
and
pr(Tu) = ~Jmin[2/e,4x(1-x)]dydx
",2/e
1 / sin-1(-JI-2/e)+rr/2 (S.33b)
= 2"Y 1 - 2/e + ----'--2-..jVe--=2=/e=----
= .S579.
Then
(a)
1.0 - , - - - - - - - - - - - - - - - - - - - - - - - - - ,
0.9
0.8
0.7
0.6
Y = 2xv- 1nx
Y 0.5
0.4
0.3
0.2
0.1
0.0 +--.--.--.---.-----,-----,----,---,---,---,---,---,---,---,---,---,----,----,----,----1
0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0
x
(b)
1.0 -,-----------=--~o:----------,
Y = 2Jx(1 - x)
0.9
Y = 2xV- 1n x
0.8
0.7
0.6
Y 0.5
0.4
0.3
0.2
0.1
0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0
x
This result follows in a manner analogous to that for EN in expression (8.16) for the
acceptance-rejection method. Figure 8.3b shows the relevant curves.
In summary, incorporating the squeeze method into the ratio-of-uniforms method
for generating a sample from the half-normal distribution reduces the mean number of
evaluations of r(Y / X) from 1.3688 to 0.3232. Again, the two pretests consume part of this
time saving. However, one should note that 100 x (I - 0.3232/1.3688) = 76.39 percent of
the time no logarithmic or exponential evaluations are required, whereas the acceptance-
rejection method in Example 8.1 requires one exponential deviate on every trial, regardless
of whether or not the squeeze method is used.
(8.34)
wherem- 1 denotes the inverse function ofm . Since the objective is to achieve !z(z) = fez),
one wants to determine the p.d.f. fx that effects this result, namely
fx(m-1(z)) = fx(x)
= !z(z)m'(m-1(z)) (8.35)
= f(m(x))m'(x).
where the upper bound on p ensures that f* is a p.d.f. Clearly, assigning p the value of its
upper bound offers the greatest benefit.
Algorithm EAM describes the method, making use of the fact that if U :s p, then
U / p is from U (0, 1). The motivation for large p is now clear. It reduces the frequency
with which one must generate X from f*, which Marsaglia recommends be done by the
acceptance-rejection method.
ALGORITHM EAM
1
fz(z) = lTO + Z2)' -00 < Z< 00, (8.37)
denoted bye (0, 1), illustrates the method. From Table 8.1, the corresponding inverse of d.f.
is {p-l (x) = tan IT (x - 1/2),0 :s x :s I}. For a = 2/lT and b = IT - 8/lT, the function
m(x) = y( a
1/4 - Y
2 + b) , Y := x - -,
1
2
O:s x :s 1, (8.38)
, 1/4 + y2
m(x)=a( 2)2+b, (8.39)
1/4 - y
I/lT [ 1/4 + y2 ]
jx(x) = 1 + m2(x) a 0/4 _ y2)2 + b .
* 1
j (x) = 1 _ p
{ 1/ IT [ 1/4 + y2
1 + m2(x) a 0/4 _ y2)2 +
bJ - pI[o.l) (x)
} ::: 0 (8.40)
360 CHAPTER 8. SAMPLING FROM PROBABILITY DISTRIBUTIONS
is p = .997738.
Algorithm CA describes an implementation of the exact-approximation method for
sampling Z from the Cauchy distribution C (0, 1) without the use of special functions.
When sampling from f*, it employs an acceptance-rejection procedure with a mean of
3.859819 additional samples from U (0, 1). However, Algorithm CA executes this branch
with probability 1 - P = .002262, resulting in an overall mean of 1.006469 samples from
U (0, 1). Section 8.10 relies on Algorithm CA to provide a fast algorithm for generating
samples from the normal distribution in Algorithm NA.
ALGORITHM CA
distribution, the reader of these sections should be able to craft a procedure that performs
acceptably.
Since
1 [2e- m (X)b(b - 1) In 2 ]
rex) = 1_ P (b _ X)2 - pI[o.I](x) :::: O. (8.47)
ALGORITHM EA
Recall from Table 8.1 that the Weibull distribution has p.d.f.
a-I
f( Z) -- ~ e-(ziP)" ,
{Ja
8.9. EXPONENTIAL DISTRIBUTION 363
d.f.
and is denoted by W(ex, f3). If Y is from £(f3), then it is easily seen that Z = y1/ a is from
W(ex, f3).
• Return Z +- yl/a.
These steps are more general than those in Table 8.1, allowing for a faster method of
exponential generation to be used if such an implementation is available.
ex, f3 > 0, z ~ 0,
which is called the inverse Weibull distribution and is denoted by IW(ex, f3). Its mean,
variance, and mode are, respectively,
EZ = r(1- l/ex)/f3,
varZ = [r(1- 2/ex) - r2(1- l/ex)] /f3 2 ,
mode = ~ C: Yla ex
The existence of EZ requires ex ::: 1, and of varZ, ex > 2. Since prey < a)
pr(1/Z ::: a),
The first property makes clear that one need only concentrate on devising a procedure for
generating a sample from N (0, 1), since the relatively inexpensive transformation Z =
/L + a Y generalizes its application. The second property shows that only one generation
from N (0, 1) is necessary to generate Z = ZI + ... + Zn.
Moro (1995) describes numerical evaluation by the inverse transform method with
10- 9 accuracy. Examples 8.1 and 8.2 show how to generate a sample from the half-normal
distribution from the acceptance-rejection and ratio-of-uniform methods, respectively.
Multiplying the outcome by a randomly determined sign makes it a sample from N (0, 1).
The rectangle-wedge-tail method in Marsaglia et al. (1964) and its modification in
Algorithm RT in Ahrens and Dieter (1972) provide the fastest algorithms for sampling from
N(O, 1). Unfortunately, they rely on extensive tables the preparation of which may not
appeal to a potential programmer. Shortly, we describe Algorithm NA in Ahrens and Dieter
(1988), which is the fastest known table-free method in both FORTRAN and assembler
language versions. Nevertheless, we first describe a commonly employed "slow" method
that establishes the basis for Algorithm NA.
and (8.49)
1
Y = (2V)l: sin 2rrU
au av au av I
/x,y(x, y) = /u,v(u(x, y), vex, y)) Iax ay - ayax
since
Expression (8.50) gives the p.d.f. of two independent random variables, as required. 0
The simplicity of implementation is most responsible for the common use of this
approach. However, its reliance on square root, cosine, and sine evaluations makes it
uncompetitive. However, it does establish a basis for Algorithm NA.
Observe that tan 2rr U in Theorem 8.5 has the Cauchy distribution C (0, I). Therefore,
employing Algorithm EA to generate V and Algorithm CA to generate Wand taking X =
J2V 1(1 + W2) and Y = W J2V 1(1 + W2) accomplishes our purpose except for signs.
Assigning a random sign to X and assigning the sign of W to Y solves this problem. Algorithm
NA assumes that the value assigned to variable Y is saved between successive executions of
the algorithm. As presented here, Algorithm NA is a slight variant of the one in Ahrens and
Dieter (1988) that exploits the inevitable call to Algorithm CA.
ALGORITHM NA
denoted by.eN (f.1" 0'2). Occasionally, the distribution is described in terms of its moments
and
Common practice generates X from N (0, 1), computes Y = f.1, + Xo', and takes
Z = eY as the sample. The marginal increment in cost over normal generation is due to the
exponential evaluation.
~
f(z)=1l'[~2+(z-a)21' -oo<a<oo, ~>o, -oo<z<oo,
denoted byC (a, ~). The distribution has the following properties:
3. If X I and X2 are independent from N (0, 1), then Z = X I! X2 is from C(O, 1).
4. If (Y I , Y2 ) is uniformly distributed on the unit circle y~ + y? = ~, then Z = YI / Y2 is
from C (0, 1).
°
Without loss of generality, we take a = and ~ = 1. Algorithm CA in Section 8.7 generates
Z from C (0, 1) using the exact-approximation method.
Table 8.1 gives the inverse d.f. for Z, which requires a tangent evaluation in practice
and compares unfavorably in timing with Algorithm CA. To avoid this, one can generate
XI and X2 each from N (0,1) and use Z = XI! X 2 • Alternatively, one can use the result
8.13. GAM MAD 1ST RIB UTI 0 N 367
based on uniform generation on the unit circle. In particular (Exercise 8.37), straightforward
application of the acceptance-rejection technique gives
Repeat
generate Y l and Yz each from U (- ~, ~) (8.51)
until YlZ + Yi :s ~.
Return YJ/ Yz.
where the mean number of trials is 4/n = 1.2732. Devroye (1986) suggests the pretest
IYll + IYzi :s 1, which reduces the frequency of evaluating the two multiplications by half.
However, one must add in the time required to evaluate the absolute value function twice.
1. If Zl, ... , Zn are independent from 9 (aI, (3), ... , 9 (an, (3), respectively, then Z =
Zl + ... + Zn is from 9 (al + ... + an, (3).
Z +- 0 and i +- 1.
Repeat
368 CHAPTER 8. SAMPLING FROM PROBABILITY DISTRIBUTIONS
which takes O( a) time. Ifone uses the inverse transform method for the exponential deviates,
then an opportunity to improve efficiency exists.
That is,
Y ~ 1 andi ~ 1.
Repeat
randomly generate Ui from U (0, 1)
Y~YUi
i ~ i +1
until i > a.
Return Z ~ -In Y.
Although only one logarithmic evaluation occurs, the generation of a uniform deviates
retains the O(a) time. Also, the required integrality of a limits the applicability of this
approach. The remainder of this section addresses the problem of Gamma generation for
a :s 1 and the problem of Gamma generation with bounded mean computing time as
a ---+ 00.
0: !: 1
In their Algorithm GS, Ahrens and Dieter (1974b) generate Z from Q(a, 1) with
o< a :s 1, using a combination of the acceptance-rejection, composition, and inverse
transform methods with
e a I a
h(z) = --I[o,I](z)az - + --I(1,oo)(z)e- Z
+1
, (8.52a)
a+e a+e
g(z) = 1[0,1] (z)e- Z + 1(1,00) (Z)Za-1 , Z ~ 0, (8.52b)
and
where I!A! (z) denotes the indicator function of the set A and {h(z)}, {g(z)}, and c(a)
are defined in Theorem 8.3. Observe that f(z) = c(a)g(z)h(z) gives the Gamma p.dJ.,
sampling from the p.dJ. {h (z)} uses the composition method and the mean number of trials
until success c(a) has the upper bound c :s 1.39. The composition method determines
whether one generates Z in expression (8.52a) from the dJ. {za, 0 :s z :s I} or from the
dJ. {I - e- z+l , 1 < z < oo} by the inverse transform method. The acceptance-rejection
method determines whether or not Z is from Q (a, 1).
8.13. GAM MAD 1ST RIB UTI 0 N 369
Algorithm GS* describes the essential steps. It differs from those in Algorithm GS in
Ahrens and Dieter (1974b) in minor ways. Observe the setup b +- (a + e)/e. If repeated
sampling is to occur for the same value of a, then it is advantageous to compute b once at the
beginning of the experiment and use a and b, instead of a alone, as input, thus avoiding the
repeated cost of computing b. Note that Algorithm GS* admits no simple pretest to exploit
the squeeze method. Best (1983) suggests several modifications that reduce generating time
by a relatively incidental factor for a close to zero and by one-half for a close to unity. As an
extension of a method for a > 1 to be described in the next section, Cheng and Feast (1980)
describe a competitive method for 1/ n ::::: a ::::: 1, where n is a fixed integer.
ALGORITHM GS*
a >1
Many alternative algorithms exist for this case of which those in Ahrens and Di-
eter (1974a, 1974b, 1982a), Cheng and Feast (1979), Marsaglia (1984), Minh (1988), and
Schmeiser and Lal (1980) are demonstrably fast. The one due to Cheng and Feast uses the
ratio-of-uniforms method (Section 8.6) and illustrates many of the nuances implicit in this
approach.
The acceptance region is
(8.53)
implying that Q (a) lies in the rectangle P (a) := {O ::::: x ::::: x* := [(a - 1)/e](a-1)/2,
0::::: y ::::: y* := [(a + 1)/e](a+1)/2} (definitions 8.27b and 8.27d). Direct application of the
370 C HAP TE R 8. SAM P LIN G FRO M PRO B A B I LIT Y DIS T RIB UTI 0 N 5
(a)
1.0-,---------------r-----c~~-------~
a=2
0.9
0.8
0.7
0.6
y' 0.5
0.4
0.3
0.2
0.1
0.0 -'f-~,.-,-____r~_+_~;__"F==f=;:::.,--,L_,_.,____,,____,_____r~_,___-,-----,_J
-0.6 -0.4 -0.2 0.0 0.2 0.4 0.6 0.8 1.0 1.2 1.4 1.6
x'
(b)
1.0-,----------------------y-~-""""
a = 100
0.9
0.8
0.7
0.6
y' 0.5
0.4
0.3
0.2
0.1
0.0 +L-,.----/"'-,---f-_,_____~____r_,____,_____~____r_,____,_____~____r_,____,_____~---,---I
-0.1 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1
x'
Figure 8.4 Gamma generation: ratio-of-uniforms method x' := xjx* and y'
yjy*.
for which
where
Table 8.5 reveals that the square P(a) has an advantage for a ~ 3, whereas for a :::: 4,
the parallelogram p'ea) has an ever-increasing advantage as a ~ 00. This suggests a
procedure that uses the square for a ~ 3 and the parallelogram for a :::: 4. However, an
additional issue plays a role.
Recall that (X = x*X', Y = y*Y') is uniformly distributed on P (a) if(X', Y') is
uniformly distributed in the unit square [0, IF. If generation from the same Q(a, 1) is to
occur repeatedly, then one can compute x* and y* once at the beginning, store them, and
use a, x*, and y* as input to the algorithm on each call. If many distinct a's are used, this
372 CHAPTER 8. SAMPliNG FROM PROBABILITY DISTRIBUTIONS
approach may not be feasible, and without modification one would repeatedly incur the
relatively high setup cost of computing x* and y*. A modification of the acceptance region
reduces this cost substantially at a relatively small increase in the mean number of trials until
success for small a.
Let (X', Y') be uniformly distributed on [0, IF. Let X = x*X' and Y = y**Y', where
y** :::: y*. Then (X, Y) is uniformly distributed on the rectangle
where b := y** /x*(a - 1), suggesting that one merely has to take b :::: y* /x*(a - 1) =
(a + 1)/(a - 1)(u+I)/2 /e and Z = (a - 1)bY' / X'. Cheng and Feast suggest
which ensures b :::: y* /x*(a - 1) and eliminates the need to evaluate x*, y*, and y**.
Since W and Z have the joint p.d.f.
it follows that
and Z given W ~ r(Z) has the desired Gamma p.d.f. Since X' and Y' are uniformly
distributed over [0, 1F, the mean number of trials is 2( a /217:) 1/2 as a -+ 00, which agrees
with the limit (8.54b).
Since P '(a) n [0, IF C P(a), this alteration also applies to sampling from P '(a).
While preserving the validity of the ratio-of-uniforms approach to Gamma generation for
a > 1, the change merely scales c(a) and c'(a) by b(a - l)x* /y*, which decreases from
1.133 at a = 1 to unity as a -+ 00.
Algorithm GKMI describes the generating method when (X', Y') are randomly gen-
erated on the unit square P(a). Note the pretest mX' - d + V + V-I ~ 0, which is based
on the inequality In w ~ w - 1 for w > O. This pretest reduces the frequency oflogarithmic
evaluation (Exercise 8.42). Whenever possible, evaluating a, b, m, and d beforehand, storing
them, and using them as input in place of a on repeated generations for the same a saves time.
8.13. GAMMA D I STRI B UTI 0 N 373
ALGORITHM GKM1
Purpose: To sample Z randomly from the Gamma distribution 9 (a, 1) with a > 1.
Input: a.
Setup: a +- a-I, b +- (a - 1/6a)/a, m +- 2/a, d +- m + 2.
Source: Cheng and Feast (1979).
Method:
Repeat
randomly generate X' and Y' fromU(O, 1)
V+- bY'/X'
if mX' - d + V + V-I :s: 0, accept (fast acceptance)
if m In X' - In V + V-I :s: 0, accept
until accept.
Return Z +- aVo
Algorithm GKM2 describes the steps when sampling (X', Y') from the parallelogram
P '(a). Whenever possible, evaluating the setup, a, b, m, d and especially f, beforehand,
°
storing them and using them as input on repeated generations for the same a saves time.
Note that Ne = .857764. It is left to the reader (Exercise 33) to show that if < X' < 1,
then (X', Y') is uniformly distributed on p'ea) n [0, IF and that on any trial
e+2
pr(O < X' < 1) = 1 - v'2 > .5328. (8.60)
2Jae(~+ 2)-
ALGORITHM GKM2
The step f +- .j(i keeps Algorithm GKM2 from completely dominating Algorithm GKMI
timewise. However, the associated O( 1) evaluation time increasingly favors Algorithm GKM2
374 CHAPTER 8. SAMPLING FROM PROBABILITY DISTRIBUTIONS
when compared to the O(a~) mean generating time for Algorithm GKMI as a ~ 00. Al-
gorithm GKM3 reconciles these two options. Cheng and Feast recommend ao = 2.5.
ALGORITHM GKM3
f( ) - 1 e-1/Pz R
z~ 0,
Z - r(a)fJaza+l ,a,,., > 0,
which is called the inverted Gamma distribution and denoted by TQ(a, f3). Its mean,
variance, and mode are, respectively,
1
EZ= ,
(a - l)fJ
1 .
varZ= ,
(a - 2)(a - I)2fJ2
and
1
mode = ( )
a+IfJ
The existence ofEZ requires a > 1, and ofvarZ, a > 2. Since pr(Y ~ a) = pr(1/Z ~ a),
where B denotes the beta function, and is denoted by l3e(a, (3). The distribution has the
following properties:
1. If X and Yare independent random variables from 9 (a, 1) and 9 (f3, 1), respectively,
then Z = X/eX + Y) has the Beta distribution l3e(a, (3).
2. Let denote independent random variables each from U (0,1) and let
U I , .•. , Un
U(l) < ... < U(n) denote the corresponding order statistics. Then U(k) has the Beta
distribution l3e(k, nk + 1) for k = 1, ... , n.
Property 1 provides an immediate way to generate a Beta variate given the availability of
a procedure for gamma generation. However, faster Beta generation methods exist. Property
2 reveals how to generate order statistics for any parent distribution for which generation via
the inverse transform method applies. See Fishman (1996, Section 3.26). The third property
shows that any development for a ::=: f3 applies equally to f3 :::: a by simple transformation.
Table 8.1 gives the inverse dJ.s that allow Beta generation in 0(1) time for a = 1
or f3 = 1. However, the derivation of an algorithm with bounded mean computing time
for arbitrary a and f3 calls for considerably more attention. We first consider the cases
max(a, (3) < 1 and min(a, (3) > 1 separately and then consider the case of min(a, (3) < 1
and max(a, (3) > 1.
and
c(a, fJ, t) = r(a + fJ + 1)[fJt + a(1 - t)]1 r(a)r(fJ)(a + fJ)t l - a (1 - t)I-f3. (8.62b)
c(a, fJ, t) = II t
10
g(z)h(z)dz = sup [f(z)1 h(z)]'
O~z~1
and c(a, fJ, t)g(z)h(z) is identical with f(z) in expression (8.61). To generate a Beta variate,
one first determines whether 0 ::: Z ::: t with probability p or t < Z ::: 1 with probability
1 - p. If 0 ::: Z ::: t, then generation occurs from {a za-I I t a , 0 ::: z ::: t} using the inverse
transform method. If (t < Z ::: 1), then generation occurs from {fJ(l - z)f3- I /(1 - t)f3,
t < z ::: I}, again using the inverse transform method. In both cases, the acceptance-
rejection method determines whether or not Z is from Be(a, fJ). The assignment t = t*,
where
fJ(1 - fJ)]-1
(8.63)
a(1 -a) ,
minimizes the mean number of trials c(a, fJ, t). We leave to the reader the proof (Exercise
8.45) that c(a, fJ, t) is bounded above for all 0 ::: a, fJ ::: 1 and all 0::: t ::: l.
Algorithm AW describes the procedure with two preliminary tests that use the inequal-
ity e > x + 1, which holds for all x > O. If repeated generation for the same a and fJ occurs,
then evaluating t prior to the first generation, storing it, and using it as input with a and fJ
on each execution of the algorithm eliminates the repeated computation of the square root.
For repeated generation with many different a's and fJ's, storing all the computed optimal
t's may not be a viable option. An alternative is to set t = ~ as a parameter, which eliminates
the square root evaluation but increases the mean number of trials c(a, fJ, ~). However,
sUPO<a,f3~1 c(a, fJ, ~) < 00. Note that if U ::: p, then UI p is from U (0, 1).
ALGORITHM AW
Purpose: To generate Z randomly from Be(a, fJ) for max(a, fJ) < l.
Input: a andfJ.
<=---:::,..,-1
Setup: and p *- fJtl[fJt + a(1 - t)].
Method:
Repeat
randomly generate U from U (0, 1) and Y from £ (1)
ifU:::p:
Z *- t(Ulp)l/a
8.14. BET A DIS T RIB UTI 0 N 377
y ~ 0, (8.64)
then Z = Y /(1 + Y) is from Be(a, (3). Therefore, one need only concentrate on sampling
Y using the acceptance-rejection approach with the factorization
and
fJ. = (a/f3)A.
x ~ 0,
378 C HAP TE R 8. SAM P LIN G FRO M PRO B A B I LIT Y DIS T RIB UTI 0 N S
the inverse transform method allows one to generate a sample from {h (y )} in constant time.
Algorithm BB* corresponds to Algorithm BB in Cheng (1978) in content. It contains
several pretests that reduce the required number of logarithmic and exponential transfor-
mations. If repeated samples are to be taken with the same a and fJ, then evaluating the
quantities in the setup beforehand, storing them, and using them as input to successive exe-
cutions reduces computing time. There is no way to avoid the logarithmic and exponential
evaluation in evaluating V and W. Note in Algorithm BB* that we use VI VI in place of vf.
Since some programming languages compute vf as exp(2ln Vd, it is desirable to avoid this
expensive evaluation method wherever possible.
ALGORITHM BB*
Purpose: To generate Z randomly from Be(a, fJ) for min(a, fJ) > 1.
Input: a and fJ.
Setup: d l = min(a, fJ), d2 = max(a, fJ), d3 = d l + dz,
d4 = [(d 3 - 2)/(2d l d2 - d3 )] ~, d s = d l + 1/d4 •
Method:
Repeat
randomly generate VI and Vz from U (0, 1)
V +- d4 In[Vt!(1- VI)]; W +- dle v ; ZI +- VIVIVz
R +- d s V - 1.38629436; S +- d l + R - W
if S + 2.60943791 > 5ZI> accept (preliminary test 1 with In 4 =
1.38629436 and 1 + In 5 = 2.60943791)
otherwise:
T +-lnZI
if S 2: T, accept (preliminary test 2)
otherwise: if R + d3 In[d3 /(dz + W)] 2: T, accept
until accept.
If d l = a, return Z +- W /(d z + W); otherwise, return Z +- dz/(d2 + W).
For min(a, fJ) < 1 and max(a, fJ) > 1, see Fishman (1996, Section 3.15).
r(a)r(fJ) Z~-I
f(z) = r(a + fJ) (1 + z)aH '
a, fJ > 0, Z 2: 0,
sometimes called the Beta-prime distribution (Johnson et al. 1994). Note that Z has infinite
support and that f decreases as O(z-(l+a)) as Z --+ 00.
8.15. REVISITING THE RATIO-OF-UNIFORMS METHOD 379
Observe that
I < ex.
Moreover, Z has infinite mean for ex ::::: 1. For 1 < ex ::::: 2, it has infinite variance.
To sample from this distribution, first sample Y from Be(ex, fJ) and then return Z =
y- 1 _ 1.
Section B.13 shows howal = 0, a2 = 1, and a bounded region P other than rect-
angular create a bounded-computing-time algorithm for Gamma generation using the
ratio-of-uniforms method. This section describes another variant of the method that is par-
ticularly well adapted for efficient sampling from Poisson, binomial, and hypergeometric
distributions.
As in Section B.13, assume that we wish to generate samples from a bounded p.d.f.
{f(z), -00 < z < oo}. Let
Q(al, a2) := {(x, Y): x::::: r 1/ 2 (al + a2Y/x), -00 < a, < 00, a2 > OJ.
Theorem B.4 asserts that if (X, Y) is uniformly distributed on Q(al, a2), then Z = al +
a2Y / X has the p.d.f. f.
Let P be the rectangle
and
Definition (8.66) ensures inequality (8.68). However, two cases need to be considered
for inequality (8.69). In the first, I y I jx =1 z - al I ja2 :::: 1, for which inequality (8.68)
implies inequality (8.69). In the second, I y I jx =1 z - al I ja2 :::: 1, which requires
a2
r(z) :::: ( 2)2 V Z E (-00, al - a2) U (al + a2, (0). (8.70)
z- al
Recall that
1
I Q(al, a2) 1= -2
a2
1 00
-00
r(z)dz = 2
a2 SUPt
1 f( )'
t
(8.71)
Then one chooses al and a2 to minimize the mean number of trials until success
IPI
I Q( aI, a2 ) I = 4a2 sup f(t)
t
(8.72)
subject to -00 < al < 00, a2 > 0, and inequalities (8.68) and (8.70).
The application of the ratio-of-uniforms method to generation from a discrete distri-
bution is now relatively straightforward. Suppose Z has the p.m.f. {Pi; i = a, a + 1, ... , b}.
Then one takes
and applies the theory of this section to find desirable values of a I and a2. The next several
sections illustrate the generality that the method offers in practice.
1. If X I, X 2, ... are i.i.d. random variables from £ (1) and Z is the smallest nonnegative
integer such that XI + ... + X Z + I > ).., then Z has the Poisson distribution P()").
2. If V I, V 2 , ••• are i.i.d. random variables fromU (0, 1) and Z is the smallest nonnegative
integer such that nt=i l Vi > ).., then Z has the Poisson distribution P()").
8.16. POlS SON DIS T RIB UTI 0 N 381
Algorithm ITR applies the inverse transform method with Po = e- Aand c(z) = A/Z,
z > O. Although Section 8.1 shows the mean computing time as O( A), its relatively small setup
cost allows this procedure to compare favorably timewise with more sophisticated algorithms
with bounded mean computing time for small A. An alternative algorithm, based on property
2, is often encountered in practice, but timing studies in Atkinson (1979) and Schmeiser
and Kachitvichyanukul (1981) show it to be more time-consuming that Algorithm ITR. No
doubt, the multiple generation of U I , U2 , ••• accounts for this excess time consumption.
Let Y be from N (0, 1). Property 3 implies that treating max(O, LA + 1/2 + y,J}.J) as
a Poisson variate from P(A) incurs an error that diminishes as A increases. The factor is 4
a continuity correction that reduces the error of approximation for every fixed A. Although
this constant-time approach is acceptable in problems in which this error is small relative
to errors from other sources, it is unacceptable in problems where results are sensitive to a
departure from the Poisson distribution. This may be especially so in applying the Monte
Carlo method to estimate the distributional character of a statistic that is a function of
Poisson random variables.
Atkinson (1979), Ahrens and Dieter (1982b), Devroye (1981), Schmeiser and Ka-
chitvichyanukul (1981), and Ahrens and Dieter (1991) all propose Poisson generating
algorithms with bounded mean computing times. Among these, Algorithm PD in Ahrens
and Dieter (1982) appears least time-consuming, but not simple. Since the 1991 proposal of
Ahrens and Dieter for A ~ 1, which exploits the ratio-of-uniforms method, is considerably
simpler and not too much more time-consuming, we describe it here.
We take
where expression (8.73) defines {f (z)} for discrete distributions. The Poisson distribution
has its mode at LAJ, so that
(8.77)
(8.78)
382 C HAP TE R 8. SAM P LIN G FRO M PRO BA B I LIT Y DIS T RIB UTI 0 N S
for al. For this choice, the az that minimizes the ratio (8.77) subject to inequality (8.71b),
A ::: 1, and az > 0 is
(8.79a)
where k* takes one of the two values k* = La .;u;; J and k* = ra .;u;;l. Also,
l - l -
a;(1) =~ (8.79b)
2
and
lim A-1/Za;(A)
A---+oo
= me = 0.8578. (8.79c)
Since computing a; in line is relatively time consuming, Ahrens and Dieter recommend the
less costly
(8.79d)
which manifests the same limits (8.79c) as the optimal az. Then
(8.80a)
and, using Stirling's formula j! ~ ..[iiijj+I/Zexp(-j + e/I2j) for integer j > 1 and
0< e < 1,
(8.80b)
a
Computations in Stadlober (1989) illustrate how well al and z fare with respect to
the optimal al and az. For A = 5, al = 5.277 and az = 2.271 minimize the mean number
a
of trials (8.77). For the recommended l = 5.5 in expression (8.78), expression (8.79a)
gives a; az
= 2.425 as best possible, and expression (8.79d) gives = 2.461, the more easily
a a
computed bound. Therefore, the mean number of trials based on l and z is within 8.37
percent of the achievable minimum, and Stadlober shows that this percentage progressively
decreases to zero as A increases.
Algorithm PRUA* describes a modification of Algorithm PRUN in Stadlober (1989),
which is a modification of Algorithm PRUA in Ahrens and Dieter (1991). Note that the setup
calls for a precomputed table of Yk = In k! for k = 0, 1, ... , k'. Moreover, for k > k', In k!
can be computed by using a truncated form of the expansion (Hastings 1955)
Stadlober reports an absolute truncation error less than 7.9 x 10-9 when terms up to O( 1/ k 3 )
are retained. The choice of k' is at the user's discretion and, in principle, depends on space
availability. Making k' large reduces the need to compute d7 and Yk in line and considerably
improves the efficiency ofthe procedure. If Poisson generation with LAj :::: k' is contemplated,
one can omit the test in the setup entirely. The rejection test Z ::: dg, based on the precision
factor do, allows the algorithm to avoid computing insignificant probabilities. As before, if
repeated sampling is to occur with the same A, then one can compute the setup prior to
any generation, store d3 , d4 , ds, d6 , d7 , Yd7 , dg, and d9 , and use these as input on successive
executions.
ALGORITHM PRUA*
Preliminary test 1 accounts for the possibility of Z < O. Preliminary tests 2 and 3
use the squeeze method with the inequalities x-I / x :::: 2ln x :::: -3 + 4x - x 2 , 0 <
384 C HAP TE R 8. SAM PLIN G FRO M PRO B A B I LIT Y DIS T RIB UTI 0 N S
1. If ZI, Z2, ... , Zn are independent Bernoulli random variables with parameter p, then
Z = ZI + ... + Zn is from B(n, p).
2. Let /-L = np. For fixed /-L, the distribution of Z converges to P(/-L) as n -+ 00 and
p -+ 0 simultaneously.
Algorithm ITR applies the inverse transform method with Po = (1 - p)n and c(z) =
(n - Z + 1)p/z(1 - p), which consumes O(np) time. If one takes Po = (1 - iW and
+
c(z) = (n - z l)p/z(1- p), where p = min(p, 1- p), and returns Z if p :::: andn - Z !
if p > !,
then the algorithm has O(n min(p, 1 - p)) time. Algorithm BER provides an
alternative approach that merely generates n independent Bernoulli samples and takes their
total as Z. Although this avoids the need for the logarithmic and exponential evaluations
implicit in (1 - p)n , it takes O(n) time. Kachitvichyanukul and Schmeiser (1988) report that
the inverse transform approach performs faster than the Bernoulli approach does.
8.17. BINOMIAL DISTRIBUTION 385
ALGORITHM BER
Although asymptotic properties 2 and 3 may tempt one to employ Poisson or normal
generation to produce an approximate binomial Z, the resulting error may lead to seriously
misleading results in the Monte Carlo experiment.
Fishman (1979), Ahrens and Dieter (1980), Devroye and Naderasamani (1980),
Kachitvichyanukul and Schmeiser (1988), and Stadlober (1991) all describe binomial gen-
erating algorithms with bounded mean computing times. We describe Stadlober's approach
based on the ratio-of-uniforms method for p ::: np ::: 1, and!,
r(z):= PLzJ = L(n + 1)pj!(n - +
L(n 1)pj)! [p/(1- p)]LzJ-L(n+I)pJ. (8.83)
maxt PLtJ Lzj!(n - Lzj)!
A 1
al :=np+-, (8.84b)
2
wherek* = lal - J2a l (1- p) Jork* = fa l - J2a l (l- p)l maximizesIQ(a l , a2)1flP I·
Also, for np = 1,
lim a;(n, p) = 1.5,
n~oo
(8.86a)
p-40
386 CHAPTER 8. SAMPLING FROM PROBABILITY DISTRIBUTIONS
a2 = a2 =
A
2 np(1- p)
[ 1] 3 (3
+"2 Ie + "2 - V;' (8.87)
(8.88a)
and
(8.88b)
ALGORITHM BRUA*
Method:
Repeat
randomly generate X and Y from U (0, 1)
W +--d4 +d7 (Y- ~)/X
if W < 0 or W 2: d ll , reject (fast rejection)
otherwise:
Z+--LWJ
if Z > k', compute Yz in line
if n - Z > k', compute Yn - Z in line
T +-- (Z - d lO )d9 + dJ2 - Yz - Yn - Z
if X(4 - X) - 3 :s T, accept (fast acceptance)
otherwise:
if X(X - T) 2: 1, reject (fast rejection)
otherwise:
if 2 In X :s T, accept
until accept.
If P :s ~, return Z; otherwise, return n - Z.
For small n min(p, 1 - p), Algorithm ITR is less time-consuming than virtually all
bounded-time algorithms are for binomial generation. Accordingly, using Algorithm ITR for
n min(p, 1- p) :s 10, andAlgorithmBRUA* otherwise provides a reasonable compromise.
ITR is applied to Poisson and binomial generation. Algorithm HYP provides an alternative
approach based on direct sampling without replacement and takes O(n) time, but avoids
the need to compute Po. However, it can require n uniform deviates, in contrast to one
deviate for Algorithm ITR. If repeated generation with the same a, fJ, and n is to occur,
then precomputing Po, storing it, and using it on successive executions of Algorithm ITR
makes this approach considerably more efficient than sampling without replacement as in
Algorithm HYP (Kachitvichyanukul and Schmeiser 1985).
ALGORITHM HYP
Kachitvichyanukul and Schmeiser (1985) describe a bounded mean computing time al-
gorithm for generating a hypergeometric sample that employs the acceptance-rejection
method. Stadlober (1989) describes a bounded mean computing time algorithm that
employs the ratio-of-uniforms method of Section 8.15. We describe this last method here.
We have
and
(8.91)
and
(8.92b)
where
2 a+f3-n a f3
a :=n· '--'--.
a+f3-1 a+f3 a+f3
(8.93)
where
and
Yj := In j!,
ALGORITHM HRUA*
1. Let Y j , Y2 ,
••• be a sequence of i.i.d. Bernoulli distributed random variables with
2. Let fJ = -1/ In P and let X denote a random variable from £ (fJ). Then LX J has the
p.m.f. (8.94).
ALGORITHM GEO
r(r+i) i
Pi = ru + l)r(r) 0 -
r
p) p, o< p < 1, r > 0, i = 0, 1, ... , (8.95)
2. For r integer, let ZJ, ... , Zr denote i.i.d. random variables from ge(p). Then Z =
ZI + ... + Zr has the p.m.f. (8.95).
3. Let X be from 9 (r, 1) and let Y given X be from P(XpI(l - p)). Then Y has the
p.m.f. (8.95).
ALGORITHM NEGBIN
where
0< Pi < 1,
PI + ... + Pr = 1,
8.21. M U L TIN 0 M I A L DIS TR I BUT ION 393
Zi integer ::: 0,
ZI + ... + Zr = n,
and denoted by M (n, PI, ... , Pr). Observe that Zj has the binomial p.m.f.
and more importantly, Zj given ZI = ZI, ... , Zj_1 = Zj-I has the binomial p.m.f.
where
Algorithm MULTN exploits this property. If used together with a bounded mean
computing time algorithm such as BRUA*, the worst-case mean computing time is OCr).
However, an opportunity does exist to improve efficiency further.
Let
Sj:=ZI+",+Zj, J = 1, ... , r,
So:= 0,
and let N denote the mean number of required binomial generations. Then
r
EN = I>
j=1
pr(Sj_1 < n, Sj = n)
r
= L[pr(Sj = n) - pr(Sj_1 = n)] (8.98)
j=1
= tJ [(tpi)n -(I:Pi)n]
J=I 1=1 1=1
Clearly, EN is minimized if PI ::: P2 ::: ... ::: PrJ suggesting that one rearrange cell proba-
bilities into descending order before executing Algorithm MULTN. The saving is especially
substantial if a single P j is considerably larger than the remaining ones.
394 C HAP TE R 8. 5 AMP LIN G FRO M PRO BA B I LIT Y DIS T RIB UTI 0 N S
ALGORITHM MULT....
ALGORITHM SKIP
• The principal algorithms for generating these samples are the inverse-transform, com-
position, acceptance-rejection, ratio-of-uniforms, and exact-approximation methods.
All are theoretically correct and apply to both continuous and discrete distributions.
• Random variate generating algorithms fall into three categories: those with computing
times that are independent of parameter values (1), those that tend to grow as functions
of the parameters of the distribution (2), and those that have an upper bound on
computing time (3). Whenever possible, it is preferable to use an algorithm of type
(1) or type (3).
• The cutpoint method, based on the inverse-transform approach, and the alias method,
based on the composition approach, allow sampling from a table in time independent
of its size.
• The squeeze method (Section 8.5.1) provides a means of further reducing computing
times for the acceptance-rejection and ratio-of-uniforms techniques.
• Virtually all simulation languages provide library routines for sampling from com-
monly encountered distributions. These include the exponential, Gamma, Erlang,
normal, uniform, Weibull, binomial, Poisson, geometric, and negative binomial. Some
routines may be based on approximation rather than theoretically exact algorithms.
Also, some may have parameter-dependent computing times.
8.24 EXERCISES
INVERSE TRANSFORM METHOD
t? 8.1 Prove that if U is from U (0, 1), then V = 1- U is from U (0, 1).
396 C HAP TE R 8. SAM P LIN G FRO M PRO BA B I LIT Y DIS TR I BUT ION S
z-c
-- if c::: z::: a+c,
ab
1
fez) = - if a+c:::z:::b+c, (8.99)
b
a+b+c-z
if b + c ::: z ::: a + b + c, O<a:::b:
ab
a. Devise an algorithm for generating samples based on the inverse transform method.
b. Show that for appropriately chosen al> az, and a3, and UI and Uz independent of
U (0,1), Z = alU I + azUz + a3 has the trapezoidal p.d.f. in equation (8.1).
~ 8.4 Let VJ, ... , Vn be i.i.d. from U (a, b) and let V(l), V(Z), .•. , V(n) denote the order
statistics of VI, .•. , V n • That is, V(I) ::: V(Z) ::: ... ::: V(n)' It is known that V(j) has the p.d.f.
r(n + 1) . I .
f ·(v) = (v - a)J- (b - v)n-J(b - a)-n 0< a < v < b
J rU)r(n - j + 1) - - -
where r(k) = (k - 1)! for k integer 2: 1. Let XJ, ... , Xn denote U.d. random variables
that have the non-central Cauchy distribution
F(x) = -1
2
+ -1 tan- I
7r
(x - c)
--
d
d > 0, -00 < c< 00, -00 < x < 00.
a. Describe an algorithm for randomly generating Y = max(XJ, ... , Xn) using exactly
one uniform deviate U from U(O, 1).
~ 8.5 Apply the inverse transform method for generating a sample, X, from the d.f.
~ 8.6 Let U and V be independent samples, each drawn from U(O, 1). Use U and V
together with the inverse transform and composition methods to generate a sample X from
8.24. Ex ERe I 5 E 5 397
the d.f.
F(x) = 1 00
h(y)G(x, y)dy,
where
1
hey) = -e- y1jJ f3 > 0, y ~ 0
f3
and
1
G(x, y) = 1 + e- (x-y
)I
C
c > 0, -00 < x < 00.
a. Devise an algorithm for generating random samples based on the inverse transform
method.
b. For the special case of m2 - ml = m3 - m2, devise a generating algorithm that relies
on a linear combination of independent VI and V 2 each from U (0,1).
CUTPOINT METHOD
e? 8.8 Derive the mean generating cost doEl;';, + (d l - do)E(l;';,IZ > b*)(l - qb*) for
Algorithm CM.
ALIAS METHOD
e? 8.9 Apply cutpoint method 2 for large b - a to the Poisson distribution with mean
A = 100 and using m = 25,50,100,200 cutpoints. For each m, compute:
<ff? 8.10 Prove that everyp.m.f. {PI, ... , Pn} can be expressed as an equiprobable mixture
of n - 1 two-point p.m.f.s.
<ff? 8.11 Define k = b - a + 1 and suppose that Pa < 1/ k and Pi ::: 1/ k, a + 1 ::::: i ::::: b.
Show that rl ::::: 1, VI E g, in step * in Algorithm ALSET. This property ensures that the
algorithm continues to iterate until all aliases are assigned.
ACCEPTANCE-REJECTION METHOD
where
b
h(z) ~ 0, Lh(z) = 1,
z=a
c = max[f(z)/
z
h(z)]' 0::::: g(z) ::::: 1.
Suppose one samples Z from {h(z)} and U from U (0, 1). If U ::::: g(Z), show that Z has the
p.m.f. {fez)}.
a
x-a
F(x) = ( - -) Ct > 0, 0::::: a::::: x::::: b. (8.100)
b-a
Give an algorithm for sampling from (1) based on the acceptance-rejection method. Identify
any additional restrictions on Ct, a, and b and give the mean number of trials until success.
<ff? 8.14 Let X have bounded p.d.f. f over the finite domain [a, b] and define A =
maxx [f(x)]. Let U and Y be independent and fromU (0,1) andU (a, b), respectively, and
let S denote the event U ::::: f(y)/A.
I(
c. Suppose one randomly generates X from the p.d.f.
d. Describe an upper bound pretest that reduces the mean number of exponentiations
until success. Do not address the issue of a lower bound pretest. Hint: A picture may
be helpful.
!
e. Modify the generating method in part c to increase preS) by without introducing
any new nonlinear transformations to generate U and Y. Hint: The picture in part d
may again be helpful.
v > 0, z ::: 0 :
a. Devise a factorization c(ex, v)g(z, ex, v)h(z, v) for the Gamma p.d.f.
c. Show analytically how the mean number of trials varies as a function of increasing ex.
d. Prepare an algorithm for Gamma generation that minimizes the mean number of
exponential and logarithmic function evaluations on each trial. Assume no pretest.
z ::: 0,
where
f.1 = ex)..,
A = (2ex - 1)1/2,
400 CHAPTER 8. SAMPLING FROM PROBABILITY DISTRIBUTIONS
a ::: 1, z ::: 0,
c. Other choices of f.L and A. are possible. Explain the appeal of the choices made here.
{3
h(z, {3, 71) = {hr[{32 + (z - 71)2]' {3 > 0, -00 < 71 < 00, Z ::: 0,
where
1 1 -1
() = - - - tan (-71/{3):
2 7r
a. Derive a factorization c(a, {3, 71)g(z, a, {3, 71)h(z, {3, 71) for the Gamma p.d.f.
a ::: 1, z ::: 0,
b. Show that 71 = a-I and {3 = (2a - 1)1/2 are acceptable choices and give a rationale
for using them.
c. With the choice of {3 and 71 in part b, show that liffia--+oo c(a, {3, 8) = 7r /2.
d. Prepare an algorithm for Gamma generation that minimizes the number of
exponential and logarithmic function evaluations per trial. Assume no pretest.
SQUEEZE METHOD
@J 8.21 Prove the results for pr(Sd and pr(Su) in expressions (B.23a) and (B.23b),
respectively.
a. Devise a pretest that reduces the mean number ofexponential and logarithmic function
evaluations.
b. Derive an expression for the reduced mean number of function evaluations in using
the pretest and compare it with the corresponding mean in Exercise B.15 as ex increases.
@J 8.24 Consider the inequality </Jz -In</J - 1 ::: lnz, \;f</J and z > O. For the algorithm
in Exercise B.16:
a. Devise a pretest that reduces the number of exponential and logarithmic function
evaluations.
b. Derive an expression for the mean number of function evaluations in using the pretest
and compare it with the corresponding mean in Exercise B.16 as ex increases.
a. Devise a pretest that reduces the number of exponential and logarithmic function
evaluations.
b. Derive an expression for the reduced mean number of function evaluations and
compare it with the corresponding mean in Exercise B.17 as ex increases.
402 CHAPTER 8. SAMPLING FROM PROBABILITY DISTRIBUTIONS
f(x) = ~sinx
2
0:::: x:::: n. (8.101)
c. Give the probability of success on a trial and the mean number of trials until success.
e. Using the squeeze method, devise a piecewise linearlower bound, {gdx)}, for {g(x)}
that reduces the mean number of sine evaluations until success.
f. Describe an algorithm that incorporates this lower bound into the acceptance-
rejection method.
g. Give the mean number of sine evaluations until success for the algorithm in part f.
RATIO-OF-UNIFORMS METHOD
c. Devise a pretest that reduces the frequency of exponential and logarithmic function
evaluations.
~ 8.28 Prove pr(Td and pr(Tu) in expressions (8.33a) and (8.33b), respectively.
~ 8.29 (Kinderman and Monahan 1980). Consider generating samples from the Gamma
p.d.f.
> 1, Z ::: 0,
8.24. Ex ERe I S E S 403
a. Give {r(z)} and devise the bounds x*, y*, and y* in expression (S.27a).
c. Derive an expression for the mean number of trials until success and characterize its
behavior as a -+ 00.
f. For d and W as defined in part d, let Tu denote the event W ~ Z/a + d. Show
that Tu provides a rejection pretest that reduces the mean number of exponential and
logarithmic function evaluations.
@l 8.31 Give an algorithm for sampling from (S.100) based on the ratio-of uniforms
method. Identify any additional restrictions on a, a, and b and give the mean number of
trials until success.
a) Devise a formulation for sampling X from {f (x)} using the ratio-of-uniforms method
with the enclosing P being the smallest rectangle containing Q.
d. Devise a pretest for reducing the mean number of sine evaluations until success.
f. For the amended algorithm of part e, give the mean number of sine evaluations until
success.
404 CHAPTER 8. SAMPLING FROM PROBABILITY DISTRIBUTIONS
d. Devise a pretest for reducing the mean number of sine evaluations until success.
f. For the amended algorithm of part e, give the mean number of sine evaluations until
success.
EXACT-APPROXIMATION METHOD
~ 8.34 (Marsaglia 1984). For the half-normal dJ. F(z) = .J2/rr Joz e- w2/2 dw, consider
the approximation
c > 0, Z ::: o.
O::s:x::S:l.
O::S:P::S:l.
Determine the c that maximizes the left side of this inequality and then determine the
largest possible value for p.
EXPONENTIAL GENERATION
~ 8.35 Let X and Y be independent random variables from U (0, 1) and U (0, 2/e),
respectively.
8.24. Ex ERe I S E S 405
b. Let W denote the event Y .::: -2X In X. Show that pr(W) = ej4 = 0.6796.
c. Using the inequalities (8.19), find a function {h*(x)} that minorizes -2x lnx and a
function {h*(x)} that majorizes -2x lnx.
d. Let WL denote the event Y .::: hAX) and Wu the event Y .::: h*(X). Derive expressions
for pr(Wd and pr(Wu ) and evaluate them.
NORMAL GENERATION
t!? 8.36 Let U I and U 2 be independent random variables from U (- ~, ~). Show that if
Uf + ui .::: ~,then Y = ut/(Uf + Un l/2 has the same distribution as cos2nU and
Z = uz/(Uf + Un l/2 has the same distribution as sin 2nU, where U is from U (0, 1). See
Theorem 8.5.
CAUCHY GENERATION
a. Show that if Xi + X~ .::: 1, then Z = X t/ X 2 has the Cauchy distribution C(O, 1).
b. Determine pre acceptance).
GAMMA GENERATION
t!? 8.38 Show that if X is from 9 (a, 1), then Z = f3X is from 9 (a, f3).
t!? 8,42 Determine the mean number oflogarithmic function evaluations for Algorithm
GKMI.
406 CHAPTER 8. SAMPLING FROM PROBABILITY DISTRIBUTIONS
a. Show that if 0 < X' < I,then (X', Y') isuniformlydistributedonP'(a) nI 2 , and
on any trial
e+2
pr(O < X' < 1) = 1 - ..fi
2J(re( vie + 2)
1jfF 8.44 Determine the feasibility of employing the acceptance-rejection method for
sampling Z from 9 (a, 1), a::: I, for {h(z) = J2/rre- z2j2 , z ::: OJ.
BETA GENERATION
1jfF 8.45 Show that {c(a, f3, t), 0:::: t :::: I} in expression (8.62b) is bounded for all 0 < a,
f3 < 1. Find sUPO<a ..B::;:l c(a, f3, t*) for t* in expression (8.63).
POISSON GENERATION
1jfF8.47 Derive an expression for the mean number of evaluations ofln X in Algorithm
PRUA*.
1jfF i,
8.48 For A. > 1.75 andal = A. + showthatai in definition (8.79a) withk* = ral -
~l minimizes the mean number of trials (8.77). Hint: First, show that the continuous
version of the problem has its optimal solution at Zo > ral - ",fiall.
1jfF 8.50 Prove the validity of preliminary test 3 given that preliminary test 2 fails in
Algorithm PRUA*.
BINOMIAL GENERATION
1jfF 8.51 Prove the validity of the fast acceptance test in Algorithm BRUA*.
1jfF 8.52 Prove the validity of the second fast rejection test given the failure of the fast
acceptance test in Algorithm BRUA*.
8.24. Ex ERe I S E S 407
g? 8.55 Prove the validity of the fast acceptance test in Algorithm HRUA*.
g? 8.56 Prove the validity of the second fast rejection test given the failure of the fast
acceptance test in Algorithm HRUA*.
g? HANDS-ON-ExERCISES
These exercises provide opportunities to prepare and execute computer programs for sam-
pling on a computer and to analyze the results. Each requires a source of pseudorandom
numbers as input.
Pi Pi
.001 11 .040
2 .008 12 .108
3 .010 13 .162
4 .011 14 .037
5 .081 15 .012
6 .049 16 .028
7 .048 17 .041
8 .059 18 .029
9 .034 19 .100
10 .142
408 CHAPTER 8. SAMPLING FROM PROBABILITY DISTRIBUTIONS
b. Using these cutpoints as input to a computer program based on Algorithm CM, ran-
domly generate 10,000 samples from the distribution. Create a plot that compares the
histogram of these data with the distribution {Pi} and record the computing time per
sample (for comparison with the corresponding time for the alias method in Algorithm
ALIAS in Exercise S.H.2).
ALIAS METHOD
a. Use Algorithm ALSET to determine the aliases Bb ... , B19 and the probabilities
P(A 1 ), •.. , P(A I9 ).
c. Compare the computing time per sample here with that in Exercise S.H.I
GAMMA GENERATION
,ff? H.3 This exercise compares the performances of the acceptance-rejection and ratio-
of-uniforms methods for generating random samples from 9 (a, 1), 1 :::: a :::: 2.
a. Using the algorithm with the optimal choice of v and pretest devised in Exercises 3
and IS, prepare a computer program to generate samples from 9 (a, 1), a ::: l.
c. For each program and each a E {l.2, 1.4, 1.6, I.S, 2}, generate 10,000 samples from
9 (a, 1) and record the computing time.
d. Compare the 10 recorded times and determine which algorithm is preferred for a E
[1,2].
POISSON GENERATION
,ff? H.4 This exercise applies the ratio-of-uniform method to sampling from the Poisson
distribution. Section 8.15 contains the supplementary theory on which the method is based.
8.24. EXERCISES 409
You are encouraged to study it and Section 8.16 carefully beore performing the computing
assignment. For A = 1,2,4, 8, 16,32, generate independent samples of size n = 100,000.
c. For each A, compute d3 , ••• , d 9 and install the computed values in the amended
program of part b. Execute the program and again record the CPU generating time
and compute the sample average and sample variance of the n outcomes.
d. How do the three programs compare with regard to CPU generating time?
e. For each A, how do the sample averages of the number of trials compare with theory?
Note: If the simulation programming language selected for part a allows for programming
as in parts b and c and is also used there, the comparison will be more meaningful. If
n = 100, 000 does not suffice to get meaningful estimates of average generation time,
increase n.
t!? H.5 This exercise applies the ration -of-uniform method to sampling from the negative
binomial distribution. Section 8.15 contains the supplementary theory on which the method
is based. You are encouraged to study it study it and Sections 8.13 (a > 1), 8.16, and 8.20 care-
fully before performing the computing assignment. For each A := i!p E {I, 2, 4,8, 16, 32}
and r E {I, 5, 2.5, 5, IO}, generate samples of size n = 100,000.
record CPU generating time and compute the sample average and sample variance of
the n outcomes.
c. How do the two programs compare with regard to CPU generating time?
d. For each A and r, how do the sample averages of number of trials compare?
Note: If the simulation programming language selected for part a allows for programming
as in part b and is also used there, the comparsion will be more meaningul. If n = 100, 000
does not suffice to get meaninful estimates of average generation time, increase n.
8.25 REFERENCES
Afflerbach, L., and W. Hormann (1990). Nonuniform random numbers: a sensitivity analysis
for tranformation methods, Lecture Notes in Economics and Mathematical Systems, G.
Plug and U. Dieter, eds., Springer-Verlag, New York.
Agrawal, A., and A. Satyanarayana (1984). An 0(1£ I) time algorithm for computing the
reliability of a class of directed networks, Oper. Res., 32, 493-515.
Aho, A.V., J.E. Hopcroft, and J.D. Ullman (1974). The Design and Analysis of Computer
Algorithms, Addison-Wesley, Reading, MA.
Ahrens, J.H. (1989). How to avoid logarithms in comparisons with uniform random
variables, Computing, 41,163-166.
Ahrens, J.H. (1993). Sampling from general distributions by suboptimal division of domains,
Grazer Math. Berichte 319, Graz, Austria.
8.25. REFERENCES 411
Ahrens, J.H., and U. Dieter (1972). Computer methods for sampling from the exponential
and normal distributions, Comm. ACM, 15, 873-882.
Ahrens, J.H., and U. Dieter (1974a). Non-Uniform Random-Numbers, Institut fur Math.
Statistik, Technische Hochschule in Graz, Austria.
Ahrens, J.H., and U. Dieter (1974b). Computer methods for sampling from Gamma Beta,
Poisson and binomial distributions, Computing, 12, 223-246.
Ahrens, J.H., and U. Dieter (1980a). Sampling from the binomial and Poisson distributions:
a method with bounded computation times, Computing, 25,193-208.
Ahrens, J.H., and U. Dieter (1982a). Generating Gamma variates by a modified rejection
technique, Comm. ACM, 25, 47-53.
Ahrens, J.H., and U. Dieter (1982b). Computer generation of Poisson deviates from modified
normal distributions, ACM Trans. Math. Software, 8,163-179.
Ahrens, J.H., and U. Dieter (1985). Sequential random sampling, ACM Transactions on
Mathematical Software, 11, 157-169.
Ahrens, J.H., and U. Dieter (1988). Efficient tablefree sampling methods for the exponential,
Cauchy and normal distributions, Comm, ACM, 31, l330-l337.
Ahrens, J.H., and U. Dieter (1991). A convenient sampling method with bounded com-
putation times for Poisson distributions, The Frontiers of Statistical Computation,
Simulation and Modeling. P.R. Nelson, E.J. Dudewicz, A.Oztiirk, and E.C. van der
Meulen, editors American Science Press, Syracuse, NY, l37-149.
Anderson, T.W. (1958). An Introduction to Multivariate Statistical Analysis, John Wiley and
Sons.
Atkinson, A.C. (1979). The computer generation of Poisson random variables, Appl. Statist.
28,29-35.
Atkinson, A.C., and J. Whittaker (1976). A switching algorithm for the generation of beta
random variables with at least one parameter less than one, J. Roy. Statist. Soc., Series
A, 139,462-467.
Best, D.J. (1978). A simple algorithm for the computer generation of random samples from
a Student's t or symmetric beta distribution, Proceedings of the 1978 COMPSTAT
Conference, Leiden, 341-347.
Best, D.J. (1983). A note on gamma variate generators with shape parameter less than unity,
Computing, 30, 185-188.
Box, G.E.P., and M.E. Muller (1958). A note on the generation of random normal deviates,
Ann. Math. Statist, 29, 610--611.
412 CHAPTER 8. SAMPLING FROM PROBABILITY DISTRIBUTIONS
Broder, A.Z. (1989). Generating random spanning trees, Thirtieth Annual Symposium on
Foundations of Computer Science, 442-447.
Broder, A.Z., and A.R. Karlin (1989). Bounds on the cover time, J. Theoretical Probability, 2,
101-120.
Chen, H-C., and Y. Asau (1974). On generating random variates from an empirical
distribution, AIlE Trans., No.2, 6,163-166.
Cheng, R.C.H. (1977). The generation of Gamma variables with nonintegral shape
parameter, Appl. Stat., 26, 71-75.
Cheng, R.C.H. (1978). Generating beta variates with nonintegral shape parameters, Comm.
ACM, 21, 317-322.
Cheng, R.C.H., and G.M. Feast (1979). Some simple Gamma variate generators,Appl. Statist.,
28, 290-295.
Cheng, R.c.H., and G.M. Feast (1980). Gamma variate generators with increased shape
parameter range, Comm. ACM, 23, 389-394.
Devroye,1. (1981). The computer generation of Poisson random variables, Computing, 26,
197-207.
Devroye,1. and A. Naderisamani (1980). A binomial variate generator, Tech. Rep., School
of Computer Science, McGill University, Montreal.
Feller, W. (1971). An Introduction to Probability Theory and Its Applications, Volume II,
second ed., Wiley, New York.
Fisher, R.A., and E.A. Cornish (1960). The percentile points of distributions having known
cumulants, Technometrics, 2, 209-225.
Fishman, G.S. (1976). Sampling from the gamma distribution on a computer, Comm. ACM,
19,407-409.
Fishman, G.S. (1978). Principles of Discrete Event Simulation, Wiley, New York.
Fishman, G.S. (1979). Sampling from the binomial distribution on a computer, J. Amer.
Statist. Assoc., 74,418-423.
Fishman, G.S. (1996). Monte Carlo: concepts, Algorithms and Applications, Springer-Verlag,
New York.
Fishman, G.S., and 1.R. Moore (1984). Sampling from a discrete distribution while
preserving monotonicity, Amer. Statist., 38, 219-223.
8.25. REF ERE NeE 5 413
Fishman, G.S., and L.R. Moore (1986). An exhaustive analysis of multiplicative congruential
random number generators with modulus 231 -1, SIAM J. Sci. Stat. Comput., 7, 24-45.
Fishman, G.S., and L.S. Yarberry (1993). Generating a sample from a k-cell table with
changing probabilities in O(log2 k) time, ACM Trans. Math. Software, 19,257-261.
Gerontidis, I., and R.L. Smith ( 1982). Monte Carlo generation of order statistics from general
distributions, Appl. Statist, 31, 238-243.
Hastings, c., Jr. (1955). Approximations for Digital Computers, Princeton University Press,
Princeton, NJ.
Hormann, W., and G. Derflinger (1993). A portable random number generator well suited
for the rejection method, ACM Transactions on Mathematical Software, 19,489-495.
Kinderman, A.J., and J.E Monahan (1980). New methods for generating Student's t and
Gamma variables, Computing, 25,369-377.
Knuth, D. (1973). The Art ofComputer Programming: Sorting and Searching, Addison-Wesley,
Reading, MA.
Kronmal, Richard A., and A.v. Peterson, Jr. (1979). On the alias method for generating
random variables from a discrete distribution, TheAmer. Statist., 4, 214-218.
Lurie, D., and H.O. Hartley (1972). Machine-generation of order statistics for Monte Carlo
computations, TheAmer. Statist., 26, 26-27.
MacLaren, M.D., G. Marsaglia, and T.A. Bray (1964). A fast procedure for generating
exponential random variables, Comm. ACM, 7, 298-300.
414 CHAPTER 8. SAMPLING FROM PROBABILITY DISTRIBUTIONS
Marsaglia, G., K. Ananthanarayanan, and N.J. Paul (1976). Improvements on fast methods
for generating normal random variables, Inf Proc. Letters, 5, 27-30.
Marsaglia, G., M.D. MacLaren, and T.A. Bray (1964). A fast procedure for generating normal
random variables, Comm. ACM, 7, 4-10.
Marsaglis, G., A. Zaman, and J. Marsaglia (1994) Rapid evaluation of the inverse of the
normal distribution function, Statistics and Probability Letters, 19, 259-266.
Minh, D.L. (1988). Generating gamma variates, ACM Trans. on Math. Software, 14, 261-266.
Moro, B. (1995). The full Monte, Risk, 8, 57-58.
Ross, S. and Z. Schechner (1986). Simulation uses of the exponential distribution, Stochastic
Programming, M. Lucertini, ed., in Lecture Notes in Control and Information Sciences,
Springer-Verlag, New York, 76, 41-52.
Schmeiser, B.W., and A.J.G. Babu (1980). Beta variate generation via exponential majorizing
functions, Oper. Res., 28, 917-926. Errata: Oper. Res., 31,1983,802.
Schmeiser, B.W., and R. Lal (1980). Squeeze methods for generating gamma variates, J. Amer.
Statist. Assoc. 75, 679-682.
Schmeiser, B.W., and V. Kachitvichyanukul (1981). Poisson random variate generation, Res.
Memo. 8184, School ofIndustrial Engineering, Purdue University.
Schreider, Y.A. (1964). Method of Statistical Testing, Elsevier, Amsterdam.
Schucany, W.R. (1972). Order statistics in simulation, J. Statist. Comput. and Simul., 1,
281-286.
von Neumann, J. (1951). Various techniques used in connection with random digits,
Monte Carlo Method, Applied Mathematics Series 12, National Bureau of Standards,
Washington, D.C.
8.25. REFERENCES 415
Walker, A.J. (1974). New fast method for generating discrete random numbers with arbitrary
frequency distributions, Electronic Letters, 10, 127-128.
Walker, A.J. (1977). An efficient method for generating discrete random variables with
general distributions, ACM Trans. on Math. Software, 3, 253-256.
Chapter 8 reveals that every algorithm that generates a sequence of i.i.d. random samples
from a probability distribution as output requires a sequence of i.i.d. random samples from
U(D, 1) as input. To meet this need, every discrete-event simulation programming language
provides a pseudorandom number generator that produces a sequence of nonnegative integers
ZI, Z2, ... with integer upper bound M > Zi Vi and then uses Ul> U2, ... , where Ui :=
Z;/ M, as an approximation to an i.i.d. sequence from U(D, 1).
Since Ui E M ~ Mo := {D, -h, ii, ... , MM1}, this generating procedure incurs a
discretization error that depends on how large M is and on how closely M resembles Mo.
Whereas an i.i.d. sequence from U(D, 1) is continuous, U 1 , U2 , ••• is a discrete sequence.
Moreover, the selected generating procedure determines how well the distribution of any
subset of U1 , U2, ... , namely Ujp Uh , ... , Ujk for arbitrary positive integers k, j, ... , A,
approximates the distribution of a k-tuple of i.i.d. uniform random variables on [D, 1). Most
importantly, there is the issue of how these discretization and distributional errors in the
generation of U1 , U2 , ••• propagate themselves in the sequence generated by anyone of the
algorithms in Chapter 8.
All generators described in this chapter exploit the concept of congruence. We say that
a is congruent to b modulo M if M divides a-b. In symbols, one writes a == b (mod M),
418 CHAPTER 9. PSEUDORANDOM NUMBER GENERATION
where M is called the modulus and == is called the congruence symbol. As examples, 7 == 1
(mod 6), 11 == 2 (mod 3), 338 == 8 (mod 11), and -5 == 1 (mod 6). Also, X = (B + C)
(mod M) denotes that X equals the quantity B + C reduced modulo M.
where Zo denotes the seed, A is a positive integer, called the multiplier, and M is the modulus.
Expression (9.1) is algebraically equivalent to
Zi = AZi- 1 - MK i , i ~ 1, (9.2)
where
Ki := LAZi-J/MJ.
To generate numbers from expression (9.1), one needs to prime the generator with a
seed. For example, to generate Zl, Zo acts as the seed; to generate Zz, Zl acts as the seed; to
generate Zn, Zn_l acts as the seed. The simplicity of priming this generator represents one
of its attractive features.
Reproducibility is another important feature. In designing a discrete-event simulation
experiment, it is not unusual to conduct a preliminary run to identify errors in program
logic and previously unexpected sample-path behavior. Such an observation often prompts
one to amend the program. By recording the seed for the first run, one can make a new run
with the modified program but using the same seed as input. Provided that the modified
program leaves the logic for assigning pseudorandom numbers to each source of variation
untouched, the sample-path behavior of the new run reflects only the code change and
contains no new variation due to sample generation. Therefore, the ability to reproduce
the exact same sampling variation on successive runs is a valuable tool in judging sample-
path changes that result from modified programs. All pseudorandom number generators
described in this chapter offer this feature of reproducibility.
Expression (9.1) makes it clear that the number of distinct values the Zi assume cannot
exceed M -1. Just how many distinct values are possible depends on the relationship between
9.1. LINEAR (ONGRUENTIAL GENERATORS 419
ZI = AZo - MK I ,
Z2 = A2Zo - MK2 - MKIA,
Z3 = A 3Z 0 - MK3 - MK2A - MKIA2, (9.3)
Since 1 ::::: Zi < M for 1 ::::: i ::::: n, the quantity Kn + Kn-1A + ... + KIA n- 1 must
be the largest integer in An Zo / M, so that expression (9.1) has the alternative representation
Observe that Zo completely determines the {Zi' i :::: I} integer sequence once A and
M are fixed. Therefore, our ability to make U I , U2 , ••• resemble a continuous-valued i.i.d.
sequence with elements fromU(O, 1) can, at best, depend on the choice of A and M.
9.1.1 PERIOD
Perhaps the most obvious property of the generator (9.1) is that once Zn = Zo for
some integer n > 0, then Zn+i = Zi for all i = 1, 2, .... We call
the period of the generator for given Zo, A, M. Clearly, for given Zo and M we would like to
choose the multiplier A to maximize the period. In particular, we would like P (Zo, A, M) =
M - 1, which would make the period identical for all seeds Zo E Mo, and thus independent
of the starting seed. Recall from expressions (9.4) and (9.5) that Zn =
Zo implies
If n =M - 1 is the smallest integer satisfying the congruence (9.6), then it must hold
for all Zo E Mo, so that
(A M - I - I) (mod M) = O. (9.7)
420 CHAPTER 9. PSEUDORANDOM NUMBER GENERATION
(9.8)
and the product is taken over all distinct primes p dividing n. An A that satisfies expression
(9.7) for M prime is called a primitive root of M. Expression (9.8) defines the Euler totient
function.
As illustration, the largest integer that a 32-bit register in a computer can hold is
M = 231 - 1, which happens to be prime. Since M - 1 has the prime factorization M - 1 =
231 - 2 = 2 X 32 X 7 x 11 x 31 x 151 x 331, these exist rjJ(M - 1) = 534,600,000 primitive
roots of2 31 -1, each one of which guarantees a full period P = M - 1 for the multiplicative
congruential generator (9.1).
To illustrate the relationship between A and the period, Table 9.1 lists the sequences
that result for the prime-modulus generator Zi = AZi - 1 (mod 11). The table reveals
rjJ(11 - 1) = = =
10 x (1 - ~)(1 - ~) 4 primitive roots A 2, 6, 7, and 8. It also reveals that
= =
A 6 generates the same full period as A 2, but in reverse order. Moreover, A 7 and =
=
A 8 have a similar relationship. We next explain these relationships.
Xi = AXi - 1 (mod M)
9.1. LIN EAR CON G RUE NT I A L G ENE RAT 0 R5 421
and
Yi - I = BYi (mod M)
with multipliers A and B and modulus M. We want to establish the condition on A and B
that guarantees Xi = Yi given X i - I = Yi - I for all i ::: 1. Since
Xi = AXi _ 1 - KM,
Yi - I = BYi - K'M,
for K := LA Xi-I! MJ and K' := LB Y;/ MJ, X i - I = Yi - I is equivalentto
or, equivalently,
AB -1 == 0 (modM). (9.9)
If B satisfies this congruence for given M and A, we say that B is the multiplicative inverse
ofA modulo M.
contains none of these factors. Section 9.5 rates these alternative multipliers with regard to
their randomness properties.
Multiplicative congruential generators with M = 2P for ,8 :::: 3 are also in common use,
although less so than prime modulus generators. The appeal of "powers-of-two" generators
stems from the computational efficiency they allow.
All modern-day computers perform computations in base 2 using either integer or
floating-point arithmetic. Integer arithmetic takes less computing time, and because of the
relatively slow speeds that characterized computers in the earlier days a natural preference
arose for using integer rather than floating-point arithmetic, whenever possible.
To evaluate Zi in expression (9.1) takes multiplication (AZi-d, division and trun-
cation (Ki = LAZi-dMJ), multiplication (MKi)' and subtraction (AZ i - 1 - MKi). Of
these, multiplication and division are the more time-consuming operations. By choosing
a modulus M = 2P, a pseudorandom-number-generating program can be written in the
machine language of the chosen computer that would use integer arithmetic and replace all
but the first multiplication (AZi-d by bit inspection and replacement.
As illustration, suppose that AZi - 1 has the binary representation BkBk-I. ... , Bl for
some positive integer k, where
so that
k
AZi - l = '~
" 2j - 1 B j ,.
j=1
Then
if k ::: ,8,
2 j - 1 B j if k > ,8,
min(k,p)
Zi = AZi - 1 (mod 2P) = L 2j - 1B j
j=1
MOD U L U 5 2f3 423
can be replaced by the less costly steps of determining k by bit inspection and then replacing
bits minCk, fJ) + 1, ... ,k by zeros.
The desire to eliminate the multiplication AZ;_1 as well has led to a recommendation
for the form of A. However, Section 9.53 shows that this form introduces a disastrous
departure from randomness, especially in three dimensions.
Although integer arithmetic is faster, it imposes restrictions on word size that impose
other design constraints on pseudorandom number generation (png). Moreover, the speeds
of current-day computers are so much greater than in the past as to make the penalty
incurred in using floating-point arithmetic considerably less of a contentious issue. As a
consequence, many png programs rely on extended-precision floating-point arithmetic to
perform all computations.
Without its computational edge, one might have expected M = 2f3, as a multiplier,
to give way to M prime. Since this has not happened in total, we need to familiarize the
simulationists with the properties of powers-of-two moduli.
What does M = 2f3 imply about the sequences that the generator (9.1) produces?
If the seed Zi-1 is an even integer, then, for any positive integer A, AZi - 1 is even and
so is Z; = AZ;_1(mod2f3 ) = AZ;_1 - K;2 f3 , where K; = LAZi -d2 f3 J. Suppose that
Z;-1 = Y;-1 x 2Y for some odd integer Yi - 1 and integer y < fJ. Then
where
A == 3 (mod 8)
and
Table 9.2 illustrates the sequences that these generators can produce. Here A = 13 == 5
(mod 8), whereas A = 11 == 3 (mod 8). Most notably, each A leads to two disjoint odd
sequences, depending on the starting Zoo Also, Z(;) - Z(;-I) = 4 for A = 13, whereas
Z(i) - Z(;_I) E {2, 6} for A = 11, implying that the latter sequences have less uniformity
than the former. More generally, maximal-period multiplicative congruential generators
with M = 2fi and f3 ::: 3 have the following properties (Jannson 1966):
Property Ml. For A == 5 (mod 8) and Zo == 1 (mod 4), {Z;, 1 < < P} is a
permutation of the integers 4j + 1; j = 0, 1, ... , 2fi - 2 - 1.
Property M2. For A == 5 (mod 8) and Zo == 3 (mod 4), {Z;, 1 < < P} is a
permutation of the integers 4j + 3; j = 0,1, ... , 2fi - 2 - 1.
Property M3. For A == 3 (mod 8) and Zo == 1 or 3 (mod 4), {Z;, 1 ::::: i ::::: P} is a
permutation of the integers 8j + 1 and 8j + 3; j = 0,1, ... , 2fi - 3 - 1.
which has the additional parameter C. For M = 2fi, C an odd integer, A == 1 ( mod 4), and
gcd(M, C) = 1, this generator has full period M consisting of all integers
{O}U Mo = {O, 1, ... , M - I}. Note that:
so that
Yi = AYi - 1 + A'
where Yi E {O, 1, ... ,2fi - 2 }, thus proving our assertion. Since A == 5 (mod 8), A =
1 + 4(1 + 2K) for some integer K. Therefore, A == 1 (mod 4) and A' = Ll/4 + 1 + 2KJ
is odd, so that {Yi } has "full period" 2fi - 2 • Analogous results obtain for A == 5 (mod 8) and
Zo == 3 (mod 4) and for A == 3 (mod 8) and Zo == 1 (mod 2).
426 C HAP TE R 9. P5 E U DO RAN DO M N U M B ERG ENE RAT ION
(9.13)
K +-- LSjMJ,
Zi+--S-KM.
for a prime modulus generator (with period P = M - 1 < 2(1 - 1), and requires A x
(2 fJ -1) ::'S 2(1 - 1 (Property M2) for a multiplicative congruential generator with modulus
M = 2fJ and A == 5 (mod 8).
To illustrate the limitation that these bounds impose, consider the primitive root A
= 950706376 for M = 231 - 1, which leads to 260 < A(M - 1) < 261. Therefore, directly
performing integer arithmetic to compute AZi _ 1 would inevitably lead to an overflow error
for some i on 32-bit computers. Since floating-point representations on these computers
have 24-bit mantissas in single precision and at most 56-bit mantissas in double precision,
directly performing floating-point arithmetic on AZi - 1 also leads to an error for some i.
At least two solutions to this problem exist. The first uses extended-precision arith-
metic software and by specifying an adequate level of precision, eliminates the overflow
problem. However, this type of software is inevitably machine-dependent, thereby limiting
the portability of any pseudorandom number generation program that relies on it. A portable
9 .4 . How RAN DO MAR E P5 E U DO RAN DO M N U M B E R 5 ? 427
computer program produces identical output on different computing platforms when given
identical input. In the context of discrete-event simulation experiments, portability is a
highly desirable feature.
The second alternative partitions arithmetic operations in a way that eliminates the
overflow problem on a wide range of computing platforms and therefore ensures portability.
For example, let Al := A (mod 216 ), A z := A - AI, Xi = AIZi _ 1 (mod 231 ), and Yi
AZZi - 1 (mod 231 ). Then expression (9.1) has the equivalent form
AIZi _ 1 .::: 247 - 1, and AZZi - 1 .::: 26Z - l. However, the least significant 16 bits of AZZi - 1
are identically zero. Therefore, this partition of AZi - 1 allows one to compute Zi with no
overflow, provided that a 47-bit mantissa is available.
Hormann and Derflinger (1993) give algorithms for effecting this portability for M =
231 - 1 and A < 230 . Implementations of these algorithms are demonstratably faster than
that in Fishman (1996, Section 7.5).
For M = 231 - 1, a third alternative for ensuring portability across platforms restricts
the choice of the multiplier A to a subset of the primitive roots of M that satisfy specified
conditions (Schrage 1979, Park and Miller 1988, and Fishman 1996). Since a major objective
is to choose an A that makes VI, V z , ... resemble an i.i.d. uniform sequence as closely as
possible, these additional restrictions can in no way improve the resemblance and are likely
to reduce it. Therefore, we do not encourage this approach to portability.
How well does VI, V z, ... resemble a sequence of i.i.d. random variables from U(O, l)? We
have already indicated that prime M and A a primitive root of M establish one-dimensional
uniformity over the integers {l, ... , M -1}, whereasM:= 2f3 (f3 > 3) and A = 5 (mod 8)
do likewise over the integers {3 + 8j; j = 0, 1, ... , 2f3 - 3 } for Zo = 3 and {5 + 8j; j =
0, 1, ... , 2f3 - 3 } for Zo = 5. But what about the independence property? Do large values of
Vi+ 1 follow large (small) values of Vi, indicating dependence; or is Vi+1 independent of the
value of Vi?
Example 8.1 illustrates why independence within 2-tuples is necessary. If Vi and Vi+ 1
are independent and each from U(O, 1) and Vi .::: e-(Ui + 1-i)2/ z , then -In V i+1 has the half
normal p.d.f. (8.12a). If Vi and Vi+ 1 are not independent then -In Vi+ 1 does not have the
desired p.d.f.
Because of the deterministic way in which the generator (9.1) produces Zi' some
dependence between Zi and Zi+1 is inevitable. Presumably, we want to choose A for a given
M in a way that keeps this dependence to an acceptable minimum. But what about the joint
dependence of Zi, Zi+l, Zi+2 or, more generally, of Zi, ... , Zi+k-I? Regrettably, analysis
428 C HAP TE R 9. P5 E U D 0 RAN DO M N U M B ERG ENE RAT ION
(a) A = 2
(b) A=8
6 7 9 10 11
2 3 4 5 6 7 8 9 10 11
Zi
shows that no A performs equally well in all dimensions 1 through k for arbitrary k with
respect to given error norms. However, for a given M we can identify those A whose worst
errors across the k dimensions are smallest.
If Vi and V i + 1 are independent from U(O, 1), then the sequence {(Vi, Vi+d; i =
1,2, ... } would have its elements (Vi, Vi+d uniformly distributed in the unit square [0, IF.
Since the generator (9.1) induces discrete (Vi, Vi+d, the closest that we can come to this
idealization is to have 2-tuples uniformly distributed on the grid {x j := it;
j = 1, ... , M -1
and Yj = it; j = 1, ... , M - I}.
Figure 9.1 gives us a preview of what we can expect. It shows overlapping 2-tuples for
the generator in Table 9.1 with A = 2 and 8. Observe that ten 2-tuples appear in each figure,
whereas one expects one hundred 2-tuples, one at each vertex of the 2-dimensionallO x 10
grid. Also, the points for A =2 appear less random than those for A = 8. A second illustration
makes the issue of nonuniformity more salient.
Recall that the most commonly employed multipliers for M = 231 -1 in discrete-event
simulation are 16807 (e.g., SIMAN), 630360016 (e.g., SIMSCRIPT n.5), and 742938285 (e.g.,
GPSS/H). To reveal the discrete patterns they induce, Figure 9.2· shows their overlapping 2-
tuples that fall in the square [0, .001F. Since any square of width and length .001 in the unit
square exhibits approximately the same appearance, [0, .001 F contains about (.001)2 X M ~
2147 2-tuples. Figure 9.2 reveals that for A = 16807 these 2-tuples are packed together tightly
on 17 parallel hyperplanes. By contrast, Figure 9.2b shows thatthe 2-tuples for A = 630360016
are considerably more uniformly distributed on 29 parallel lines, whereas Figure 9.2c shows
50 parallel lines for A = 742938285.
These numbers arise from counting the number of parallel lines within the set of
parallel lines that have maximal distance between successive lines. For (0, I?, these numbers
9.4. How RANDOM ARE PSEUDORANDOM NUMBERS? 429
0.0009
0.0008
0.0001
0.0006
U,., O.ooos
0.0004
0.0003
0.0002
0.0001
O ~~~-L~~-L~-L~~~
o 0,0002 0.0004 0.0006 0.0008 0.001 o 0,0002 0.0004 0.0006 0.0008 0.001
U. U,
(e) II = 742938285
u,.,
suggest that 2-tuples for A = 16807 are distributed on about 17,000 parallel lines in the unit
square, 2-tuples for A = 630360016 are distributed on about 29,000 parallellines, and 2-tuples
for A = 74938285 are distributed on about 50,000 parallel lines.
Since the number of these lines increases with the distance between successive parallel
lines and since for a given multiplier the distribution of 2-tuples becomes less uniform as
the distance between parallel lines increases because of the increasing area void of 2-tuples,
it follows that A = 16807 offers less-uniform 2-tuples than A = 630360016, which offers
less-uniform 2-tuples than A = 742938285.
These observations for 2-tuples extend more generally to k-tuples. In particular, all
prime modulus generators oftheform induce M -1 k-tuples {Zj = (Zj, ... , Zi +k-I); 1 ::::
i :::: M - I} on the vertices of the k-dimensional grid 9 = {z = (ZI, .. . , zd : Zj = j, 1 ::::
430 CHAPTER 9. PSEUDORANDOM NUMBER GENERATION
j ::::: M - 1, 1 ::::: i ::::: k}, thereby leaving (M - 2)[(M - 1)k - 1] vertices unoccupied.
Hence, the density of points diminishes with increasing dimension k. Since all vertices are
not occupied, the second observation regarding uniformity becomes increasingly important
as k increases. That is, some arrangments of the M - 1 k-tuples appear closer to uniformity
than others. Since uniformity is a principal consideration, one prefers the primitive root A,
for a specified prime modulus M, whose k-tuples come closest to uniformity as measured
by an objective criterion for each dimension k = 1,2, .... Theorem 9.1 provides a basis for
making this choice.
Theorem 9.1.
For each k ::: 1, letq := (qo, ql> ... ,qk-d denote points in the set
and let
k-l
Zi(q, k) := L qsZi+s, (9.14)
s=o
where
(9.15)
i. For each q E Qk(A, M) the k-tuples {Uik := (Ui> Ui+l> ... , Ui+k-d;
i = 1, ... , M - I}, where Ui := ZdM, lie on parallel hyperplanes in (0, 1)k.
ii. The total number of these parallel hyperplanes does not exceed L!:~ I qs I -1.
-[/2
Z;(q, k) (mod M) = 0,
or, equivalently,
This implies that for i = 1, ... , M - 1 there exist integers c;(q, k) E {-M, -M +
1, ... , -1,0,1, ... , M - I} such that
k-I
LqsU;+s =c;(q,k). (9.16)
s=o
k-I
Z;(q,k) < M Lmax(O,qs),
s=o
so that
k-I
c;(q,k)::s: Lmax(O,qs).
s=o
Conversely,
k-I
Z;(q, k) > M L mineO, qs),
s=o
so that
k-I
c;(q, k)::: L mineO, qs) + 1.
s=o
432 CHAPTER 9. PSEUDORANDOM NUMBER GENERATION
Let Cmin and Cmax denote the largest and smallest integers in Ck(q). Since I Ck(q) I denotes
the number of parallel hyperplanes,
Let x := (xo, ... , Xk-l) and y := (Yo, ... , Yk-d denote points on the
°
PROOF OF PART III..
parallel hyperplanes {qouo + ... + qk-lUk-l = C : < Uj < I; j = 0"", k - I} and
{qouo + ... + qk-lUk-l = c' : ° < Uj < I; j = 0, ... , k - I}, respectively, for C and
c' E Ck (q). To find the distance between these hyperplanes, we fix x and find the solution to
subject to
and
k-l
LqsYs = c'.
s=O
so that
2(c - c')
A - "k-l 2'
L."s=O qs
9 .5 . C H 00 SIN GAM 0 N G M U L TIP LIE RS 433
Corollary 9.2.
For{Zi = AZi- 1 (mod2 P);{3 > 3,i::: I} with A == 5 (mod B), Theorem 9.2 continues
toholdwithL!:~ qsA S == 0 (mod2 P- 2 ).
This implies that all k-tuples for generators with M = 2P and A == 5 (mod 8) lie
on parallel hyperplanes, and thus any methods for discerning departures from uniformity
apply to these as well as to prime modulus generators.
To predict the seriousness of error and thereby to identify perferred multipliers, we need
to understand more about the k-tuples in expression (9.15). Reducing both sides of the
expression modulo 1 leads to
k-1
LqsUi +S == 0 (mod I) (9.17)
s=o
(9.18)
where
In particular,
dk(A, M) = qEQk(A,M)
max dk(q, A, M) (9.20)
denotes the maximal distance between two adjacent hyperplanes over all families of parallel
hyperplanes that the multiplier A and modulus M induce. Since one can show that for every
434 C HAP TE R 9. PS E U D 0 RAN D 0 M N U M B ERG ENE RAT ION
q E QdA, M) with ~k(q) > 1 there exists a q E Qk(A, M) with ~k(q) = 1 such that
k =2,
r l/6 k = 3,
rl/4 k=4,
[t(M)]llkdk(A, M) :::: Yk:= r 3/10 k = 5, (9.21)
where
t(M) .-
.- 12fJM - 2
if M is prime,
if M = 2fJ.
For M = 11, d2 (A, 11) :::: .2806, revealing that d2 (8, 11) is within 13 percent of the best
achievable bound for 2-tuples. For M = 231 - 1,
.2008 X 10-4 k = 2,
.6905 X 10-3 k = 3,
ddA,2 31 - 1):::: .3906 x 10- 2 k = 4, (9.22)
.1105 X 10- 1 k = 5,
.2157 X 10- 1 k = 6,
9.5. CHOOSING AMONG MULTIPLIERS 435
.1109 X 10-6 k = 2,
.2158 X 10-4 k = 3,
dk(A, 248 ) 2: .2903 X 10-3 k = 4, (9.23)
.1381 X 10-2 k = 5,
.3814 X 10-2 k = 6,
indicating the relative coarseness of the grids in as few as four dimensions. This coarseness
enhances the importance of choosing an A that makes dk(A, M) as small as possible across
dimensions.
Table 9.3 gives results for high-performing multipliers, with respect to dk(A, M) for
M = 231 - 1, 232 , and 248. For modulus M, the quantity Sk(A, M) denotes the ratio of
the minimal achievable distance Yk/t1/k(M) to the worst-case distance dk(A, M) for the
multiplier A. For M = 231 - 1, the first five entries are the best among the 534,600,000
primitive roots of M. For M = 232 , the entries are best among the 2{3-3 = 229 =536,870,912
possible candidates, and for M = 248 the five entries are the best among 60 million multipliers
tested. For M = 232 , the second entry under each multiplier is its multiplicative inverse
modulo M. For M = 231 - 1, the table also shows results for the two multipliers A =
630360016 in SIMSCRIPT 11.5 and A = 16807 in SIMAN and SLAM. As anticipated from
Figure 9.2, d2 (742938285, 231 - 1) < d2 (630360016, 231 - 1) < d2 (16807, 231 - 1). More
generally, each of the best five dominates 630360016 and 16807 for 2 :::: k :::: 6. Recall
that GPSS/H uses 742938285. Clearly, there is room for improvement in the pseudorandom
number generators in SIMAN and SLAM.
Other mathematical norms exist for choosing among multipliers, and they generally
lead to the same, or close to the same, ordering among multipliers in each dimension k. See
Fishman (1996, Chapter 7). These alternatives include a bound on the number ofhyperplanes
(Theorem 9.2 ii),
k-l
Nk(A, M):= L I qs 1-1,
s=o
Table 9.3 Distance between parallel hyperplanes for {Zj = AZ j - 1 (mod M), i 2: I}
To illustrate the problem, Figure 9.3a contains seven parallel lines with incremental
distance d when the lines are oriented parallel to the 45-degree line; but Figure 9.3b shows
only five lines with incremental distance d when the lines are oriented parallel to the y-axis.
While this example places more value on dkCA, M) than on NkCA, M) as an indicator of
uniformity, NkCA, M) nevertheless can provide useful information, as Section 9.5.3 shows.
Since Figure 9.2 reveals that A = 16807 induces larger null regions in [0, 1)2 than
A = 360360016 and A = 742938285, its use in practice is more suspect than the others.
However, some say that even with these large null regions A = 16807 continues to be an
acceptable generator "to the level of approximation" one aims for when using simulation
9 .5 . C H 00 SIN GAM 0 N G M U LTIP LIE RS 437
(b)
(a)
o
o
output statistics to approximate unknown system quantities. Regrettably, both the criticism
and defense of A = 16807 are far too abstract for a reader to assess the strength of each
argument. To move the debate closer to reality, we return to sampling from the half-normal
p.d.f. (8.12a) and corresponding d.f. {2cJ>(x) - 1, 0 ::: x < oo}. In particular, we compare
the discretization errors that each ofthe three multipliers induces for half-normal generation
via the acceptance-rejection method (Section 8.5). To benchmark these errors, we first study
discretization error for the inverse transform method (Section 8.1.3).
Applying the inverse transform method leads to the sequence
x(j) := cJ>
_l(l+ 2j /M) ' j = 1, ... , M -1,
defines, for all prime-modulus generators, the ordered sequence of approximating half-
normal values that expression (9.23) produces. Moreover, the discretization errors between
438 C HAP TE R 9. P5 E U DO RAN DO M N U M B ERG ENE RAT ION
x( ·+1) -
J
x(·)
J
<
-
14.312 x 10- 9 if 1 <
5.254 X 10- 8 if 2 <
x(j) :::
x(j) :::
2,
3,
1.740 x 10-6 if 3 < x(j) ::: 4.
Since 2<1>(4) - 1 = 1 - .6334 X 10-4 ::::: .99993, we conclude that discretization error is at
most 1.740 x 10-6 for all numbers except those greater than 4, which are rarely encountered.
These favorable results apply for any full-period generator. However, no closed form
exists for the inverse <1>-1, so that this method of half-normal generation must rely on time-
consuming methods ofnumerical approximation. Nevertheless, the bounds on discretization
error provide a basis for judging the discretization errors induced by the acceptance-rejection
method based on Algorithm AR for A = 16807,630360016, and 742938285. In the present
notation:
ALGORITHM H-N
Given: Zo (seed).
Method: i +-- -1.
Repeat
i +--i+2
Zi +-- (AZi-d ( mod M)
Zi+! +-- (AZ i ) ( mod M)
Ui +-- Zi/ M
Ui+! +-- Zi+d M
Y +-- -In(l- Ui)
Until Ui+1 ::: e-(Yi-1)2/2.
Return Y.
Clearly, discretization error depends on the properties of the 2- tuples {( Ui , Ui +1) } that
lie in
C:= { (Uh U2): -U2 + AU1 == 0 (mod 1), U1 E {~, ... , M;; 1 } } .
Observe that the points fall on A parallel lines with slope A, whereas the accepted points are
ill
U2 ::: e-[ln(l-Ul)-1]2/2} •
9 .5 . C H 00 SIN GAM 0 NG M U L TIP LIE RS 439
Let j 1, ... , A index the parallel lines (from left to right). Then UI = k(j)IM,
where
where Y(l) is strictly increasing in I. Then Algorithm H -M produces no values on the positive
axis in the intervals
A-I
U
j=1
(Y(l(j)-I), Y(k(j+I)))'
Let ~Y denote the length of an excluded interval, which we hereafter call a gap. Table 9.4
displays bounds on gaps for the three multipliers of interest. For A = 16807, the gaps are
considerably larger than for the other multipliers. They are also substantially larger than
those that the inverse transform distribution induces. Although Algorithm H-N is not the
commonly encountered method for generating half-normal samples, the gaps for A = 16807
represent what can happen when a multiplier that performs relatively poorly on the spectral
test is used. At a minimum, Table 9.4 should encourage potential users of this multiplier to
switch to any of the first five multipliers in Table 9.3 that perform best on the spectral test in
dimensions 2 through 6.
Recall that A == ± 3 (mod 8) and M = 2f3 (f3 :=:: 3) yield a generator with maximal
period 2f3 - 2 • Consider a multiplier A E {2" - 3; v :=:: f3 12} U {2" + 3; v :=:: f3 12} that ensures
440 CHAPTER 9. PSEUDORANDOM NUMBER GENERATION
A y f),.y
In the early days of simulation, multipliers of this form offered the appeal of allowing
shift and add operations to replace the more costly direct multiplication AZi • For example,
A = 2v + 3 allows:
• AddZi to B.
• Zi+l = B.
9.6. MULTIPLE REPLICATIONS 441
Ui + 2 =f 6 Ui + 1 ± 9 Ui == 0 (mod 1),
revealing that the triplets {(Ui , Ui + l , Ui + 2 ); i ~ I} all lie on no more than N3(A, M) = 15
parallel hyperplanes.
Regrettably, a multiplier A = 216 + 3 in this class was used for many years in the pseu-
dorandom number generator RANDU in IBM's Scientific Subroutine package. Interestingly,
the bad performance in three dimensions was discovered empirically.
This last example demonstrates that although dk(A, M) is a better measure of k-
dimensional nonuniformity than Nk(A, M), a bound on the number of hyperplanes may
be more easily computed and thus be of more immediate use.
where I > max j kj denotes the offset in the pseudorandom number sequence between
successive streams.
It is easily seen that these points lie on (k l + ... + kr )-dimensional hyperplanes
r kj-I
LL q(j-I)I+sZi+(j-I)I+s == 0 (mod M), (9.27)
j=1 s=O
t(M) is defined in Section 9.5, and the maximal distance between successive parallel
hyperplanes is
r kj-l ) -1/2
d'
k1+,+k,
(A, M) := max
qeQ '(r-l)I+k,,(A,M)
(
~ L
J=l s=O
2,
q(J-l)l+s
(9.28)
This motivates our interest in identifying the multiplier A that minimizes this maximal
distance.
Since inequality (9.21) has already revealed the grid coarseness for the generator (9.1)
for dimensions as small as 4, identifying the best A in kl + ... + kr > 6 dimensions would
serve little purpose. This motivates us to defer discussion of multiple streams until Section
9.7.1 and to turn to an alternative form of pseudorandom number generation that offers
an expeditious way of reducing this coarseness up to significantly higher dimensions. While
not currently implemented in any simulation language, its availability in C code makes it a
prime candidate for future implementation.
j = 1, ... , J, (9.29)
where M l , •.. , MJ are distinct primes and Aj is a primitive root of M j . For example, for
J =4,
(9.31)
and the normalized sequence {Ui := Zil M 1 , i :::: I}. What can we say about its properties?
9.7. COMBINED GENERATORS 443
0.001
, ....
.... .. ;...;- ..........-:. .
~-~;.-'~~;"\ 'il"'~':-~'
.:
"" . "--:,------.--.---------------
..). ~ ~
.- ••
.... . . ~. -: :.:",..
. ). '"'. .~ -;.-",.:........
......._.::...: ......
r·: .... ' :~
• •••••• .. .".... ~ ...: ... ,.. • •••• I :: •
0.0008 : • •1' .; ',' I. :: ~ •• ' .' '.,~ ':.: , " . : • • • •, ' • - ••"._
•
...
: :• • ~::.:.:~ •• I ••• , .... :".!~ '... : ~" ••: ,',
1'\" • •••••• ','.. • ......1 \
::. II: ::...... :. ':.: '~" .. :.:..;".::.!'~:;.:. 'II",:: ••:,' .,~
:: :;.::' .... : ,.1 I':, ':' .,~ ::." : :'.
.1-: ... \.
':'.1 ...•. ' .. ~. I.,"
.. :: .-:.... :., ' .:'. I. '.' , '.
0.0006 ~
,
.
. ..' ",'.' ....~.. .. .:' I.:. '::-,,\"! \. '. ':~. I ' ' ..
.' •••.
..: .... I.,. ".:' .,...... ........ . ... :: ..,
U i+l ~,~~
........
:. ,: :...
•. ...... :.:. ....
...
' .., ......
._'" .. -:.:.-.!
~: :,.........., ....'
... ..............:. ~.,
. .......
. ...., :..,:,......... .........
....' ...
.
.\ .:.~
:~ <4
:'
•• .. •• ., • •It • "'.. ..,.. • • • • • I. • ':
0.0002 !. .1.:.. .." ..
Jt :0......t,• ~
••". ....;:" •• ' •• ::. _.. \ •• •••
. :.......:. ' .....:... .......'.....
r:'... •.:......' : •• ••• ! •.. .
.., .... ... ...--... ::.._........
... .....'.::. ....
:. : .. .. : ..:..... . .'. -. ~
:~
~
•... : : .. 'y,:.:: ... .., ..
:
ie, !I . . .J'. ~'·.:.r .~.
Ui
Zji/Mi ,
(t1=1
OjUji) (mod 1), > 1, (9.32)
and
- J
M:= Ilj=IMj.
Then
where Yi = !VI Vi and A is computable (L'Ecuyer and Tezuka 1991) and does not
depend on {OJ}.
444 CHAPTER 9. PSEUDORANDOM NUMBER GENERATION
• Ui = ~ + Ei, where tight lower and upper bounds can be computed on Ei.
These are important properties. They imply that the period is at least min l:::;j:9 (Mj -
1) and that judiciously chosen M I, ... , M, can induce a period as large as (M I - 1) x ... X
(M, - 1)/2'-1. In particular, the maximum is achieved if (M I - 1)/2, ... , (M, - 1)/2
have no factors in common, as is the case for M I , ..• , M4 in expression (9.29), for which
P ~ 2.13 X 1037 , in contrast to a period of 231 - 2 ~ 2.14 X 109 for the generator (9.1)
with M = 2 31 - 1. Indeed, the density of points in [0, 1) increases by a factor of 1027 .
The first property tells us that the normalized {~, i :::: I} satisfy a one-step recursion
~ = A ~_I (mod 1). The third reveals that Ui, based on the generator (9.30), differs from
~ by a negligible amount. In particular, the assignment (9.29) leads to
£1 = 21267641435849934371830464348413044909 ~ 2 x 1037 ,
A=5494569482908719143153333426731027229,
and induces the bounds -1.04308128 x 10-7 ~ Ei ~ 1.99303031 X 10-7 (L'Ecuyer 1999).
Therefore, it is not unreasonable to characterize the properties of IUd by those of {~},
which, fortunately, we can determine via the spectral test.
Table 9.5 lists the distances {dk(A, £1), k = 2, ... , 1O} between successive hyperplanes
for the generator based on the assignment (9.29). For comparison, it also lists the distances
for A = 16807,630360016, and 742938285 and M = 231 -1. The unequivocal superiority of
the generator (9.30) is clear. It induces a considerably denser grid than the other generators
do.
Recall that Figures 9.2a, 9.2b, and 9.2c each show regular patterns of about 2147
2-tuples in [0, .001) x [0, .001) over the period M - 1 = 231 - 2 of the three prime-
modulus multiplicative congruential generators of the basic form (9.1). For the combined
generator defined in expressions (9.28), (9.29), and (9.30), run with arbitrarily selected
seeds for each of its component generators, Figure 9.5 displays the subset of2147 2-tuples of
{(Ui, Ui+I); i = 1, ... , 231 -2}thatfallinto [0, .001) x [0, .001). The choice of run length
was made to allow comparison between Figures 9.2 and 9.5 with density held relatively
fixed. Most notably, the absence of any regularity in Figure 9.5 allows us to conclude that for
sequences of length 231 - 2 the combined generator succeeds in eliminating the apparent
lattice structure inherent in generators of the form (9.1) and depicted in Figures 9.2a, 9.2b,
and 9.2c.
9.7. COMBI N ED G EN ERATORS 445
Recall from Section 9.6 that it is the properties of the (k1 + ... + kr )-tuples that
ultimately interest us. Moreover, we cannot expect these to be particularly good for M =
231 -1 and 232 • To simplify the exposition in the current context, we take k1 = ... = kr = k
and focus on the kr-tuples
Zi := (2i, 2i+1> ... , 2i +k-1> •.• , 2i+l, 2i+ I+1> •.• , 2i + I+k-1>""
2i +(r-1)1, 2i +(r-1)1+1> .•• , 2i +(r-1)1+k-d,
which, because of the third property of generator (9.31), we assume are close to those for
the kr-tuples
For assignment (9.29), it is of interest to determine d~lr (,4, M), the maximal distance
between parallel hyperplanes, for r pseudorandom number streams with displacement I
between successive streams for k dimensions. An empirical analysis in L'Ecuyer and Andres
(I997a) reveals that
2.02 X 10- 19 r = 2,
3.22 X 10- 13 r = 3,
3.92 X 10- 10 r = 4,
d~lr(A, M)::::: 2.78 x 10-8 r = 5,
4.66 X 10-7 r = 6,
3.46 X 10-6 r = 7,
1.53 X 10-5 r = 8,
446 CHAPTER 9. PSEUDORANDOM NUMBER GENERATION
for k = 1, ... , 20, and I = 241. This choice of displacement I induces the least upper bound
on dle1rCA, M) for all 2 :::: r :::: 8 and 1 :::: k :::: 20. Since these are considerably smaller than
one could expect to achieve for generators of the form (9.1) for k-tuples taken on r streams
for these ranges of k and r and any displacement I, we recommend the L'Ecuyer and Andres
combined generator (9.31) with the assignment (9.30) for replacing currently implemented
pseudorandom number generators. Although the L'Ecuyer-Andres implementation takes
r = 231 streams each oflength I = 241 by default, it allows the user to change these values.
These improved properties come at the expense of increased computing time per pseu-
dorandom number generation. The increase is between three and four times the computing
time for an efficient implementation of the generator (9.1). The upper bound offour arises
because the function call to the generator occurs once regardless of whether generator (9.1)
or (9.29) is used.
As already mentioned in Section 9.2, careful attention to multiplication modulo M
can save time. The C programs clcg4.c and clcg4.h and the Modula-2 code clcg4.mod
and clcg4.def, available at http://www.iro.umontreal.ca/...lecuyer/papers.html. take full
advantage of the option to conserve time. A test program, prg 2.c, is also available there.
For the practitioner, the issue now becomes one of quality of results versus computing
time. If a simulation using generator (9.1) devotes 100 x a percent of its time to generating
pseudorandom numbers, then a switch to generator (9.30) induces a relative increase in
computing time of at most 4a + (1- a) = 3a + 1. For example, a = .05, .10, and .20 induce
3a + 1 = 1.15, 1.30, and 1.60, respectively.
In Monte Carlo experiments that focus narrowly on numerical integration, pseudo-
random number generation can be the principal time consumer. If, for example, a = .80,
then the switch from generator (9.1) to generator (9.30) implies as much as a 3a + 1 = 3.4
time increase in computing time. No doubt, this substantial increment in cost is what has
retarded the implementation of better pseudorandom number generators in this type of
experiment.
By contrast, pseudorandom number generation in discrete-event simulation rarely
consumes more than a marginal amount of computing time, most of which is devoted to
memory management and, in particular, list processing. It is not unusual to have a < .20. In
this case, the penalty of increased computing time seems worth the benefit ofhigher-quality
pseudorandom numbers.
normalized by mapping them (Ui = Zi 1M) into points in (0, 1), which are then used
as input for generating samples from diverse distributions.
• If M = 2fJ for f3 ::: 3, then choosing A = ± 3 (mod 8) ensures a maximal period MI4
on a subset of the MI2 odd integers in {l, 3, ... , MI2 - I}. The period denotes the
number of iterations of the generator before it repeats itself.
• k-tuples (Ui , U i + l , ... , Ui+k-d for i ::: 1 lie on parallel hyperplanes in (0, 1)k. The
choice of M and A dictates the number of parallel hyperplanes and the maximal
distance between successive parallel hyperplanes. A small number of widely spaced
hyperplanes signals a poor approximation to randomness for the k-tuples. Among
all multipliers A that maximize the period for a given M, one prefers the one that
minimizes the maximal distance between successive hyperplanes in k dimensions.
This optimal A usually varies with k.
• Table.9.3 gives good choices of multipliers for M = 231 - 1,232 , and 248.
• Since Ui , Ui +l , ... are the input to a procedure for generating samples X j, XHI, ...
from a particular distribution F, departures from uniformity in the Ui induce a
distribution F for the X j that only approximates F. Most importantly, a given sequence
Ui , Ui + l , ... used as input to different procedures for generating samples from F
induces different F's and therefore different approximations to the desired distribution
F. The acceptance-rejection and ratio-of-uniforms methods can induce substantial
errors in this way.
• Implementations of the combined generator are available via the Internet. See Section
9.7 for the address.
9.9 EXERCISES
<ff? 9.1 Show that A = 742938295 is a primitive root of2 31 - 1.
<ff? 9.3 Show that A=746061395 is the multiplicative inverse of630360016 (mod2 31 -1).
<ff? 9.4 Determine whether A = 48271 and M = 231 - 1 gives a full period M - 1.
<ff? 9.5 Determine whether A = 343 and M = 231 - 1 gives a full period M - 1.
a. Determine the number of values (mod 2731) for A that give a full period 2730.
where M = 2fJ - y, y > 0, {J > log y I log 2, and M is prime. Construct a portable
pseudorandom number generator that will produce the identical sequence of numbers on
all computers whose floating-point representations have at least a f3{J 12l-bit mantissa.
9.9. Ex ERe I S E S 449
with M = 4999 prime, Al = 2187, and Zo E {l, 2, ... , 4998}. A second simulator suggests
an alternative multiplier A2 = 2182. Determine which, if either, of the multipliers generates
all the desired integers. Give complete details.
Gf!? 9.9 Consider the pseudorandom number generator
Gf!? 9.10 The programming language Prime Sheffield Pascal provides a library function
RANDOM that uses a multiplicative congruential generator Zj = AZj _ 1 (mod M) with
A = 16807 and M = 231 to produce random numbers. Determine whether this generator
has the maximal achievable period for this modulus. Display all steps in your proof.
Gf!? 9.11 Because of the small word size available on her computer, a simulator decides to
employ the random number generator
f(x) = e- x , x 2: O.
She decides to apply the inverse transform method to the normalized Zj to generate these
exponential samples. Let X be a resulting sample. Find the smallest and largest values that
X can assume before repeating itself (a) if Zo = 1 and (b) if Zo = 7. Give their numerical
values to six significant digits.
Gf!? 9.12 Consider the multiplicative congruential generator
b. State the conditions under which the numbers 2875, 4876321, and 578766 would
each appear in a sampling experiment that uses P pseudorandom numbers, where P
denotes the maximal period.
~ 9.13 For A = 65541 and M = 232 , show that the period of generator (9.1) is 230 •
~ 9.14 For A = 16777221 and M = 248 , show that the period of generator (9.1) is 246 •
9.1 0 REFERENCES
Fishman, G.S. (1990). Multplicative congruential random number generators with modulus
2fJ: an exhaustive analysis for fJ = 32 and a partial analysis for fJ = 48, Math. Comp.,
54, 331-334.
Fishman, G.S. (1996). Monte Carlo: Concepts, Algorithms, and Applications, Springer-Verlag,
New York.
Hormann, W., and G. Derflinger (1993). A portable random number generator well suited
for the rejection method, ACM Trans. Math. Software, 19, 489-495.
L'Ecuyer, P., and S. Tezuka (1991). Structural properties for two classes of combined random
number generators, Mathematics of Computation, 57, 735-746.
L'Ecuyer, P., and T.H. Andres (1997a). A random number generator based on the combina-
tion of four LCGs, version: November 25, 1997, University of Montreal, available at
http://www.iro.umontreal.ca/..-. lecuyer.
L'Ecuyer, P., and T.H. Andres (1997b). A random number generator based on the
combination offour LCGs, Mathematics and Computers in Simulation, 44, 99-107.
L'Ecuyer, P. (1999). Personal communication.
Overstreet, Jr., c.L. (1974). The relationship between the multiplicative and mixed generators
modulo 2b, Computer Science Department, Virginia Polytechnic Institute and State
University, Blacksburg.
Park, S.K., and K.W. Miller (1988). Random number generators: good ones are hard to find.
Comm. ACM, 31, 1192-120l.
9.10. REFERENCES 451
Payne, W.H., J.R. Rabung, and T.P. Bogyo (1969). Coding the Lehmer pseudorandom number
generator, Comm. ACM, 12, 85-86.
Schrage, L. (1979). A more portable FORTRAN random number generator, ACM Trans.
Math. Software, 5,132-138.
CHAPTER 1
• Expert opinion based on knowledge of how the particular input process behaves in
the real world
• Expert opinion about the behavior of input processes in closely related systems.
For example, if an arrival process can be viewed as the superposition of a very large number
of independent renewal processes each with relatively small arrival rate, then theoretical
454 C HAP TE R 1 0 . PRE PAR I N G THE I N PUT
deduction can show that inter arrival times in the arrival process of interest have a distribution
well approximated by the exponential (Section 1004.1).
If, in addition, expert opinion based on historical recollection indicates that the arrival
rate A lies in [A [, Azl for 0 < AI < Az < 00, then the simulationist has a candidate
distribution and an interval for the value of its parameter. Using the lower bound A[ in the
simulation would induce lower congestion than expected in the real system, whereas using
Az would induce the opposite behavior. This may encourage the simulationist to compare
the output of, say, two runs, one with A = A[ and the other with A = Az, to see whether
the uncertainty about A induces variation in the output that is within tolerable bounds. If
it does, then the actual value of A is not a major issue. If variation is not within tolerable
bounds, then attention must be devoted to finding a better way to estimate A.
Naturally, the availability of empirical data on the input process of interest or on one
closely resembling it is of great value. It creates an opportunity for input preparation that
enables the executing simulation program to generate stochastic sample paths that mimic
those observed in either the real or related system. How well these match depends on the
amount of historical data available and on the techniques employed in analyzing data.
Some input preparation depends exclusively on either expert opinion or on empirical
data analysis. However, a blend of both can endow a simulation with a considerably more
representative input than either alone. To effect this blend often calls for hypothesis testing
as well as estimation. Several factors militate against embracing this joint approach. First,
it requires a deeper knowledge of statistical theory. Second, it inevitably takes more of the
simulationist's time and effort. Third, many theoretical results in the study of delay systems
have their greatest value in facilitating analytical solution. Since a simulation model provides
a numerical solution, why burden the analysis with specification aimed at analytical solution?
While the first two factors need to be evaluated in light of the simulationist's skills and
time constraint, the third needs to be tempered by recognizing the limitations of relying on
a data analysis devoid of plausibility arguments. Using a sample record of finite length to fit
an input distribution inevitably invites errors both in selecting the distribution and estimat-
ing its parameters. By combining this analysis with plausibility arguments, a simulationist
prevents the sampling errors in the distribution fitting process from having undue influence
in the final form of the input.
Batch
size
o 10 12 14 16 18 20
time
times and batch sizes. Then one need only specify a single distribution for each source from
which to generate samples when executing a simulation run. In reality, the i.i.d. assumption
does not always apply, and input preparation needs to acknowledge that and accommodate
dependence. Section 10.11 does this. For now, we retain the assumption merely as a con-
venient backdrop to addressing issues relevant to the objectives of input preparation. The
issues raised here apply equally well when the i.i.d. assumption does not hold.
Discrete-event simulation methodology often characterizes the arrival process in one
of two ways. One views it as a sequence of2-tuples (T], Dd, (Tz , Dz), ... , whereT], Tz , .. . is
a sequence ofi.i.d.interarrival times and D], D 2 , ••• is a sequence of batch sizes. If D; = 1 Vi,
then we are back to the classical single-item arrival queueing model. If D], D z, ... are i.i.d.
random variables, then we have a random batch-size arrival process. Figure 1O.1a illustrates
the concept.
The second characterization consists of a sequence of i.i.d. 3-tuples (T], T{, D]), (T2 ,
T;, D2)' ... where T], T2, ... and T{, T;, ... are independent sequences ofi.i.d. nonnegative
random variables, and D; items in theith (i > 1) batch begin arriving at time T] + :L;;;;;;
(T/+
1[') and end arrival at time :L;=](If + 1[').
The transmission of records in a communication network often fits this second char-
acterization, where T;' denotes the time required to transmit the i th record and T; + T;'
denotes the time that elapses between the end of transmission ofthe (i ~ 1)st record and the
end of transmission of the i th record. Occasionally, it is convenient to think of this as a fluid
456 C HAP TE R 1 0 . PRE PAR I N G THE I N PUT
(b) Fluid-flowarrivais
5 ----------------------------------------,
Arriving
volume
o 10 12 14 16 18 20
time
flow into a storage tank rather than as a discrete count on items (Section 2.6). Figure 1O.lb
gives one possible conceptualization of this process.
When empirical data are available on input processes, a simulationist can use them in at
least two ways to prepare input. One constructs empirical distribution functions (e.d.f.s),
based exclusively on the data, and generates samples from them during the simulation. The
other fits the data to theoretical distributions and then generates samples from the fitted
distributions.
The e.dJ. approach induces stochastic variation in a simulated sequence that exactly
mimics that in the empirical data. Some of these fluctuations arise from the intrinsic proper-
ties of the underlying stochastic process. These are desirable. However, others arise from the
less-than-complete stochastic representation on which the e.dJ. is based. These are undesir-
able. Therefore, simulated sample sequences generated by an e.dJ. show desirable variation
due to the intrinsic character of the processes and undesirable variation due to finite sample
size.
As the length n of the empirical record increases, the unwanted fluctuations diminish
in relative importance when compared to the wanted fluctuations, so that the e.dJ. approach
generates samples that are increasingly (as n increases) representative of sample paths on
the underlying stochastic process. When very long empirical records are available, the e.dJ.
10.3. EM P I RIC A L D. F. A P PRO A C H 457
approach has much to commend it as a means of generating sample sequences. Section 10.3
describes its essential features.
For small and moderate n, the fitted d.f. approach has appeal. Fitting a theoretical
distribution to data smoothes out the variations in the empirical distribution due to finite
sample size. It also enlarges the domain of values for sampling. For example, given a sample
record of service times X(l) ::: X(l) < ... ::: X(n), the e.d.f. approach generates values on
[X(l), X(n)] at best. However, if expert opinion tells us that in reality service times take values
in the support [Xl, Xl], where Xl ::: X(l) < ... ::: X(n) < Xl, then fitting a distribution
with this support allows this expert opinion to be merged with the sample record to generate
samples on [Xl, Xl].
Smoothing and increasing the domain for sampling are the desirable features of the
fitted d.f. approach. As n grows, these benefits diminish in importance when compared to the
e.d.f. approach. First, the e.d.f. becomes smooth; second, its domain for sampling increases,
and third, because the fitted d.f. is inevitably an approximation, tests of its adequacy begin
to detect statistically significant discrepancies between fitted and empirical distributions.
Section 10.12 discusses distribution fitting in several different contexts.
Although our discussion reveals a tendency to favor the e.d.f. approach for large sample
sizes and the fitted d.f. approach for small and moderate sizes, following this inclination
would be too simplistic in practice. Circumstances, as in Section 10.13, exist where the
e.d.f. approach offers more convenience and more accuracy for relatively small sample sizes.
Moreover, the characterization of arrival processes in Section 1004.1 encourages the reader
to focus on the (theoretical) exponential distribution as a candidate for fitting, even in large
samples. Therefore, we encourage the reader to recognize that circumstances for her/his
particular study must be the determinant of which approach to follow. More often than not,
both play roles in a single simulation study.
Let X denote a random variable with d.f. {F (x), XE X} and p.d.f. or p.m.f. {f (x), X E X}.
If X denotes interarrival or service time, then F is usually continuous with support X E
[0,00), [a, 00) for some fixed a > 0, or [a, b) for fixed 0 ::: a < b < 00. For the moment,
assume that X is continuous on [0, 00).
Let Xl, ... , Xn denote n i.i.d. observations from F. Then the e.d.f.
1
L
n
Fn(x) := - I[xj,oo) (x), X::: 0, (10.1)
n i=l
(10.2)
458 C HAP TE R 1 0 . PRE PAR I N G THE I N PUT
(a)
0.14
6. =.2758
1=20
0.12
0.1
0.08
0'"
.~
e
0.
P- 0.06
0.04
0.02
0 I I I I
0.3 0.6 0.9 1.1 1.4 1.7 2.0 2.2 2.5 2.8 3.1 3.3 3.6 3.9 4.2 4.4 4.7 5.0 5.3 5.
~ .
Yl := - + mm Xi,
2
Yj := Yj-l + ~ j = 2, ... , I,
max X. - min X.
~:= I I
approximates f(Y)~ evaluated at Y E {Yl, ... , yd. Figure 1O.2a shows an empirical
histogram for n = 10 I i.i.d. service times based on an I = 20 cell partition of the data.
The graph of a histogram can provide insight into which theoretical distributions are
good candidates for fitting. For example, the Gamma and the Wishart distributions with
their skewed right tails are good prospects for Figure 10.2. However, the ability to discern
shape in a histogram depends crucially on 1. Customarily, I is chosen to balance the need
to discern the underlying shape of this frequency chart against the need to smooth out
fluctuations that obscure shape. Large I improves resolution but admits large fluctuations.
Small I smooths out fluctuations but reduces resolution. Inevitably, the choice of I is a
compromise. A comparision between Figures IO.2a and 1O.2b shows the tradeoff.
10.3. EM P I RIC A L D. F. A P PRO A C H 459
(b)
0.2
0.18
0.1 6
0.14
0.12
c
0
'f 0.1
0
0.
0
~
0.08
0.06
0.04
0.02
0
0.4 1.0 1.5 2.1 2.6 3.2 3.8 4.3 4.9 5.4
To assess how well {Fn(x)} approximates {F(x)}, we turn to its sampling properties.
For each x E X they are:
• SUPXEX I Fn(x) - F(x) I has the Kolmogorov-Smirnov (K-S) distribution for each
fixed positive integer n. Therefore, ([Fn (x) - dn(8), Fn (x) + dn(8)], '<Ix EX} covers
the true dJ. {F(x), x EX} w.p. 1 - 8, where dn(8) denotes the 1 - 8 quan-
tile of the Kolmogorov-Smirnov distribution. As n -+ 00, n 1j2 dn (.05) -+ 1.3581
460 CHAPTER 10. PREPARING THE INPUT
and n l / 2 dn (.01) -+ 1.6276. For n ::: 100, 1.3581/n l / 2 and 1.6276/n l / 2 approximate
dn (.05) and dn (.01), respectively, with negligible error.
d
• .jiiFn(x) -+ N(F(x), F(x)[I-F(x)])asn -+ 00. Therefore, for x EX, {nFn(x)+
4>2/2 =f 4>{4>2 /4 + nFn (x)[1 - Fn (x )]}1/2}/(n + 4>2), where 4> := <1>-1(1- 8/2), covers
F (x) with probability that converges to 1 - 8 as n -+ 00.
These properties also hold if X is continuous over an interval of finite length X := [XI, X2).
If X is discrete, the properties hold except that the confidence region based on the K-S
distribution corresponds to a confidence level greater than or equal to 1 - 8.
The standard error, relative error, K-S distribution, and normal limit all provide ways
of assessing how well the e.dJ. approximates the true, but unknown, dJ. Replacing F(x)
by Fn(x) in s.e. (Fn(x)) and r.e. (Fn(x)) provides estimates of these errors. The K-S and
limiting normal properties provide more incisive measures.
The K-S distribution leads to a confidence region for the entire dJ. {F(x)} at the
100 x (1 - 8) percent confidence level for each positive integer n. By contrast, the limiting
normal result provides a 100 x (1 - 8) percent confidence interval for a selected x as
n becomes large. Both results have benefits and limitations. For example, the K-S result
gives a half-length of 1.6276/n l / 2 for 8 = .01 andn ~ 100 for all x, leading to {F(x) E
[max[O, Fn(x) - .1628), min[l, Fn(x) + .1628)), Vx E X} for the e.d.f. with n = 100 on
which the empirical histogram in Figure 10.2 is based.
Figure 10.3 shows {Fn(x)} and its 99 percent K-S confidence region where {Fn(x)},
as defined in expression (10.3 ), differs from {Fn(x)} in a relatively minor way. The width
of the region is far too large to regard the e.d.f. as a relatively accurate approximation of
{F (x)}. However, the limiting normal result reveals a better pointwise accuracy. Table 10.1
shows individual and simultaneous confidence intervals (Section 7.1) for five values of x .
These reveal shorter inteval lengths than the K-S approach, suggesting in general,
that for moderate and large n, computing confidence intevals for selected x provides a more
informative picture of statistical accuracy than the K-S approach. Nevertheless, in the present
case, the lengths of the normal intervals also imply that {Fn (x)} is not a particularly accurate
approximation to {F(x)}.
To generate a random sample X' from {Fn(x)}, we proceed as follows. Let {XI < X2 <
... < Xk(n)} denote the ordered collection of the k(n) distinct values in {X I, ... , X n },
a:= 1,
b := k(n),
PI := Fn(XI),
ql := PI,
Pi := Fn(Xi) - Fn(Xi-d,
and
0.9
0.8
0.7
0 .6
0.5
0.4
0.3
0 .2
- e.d.f.
o
o 2 3 4 5 6
Figure 10.3 Empiral distribution function {l\(x), X E X} and .99 K-S limits for
service-time data, n = 100
462 C HAP TE R 1 0 . PRE PAR I N G THE I N PUT
• Sample Z using the cutpoint method (Section 8.2) with {qa, ... , qb} as input
or using the alias method (Section 8.4) with {Pa, ... , Pb} as input.
• X' =Xz.
Repeated application of these steps generates a sequence of i.i.d. random samples from
the restricted support {Xl < ... < Xk(n)} ratherthan from the infinite support X. To increase
the set of values that can be sampled from {Xl < ... < Xk(n)} to [0, Xk(n)j, let
Xa-l := 0,
Fn(O) := 0,
lex) := min(i ::: a: Xi > X),
and
(10.3)
• Sample Z using the cutpoint method with {qa, ... ,qb} as input and U from U(O, 1);
• X +-
I
XZ-l
+ (Xz - XZ-l
) Fn(xz)-Fn(xz-Il'
U-Fn(XZ_I) •
produces a sequence of i.i.d. samples from {Fn (x), 0 < X :s Xk(n)}' For an alternative method
of interpolation that relies on the alias method, see Ahrens and Kohrt (1981).
As n increases, so does k(n) and, therefore, the memory space requirements for both
the cutpoint and alias methods. Indeed, each grows proportionately to k(n). If space is an
issue, one can resort to a space-conserving algorithm that, in effect, relies on an estimator
of the inverse d.f.
Q(f3) = XEX
inf [F(x) ::: f31 , 0:sf3:s1.
Let X(l) :s X(2) :s ... :s X(n) denote the order statistics of the sample Xl, ... , X n • For some
positive integer k :s n,
Qn(O) := 0,
Qn (j / k) := X(rjnfkl), j = 1, ... ,k,
is a k-point estimate of {Q(f3), 0 :s f3 :s I}. Then repeated execution of the step
10.3. EMPIRICAL D.F. ApPROACH 463
• J +- LkuJ.
• Z +- Qn(Jlk) +k(U - Jlk) [Qn((J + l)lk) - Qn(Jlk)].
• X" +- Z;
O:::;x:::;Qn(l),
d ~r (Q( 'Ik)
• n 1/2Q n ('Ik)
] --+ JV ] ,
(j/k)(l-j/k))
f(Q(jfk)) as n --+ 00.
ensuring that Fn (x) converges to F(x), for each x E Qk := {Q(11 k), ... , Q( (k - 1)1 k)},
as desired.
However, no such convergence occurs for x E X \ Qk. How serious is this absence of
convergence? The answer depends on k and n. If n = 100 and k = 10, the quantile method
is an imprecise method at best. For n = 106 , as may occur when large data sets are available,
choosing k = 1000 makes {Qn(j I k)} a sequence of.OOlj quantiles for j = 1, ... , 1000, so
that linear interpolation in the quantile method is over relatively small probability intervals
464 CHAPTER 10. PREPARING THE INPUT
where the error of approximation is far less than in the k = 10 and n = 100 case. Since
n = 106 would require space of order four (single precision) or eight (double precision)
megabytes for the cutpoint and alias methods, a simulationist inevitability has to make a
choice between a large space commitment and an error of interpolation at the .00 I-increment
level.
Definition 10.1.
Let Xl, Xz, ... denote a sequence of i.i.d. nonnegative random variables and let
So:= 0,
Sn := Xl + ... + X n, n = 1,2, ....
Definition 10.2.
Let {N 1 (t), t 2: O}, ... , {Nm(t), t 2: O} denote m independent renewal processes and let
{Nom(t) := Nl (t) + ... + Nm(t), t 2: O} denote their superposition. That is, Ni(t) denotes
the number of events oftypei that occur in (0, t], whereas Nom(t) denotes the number of events
of all types that occur. In general, {Nom (t)} is not a renewal process. However, in at least one
special case, it exhibits that property in the limit.
Foreachi = 1, ... , m, let Xii, X iZ , ••• denote a sequence ofi.i.d. nonnegative random
variables with d.f. {Fim(t), t 2: O}, and let
and
If A --+ constant as m --+ 00 and if for each m there exist E > 0 and t' > 0 such that
as m --+ 00.
Since by definition
the limiting distribution (as m --+ 00) of the time to the next event is the exponential £ (1 / A).
Gnedenko and Kovalenko (1989) attribute this result to Grigelionis (1962).
For many open -loop delay systems, it is not untenable to characterize the arrival process
as the limit of a large number of independent renewal processes each with relatively small
arrival rate. As a consequence, the exponential distribution becomes a candidate for data
analysis aimed at fitting an interarrival time distribution. This does not mean that we should
consider only this distribution. It does mean that within the framework of data analysis a test
for the suitability of the exponential distribution offers us some protection from allowing
the empirical data, based on a finite sample size, to dictate exclusively the estimated values
of the parameters. Estimates based on theory together with data analysis inevitably result in
more thoughtfully fitted distributions.
aT
Ys and YT : = - .
J-Ls J-LT
If W denotes waiting time, then under relatively mild conditions on Si, T;, and Si - kT;, W/ ())
converges to a random variable from £(1) as p t 1 (K611erstrom 1974).
For p close to unity, this implies that the distribution of W is approximately £ (1/ ())),
where W depends only on the traffic intensity p, the coefficients of variation Ys and YT, and
is independent of the parent distributions of the interarrival times T\, T2 , ••• and the service
times S\, S2, ....
For this commonly encountered delay system, this result implies that as the system
approaches saturation, the dependence of at least one of its output distributions becomes less
sensitive to the form of its input distributions and more sensitive to their first two moments.
For input data analysis for heavy-traffic systems, the result lessens our concern about input
distributional shapes but encourages us to obtain estimates for their means and variances
that are as accurate as possible.
Just as the characterization of a systems's logic flow benefits from the expert opinion of those
most familiar with the real system, so can the specification of input characteristics benefit
from their knowledge. Combining that knowledge with statistical inferences drawn from an
analysis of historical data is the most likely recipe for successful input modeling. When no
data are available, we need to rely exclusively on expert opinion. An example shows how this
knowledge can be converted. into an input distribution.
Recall the example of Section 1.5 where drums were delivered daily to the incinerator
complex. No historical data were available for delivery times. However, incinerator operators
revealed that drums never arrived before 11 a.m. nor after 4 p.m. When pressed by the
simulationist as to the most likely time of arrival, they indicated 2 p.m.
With only these pieces of information, distribution fitting had limited possibilities. The
simulationist chose to fit the triangular distribution (Exercise 8.7). In particular, m\ = 11,
m2 = 14, and m3 = 16 after the times were converted to a 24-hour basis. As a consequence,
In particular,
2
30'
t = 12,
6
30'
t = 13,
10
F(t) - F(t - 1) = t = 14,
30'
9
30'
t = 15,
3
30'
t = 16.
Sampling delivery times from this {F (t)} would result in almost two-thirds of delivery
occurring between 1 and 3 p.m. Since the incinerator operators were more certain about the
endpoints mI and m3 than the modal value mz, the simulationist chose to run at least two
additional simulations, one with mz = 13 and the other with mz = 15, and to compare the
output with that for mz = 14. Little variation in output would indicate that system response
was relatively insensitive to the choice of most likely delivery time.
By fitting a distribution, we mean selecting a theoretical p.m.f. or p.d.f., estimating the values
of its parameters from data or expert judgment, and, in the data case, assessing how well the
resulting fitted d.f. approximates the corresponding e.d.f. Graphical comparison provides
one means of assessment; applying one or more statistical tests provides a second.
Commercial software is available for fitting. For example, BestFit (www.lithec.
skJukJdts_bestfit.htm), ExpertFit (www.does.orglmasterli/s3.htm), and Stat::Fit (www.
geerms.com/default.htm) each use empirical data to estimate the values of parameters for
a host of candidate distributions and provide graphical displays and test statistics to guide
the choice among them. Also, some simulation systems such as Arena provide a capability
for fitting distributions. Using this software saves the simulationist's time; but he/she must
ultimately make the choice among the candidates.
Unfortunately, goodness-of-fit tests for distributions tend to be considerably less
discriminating than desired. In particular, the standard approach tests Ho: a particular dis-
tribution fits the data, against the omnibus alternative HI: one of the many nonspecified
alternatives fits the data. This setup is known to have low power, meaning that the test
accepts Ho more often than it should, thus being less discerning than an analyst would like.
Moreover, some of these software applications rank the desirability of the host of candidate
distributions by the values of their test statistics on a particular test. This practice encourages
users to choose the best-performing distribution according to the ranking. However, little
basis exists in the statistical literature to support these ranking schemes. In the remainder
468 CHAPTER 10. PREPARING THE INPUT
of this chapter we concentrate more on graphical analysis to assess the adequacy of fitted
distributions. These are usually available from the software fitting applications or are easily
computed by more general-purpose applications such as Microsoft Excel.
For nonnegative data, the most difficult part of a distribution to fit is its right tail.
Graphical analysis may reveal discrepancies between the tails of empirical and fitted d.f.s,
but except in the case of an exceptionally large sample size, the ability of statistical tests to
reject based on these discrepancies is relatively low.
If a simulationist knows something about alternative tail behaviors, then her/his ca-
pacity to choose among alternative fits can be greatly enhanced. This section provides an
overview of these alternatives.
The Gamma distribution (Section 8.13 and Table 10.3) is a commonly fitted distri-
bution that has an exponentially decreasing right tail. It often provides a basis for fitting
interarrival and service time data. It has mean IL = af3, variance a 2 = af3 2 , mode at
x = max[O, f3(a - 1)]. It also facilitates hypothesis testing for exponentiality (a = 1)
within the context of standard statistical theory. Section 10.12.2 illustrates this feature. For
a = 1 its (finite) mode is at x = 0. For a < 1, its (infinite) mode is also at zero. For a > 1,
its (finite) mode is at some positive x. Table 10.2 lists the maximum likelihood equations
that need to be solved iteratively for this distribution.
The Weibull distribution (§8.9.1 and Table 10.3) provides an alternative basis for
fitting with mean f3r(1 + Ija), variance f32[r(1 + 2ja) - r2(1 + Ija)], mode at x =
f3 max[O, (1 - ja)l/a], and right tail that decreases as exp[ -(xj f3)a]. This last property
implies that the data, more than model selection, dictate tail behavior, being more rapid
a a
than exponential if > 1 and less if < 1. The Weibull also facilitates hypothesis testing
for exponentiality (a = 1) within the context of the likelihood ratio test (Section 10.12.2).
The location of its mode follows analogously to that for the Gamma. Table 10.3 lists the
maximum likelihood estimates that need to be solved iteratively for the Weibull.
Fitting data to an exponential, Gamma, or Weibull p.d.f. implicitly restricts its mode
and right tail. For exponential fitting, the mode is at zero and the tail exponential. A Gamma fit
with a < 1 puts the (infinite) mode at zero and retains the exponential tail. A Weibull fit with
a < 1 again puts the (infinite) mode at zero but makes the tail diminish subexponentially. A
Gamma fit with a > 1 puts the mode at a positive value and continues to give an exponential
tail. A Weibull fit with a > 1 puts the mode at a positive value but makes the right tail decrease
hyperexponentially.
10.6. C H 00 SIN GAD I S TR I BUT ION 469
Occasionally, the empirical histogram reveals tail behavior that does not fit one of these
profiles. This is especially true when the empirical histogram shows the mode at a positive
value and a right tail that decreases at less than an exponential rate. If a simulationist were to
ignore this discrepancy between the e.dJ. and a fitted exponential, Gamma, or Weibull d.f. the
resulting sampling sequence during a simulation experiment would show proportionately
fewer large right tail values than the empirical evidence suggests. Accordingly, we need to
look at other options. This section discusses the lognormal distribution and §10.6A the
inverted Gamma and inverse Weibull distributions.
From Section 8.13, a random variable from the lognormal distribution eN (f-L, a 2) has
mean exp [-(f-L+a2 /2)], varianceexp(2f-L+a 2) x [exp(a 2)-I],modeatx = exp(f-L+a2/2),
and right tail whose dominant terms decreases as exp[-(lnx)2/2a 2] as x increases. Most
notably, tail behavior is slower than exponential in x, thus providing a candidate for data
with a "heavy" tail.
where
r
9.5 for Ig (2.4, .1282),
x(.99) =
9.0 for W (2.953, 2.914),
4.9 for IW (2.938, .5257).
In addition to revealing the wide disparity among the .99 quantiles, Figure 1O.4c shows
that although samples are generated from this part of each distribution no more than once
per hundred trials on average, when such an outcome X does occur the values of X tend to
be considerably larger for the inverted Gamma and inverse Weibull distributions than for
the Gamma and Weibull. We can easily recognize the significance of this property for service
times. In some repair processes, the vast majority of items require moderate repair times,
but occasionally an item requires an excessively large repair time.
For completeness, recall that the Beta-prime distribution of Section 8.14.1 also has a
right tail that decreases as a polynomial in x. We leave to the reader the exercise of showing
that this distribution has J.L = fJ/(a _1),0'2 + J.L2 = fJ(l + fJ)/(a - 1)(a - 2), and, for the
particularJ.L = 2.6 and 0'2 = 3.38,a = 4.7692andfJ = 9.800. A graph of the corresponding
p.d.f. is of interest when compared to those in Figure 10.4.
10.7 SUPPORT
Let X denote a continuous random variable with p.d.f. or p.m.f. Ix. The support of X,
supp(X), denotes all points in mfor which fx(x) is positive. For example, Z '" 9 (a, fJ)
has supp(Z) = [0, (0), whereas X := a + bZ, for b > 0, has supp(X) = [a, (0). If
Z '" Be(a, fJ), then supp(Z) = [0,1], whereas X := a + (b - a)Z, for b > a, has
supp(X) = [a, b].
Given a sample sequence Xl, ... , Xn for which supp(Xi ) = [a, (0) for known a i= 0,
one customarily works with the transformed data, X; := Xi - a, i = 1, ... , n, when
fitting a distribution. Ifsupp(X i ) = [a,b] forknownb > a,thenX;:= (Xi -a)/(b-
a), i = 1, ... , n, has support [0, 1]. If unknown, the support must be estimated prior to
estimating, or along with, the values of the parameters of the selected distribution. Clearly,
a ::::: minl:9::on Xi and b 2: maxl::oi::on Xi. When expert opinion indicates finite support
[a, b] and gives estimatesG and b satisfyingG ::::: minl::oi::on Xi andb > maxl::oi::on Xi, it is not
unusual to fit X; := (Xi - G)/(b - G), i = 1, ... , n, to the beta distribution Be(a, fJ). An
approach, more firmly grounded in theory, simultaneously fits a, b, a, fJ using the maximum
likelihood method (e.g., Johnson et al. 1994a and 1994b).
When b is assumed infinite, similar approaches are used with X; = Xi - G, i =
1, ... , n, and the exponential, Gamma, Weibull, and other distributions. As an example,
1 0.7. SUPPORT 471
(a) p.d.f..
0.8 ' ' ' ' . - - - - - - , . . - - - - - - -....''.... ,.."'''''....., , - - - - - - - - - - - - ;
0(2. 1.3)
-1O(4_12J2)
0-5
-W(1.9n.2-914)
- IW(2.9JlI,>U...'1
0.4
0.3
0.2
0.1
o 2 4 8 8 10 12
(b){pr(X >x)}
0.9
0.8
0.7
0.8
0-5
0.4
0.3
0.2
0.1
8 10 12
x
(0) {pr[X >xlX >x(.99)]J . x(.99):=.99quantile
1 "--------,-~.,-----------
0.8
0.8
Figure 10.4
Selected distributions
with {l = 2.6 and
(72 = 3.38
5 8 7 8 9 10 11 12 13 14 15
x
472 C HAP TE R 1 0 . PRE PAR I N G THE I N PUT
fj = min Xi
l~i~n
and
A 1
A= -
n
L (Xi - fj).
n
i=1
For discrete data, comparable techniques can be used with the binomial distribution if the
support is finite or with the Poisson, negative binomial, or other distributions, if the support
is infinite.
By way of interpretation, 0 is the value that maximizes the likelihood of observing the given
sampleX.
For the distributions we consider here, all of which are described in Chapter 8, the
maximum likelihood estimator (m.l.e.) 0 of 8, has the folloing important properties:
10.8. MAXIMUM LIKELIHOOD ESTIMATION 473
• Uniqueness. 8 is unique
• Strong Consistency. 8 --+ 0 as n --+ 00 w.p.1
where
i, j = 1, ... , q
• Invariance. For any function, {h (O)}, {h ( 8)} is its m.l.e., thus inheriting the properties
of strong consistency, efficiency, and asymptotic normality.
In large samples, efficiency implies that no alternative estimator of (}i has smaller
variance than the m.l.e. Asymptotic normality provides a distribution theory for assessing
how well 8 approximates O. In particular, for each i [Oi ± <1>-1 (1 - 8/2)s.e.(Oi)] with
1/2
s.e.«(}d := (var (}d
A A
provides a 100 x (1 - 8) percent confidence inteval for (}i, ifvar Oi were known. Since it is
not, we replace it with the i th diagonal element of ~ (8) / n, which by the invariance property
is the m.l.e. of var Oi and therefore inherits the property of efficiency. That is, for large n no
alternative estimator of var Oi has smaller variance.
474 CHAPTER 10. PREPARING THE INPUT
1/2
r.e.(ei ) (var ei ) lei
A._ A
.-
e;
provides an additional measure of how well approximates ei •
These m.l.e. properties hold for any distribution representable in the form
where A, B, C, and D are arbitrary functions. Collectively, they define the class ofDarmois-
Koopman distributions (e.g., Johnson et al. 1994a). Virtually all distributions discussed in
this chapter admit representations of this form.
o EXAMPLE 10.1
Let XI, ... , Xn denote i.i.d. observations from £(f3) with p.d.f.
f3 > 0, x::: o.
n
InL(O,X) = -nlnf3 + r l LXi,
i=1
1~
el = f3 = -
A A
~ Xi,
n i=1
varf3
A
= f3 2 In,
1/2
s.e.(f3) = f3ln ,
A
and
A s.e.(~) 1
r.e. (f3) := -f3- - nl/2'
o
10.8. MAXIMUM LIKELIHOOD ESTIMATION 475
Table 10.2 lists selected continuous and discrete distributions whose m.l.e.s are avail-
able in closed form. Table 10.3 lists selected continuous and discrete distributions whose
m.l.e.s are computed by iterative methods. In particular, Algorithm N -R in Section 8.1.1 de-
scribes the Newton-Raphson method for finding the m.l.e. for one parameter using {k(z)}
and {k'(z)} in Table 10.3 for the Gamma, Weibull, and negative binomial distributions.
Then the rightmost column gives the form of the second parameter estimator. For example,
Algorithm N-R determines & for the Gamma distribution and ~ = A/&. An error bound
v .::: 10-6 is recommended for error tolerance in the algorithm.
e.
Tables 10.3 and 10.4 also list the large-sample form for var In the remainder of this
chapter these quantities are evaluated with vare replaced by its m.l.e.
All iterative computations rely on the availability of procedures for computing the
digammafunction {1/I(z) := dlnd~(z)} and the polygamma function {1/1(1) (z) := d~~z)}. These
are available in Mathematica and Mathcad. Since these are slowly converging infinite series,
we encourage a user of the iterative procedures in Table 10.3 to employ one of these packages
rather than to write his or her own procedures for these functions from first principles.
o EXAMPLE 10.2
In fitting the Gamma distribution to the service-time data with empirical histogram
in Figure 10.2, the m.l.e. are
Figure 10.5a compares the exceedance probabilities for the e.dJ. in Figure 10.2 with
those for the fitted dJ. Figure 1O.Sb shows their difference, and Figure lO.5c compares the
conditional right tail exceedance probabilities. The first two graphs reveal a relatively good fit
for just n = 100 observations. In particular, Figure 1O.5a shows that the fitted dJ. introduces
smoothness that is notably absent in the e.dJ.
Because X(i) and X(n) are finite, sampling from an e.dJ. limits its sample values to
[X(i), X(n)l. This can be a serious limitation when X is believed to have infinite support on
the nonnegative line or at least an upper bound much larger than X(n). Figure 1O.Sc shows
how the fitted d.f. overcomes this limitation of the e.d.f.
~
~
(")
I
f32 ~~
exponential £ (f3) f3 o P=A EP = f3 varp = ~ MI»
n· ~ g,
f3>O -5" g:
x:=:O
:>< s·
b:lc.
- 0
2 ·Ii 8.-
lognormal CN (/L, 0"2) e"+u 2 /2 e2JL+u2 (eu2 - 1) e"+u 2 /2 (L = A' E(L = /L var(L=~
::II 8'
-..,
-00 < /L < 00 8- 2 = B' - (A')2 E.a 2 =R:IU 2 var u1 = 20"4 corr«(L, a2) = 0 MS
n -. ~
!!.
0"2> 0 S
~
->< N
x:=:O ~
distribution mean variance mode m.l.e. properties Si
g:
p(I;:P)
Bernoulli J3er(p) p p(l- p) Oifp < t p=A Ep=p var p =
...?n
N
L>..J otherwise
~
»
x = 0,1, ... x
-
3:
c
geometric ge(p)
3:
r-
A A
O::;p::;1 ....L 0 Ep--+p nvar p --+ p(1 _ p)'
I-p (I_~)2 p = I+A /<;
m
as n --+ 00 as n --+ 00 I
0
X = 0,1, ... 0
0
m
(J)
-I
3:
»
-I
0
Z
~
....
....
~
""
.... G'l~~ (")
distribution mean variance mode I
~~
N' N' ',', no
Gamma Q(a, f3) af3 af32 max[O, (a - 1)f3] •.•. ;:s
e:.... >
."
a, f3 > 0 II II I Q --I
;:sI ;:sI M- t.. m
x~O
'"
.......
Weibull W(a, f3) max[O, f3(1 - l/a)l/a]
MMr~ o
f3r(1 + l/a) f3 2[r(2 + l/a) - r2(1 + l/a)] [~[ ~ ->s a
a, f3 > 0 ~><:- 8.-
-;::::-'N C"':l Q..
x~O -0
i: S" H la' '"m
..!L rp + :.><:;:s;a, ."
negative binomial NB(r, p) (l_p)2 wand w + 1 if LwJ = w !.. ~
I-p >
r > 0, 0 ~ p ~ 1 Lw J otherwise N -. ~
~~Mg·::s '"z
-II (I)
x = 0,1, ... w := (rp - 1)/(1- p) G)
',i -S" ~
--I
;:s ><: ~ I
!..:. '" m
asymptotic properties M tl ?
.... ;:1 •• ~
Z
distribution variances correlation !!. II!' ."
~ C
A -'N (1)
p2
><: ;:sI
A a 1 --I
Gamma vara ~ [a1fr l l)(a)-I[n varf3 ~ 1fr(1)(a)[a1fr(1)(a)-I)n ~ - a1fr(1) (a) '0 -~
::s M-.
><:-.~ti1
Weibull vara ~ 1.109(f3/a)2/n varfi ~ .608a 2 /n ~ .3812 ::::....!!. ::;."
.. N 5'" ~
.... ~I»
A ~ 1___ -p - ....... t:!".
negative binomiala varr ~ M(r,p)n varfi ~ ! [P(I+P) + ~] ~ [ 0
n r r 2M(r,p) ~ M(r,p)r[ var, varpf/2 •• ::s
II.?<~
;:s - ••
!..~ II
iterate second MN' ;:Sl
distribution onz = k(z) k'(z) estimator ~'~~M
A A - II
Gamma a 1/f(l)(z) - ~ ~;:s TI'~
1/f (z) - In z + In A - C f3 = - ~ I-
z a N _ ><:
! _ G(z) +c 1 H(z)
+M:'
Weibull a E(z) E(z)
fi = [E(a)j1/a _.
><: -. ~ II
z E(z) - zr - + [ G(z) r
A A 7'=~
negative binomial r In( z~A) + /(z) -1/f(z) ~ - Z~A + J(z) -1/f(l)(z) P=-A-
r+A
j+2
aM(x, Y):= L~o Bj~r> (Jiy) ,where B denotes the beta function.
10.8. M A X I MUM LIKE L I H 00 DEs TIM A T ION 479
0.9 - l-e..d.f
0.8 - I · f'i l~cd d.r.
0.7
0.6
0.5
0.4
0.3
0.2
0.1
o o~------------------~~==~==~
3 4 5 6
X
0.01
- 0.01
- 0.03
For n observations Xl •... , Xn from the Beta distribution Be(a, (3) (Section 8.14),
the logarithm of the likelihood function is
In L(a. f3. X) = n [In rea + (3) -In rca) -In r(f3) + (a - l)C + (f3 - l)D] ,
480 CHAPTER 10. PREPARING THE INPUT
simultaneously for the m.l.e. &; and~, where 1fr denotes the digamma function. This presents
more formidable problems than solving for the other m.l.e.s in Table 10.3.
Bivariate search provides one approach, starting with the initial values
Ot := (A - B)AI(B - A2)
and
the moment estimators ofa and fJ (Fielitz and Myers 1975). Familiarity with bivariate search
techniques is necessary.
A second approach reduces the problem to a univariate search for &; by combining the
likelihood equations to obtain (Beckman and Tietjen 1978)
A 1
vara ~ 1fr(l)(a + fJ)[IIQ(fJ, a) - Q(a, fJ)]n'
A 1
var fJ ~ 1/1 (I) (a + fJ)[IIQ(a, fJ) - Q(fJ, a)]n'
10.8. MAXIMUM LIKELIHOOD ESTIMATION 481
A -1
corr(a, (3) ~ [Q(a, (3)Q(f3, a)]l/2'
where
The Beta distribution of Section 8.14 is a special case of the generalized Beta
distribution
Ifzl andZ 2 are known exactly, then one transforms Xl, ... , Xn to {(Xi -Zd/(Z2 -Zl); i =
1, ... , n} and proceeds as above. If Zl and Z2 are unknown, estimation becomes more prob-
lematic. In particular, the m.l.e.s for a and f3 are sensitive to values assumed for Zl and
Z2' AbouRizk et al. (1994) provide software called BetaFit for estimating a, f3, Zl> and Z2
by several different methods. The reference shows that least-squares estimation generally
gives as good and often a better fit than the m.I.e. VIBES, accessible on the Internet at
http://www.ie.ncsu.edu/jwi1son/page3.html. provides the software for BetaFit.
To estimate the m.I.e. of the Beta-prime distribution, we make use of its relationship
to the Beta distribution. Recall from Section 8.14.1 that if Z is from Be(a, (3), then X =
Z-l -1 is from the Beta-prime distribution with support [0,00) and right tail that decreases
polynomially. To estimate a and f3 for this distribution for sample data Xl, ... , Xm one
replaces Xi by 1/(1 + Xi) for i = 1, ... ,n everywhere in the adopted m.I.e. procedure for
Be(a, (3).
Maximum likelihood estimators are easily computed for the inverted Gamma distri-
bution (Section 8.13.1) and the inverse Weibull distribution (Section 8.9.2) by exploiting
their relationships with the Gamma and Weibull distributions respectively. Recall that if X
is from rQ(a, (3), then 1/ X is from Q(a, (3). Accordingly, the m.l.e.s a and fi for rQ(a, (3)
are obtainable using {k(z)} and {k'(z)} for the Gamma distribution in Table 10.3 with the
revised definitions
n
Li=l X-I
I
482 CHAPTER 10. PREPARING THE INPUT
and
n
Li=l X:-I 2 •
In an analogous manner, the m.l.e.s a and fi for IW(a, fJ) are obtainable using
{k(z)} and {k'(z)} for the Weibull distribution with
n
E(z) := n- l Li=l X- z
i '
n
G(z) := n- l Li=l Xi z In(Xi l ),
and
n
H(z):= n- l Li=l XiZ[ln(Xil)]2.
• Routing that temporary entities follow as they flow through the system
• Scheduling of resources.
They can also affect sample averages collected during a simulation. For example, management
decision-making may require estimates oflong-run averages and exceedance probabilities
for waiting time and queue length for jobs partitioned by attribute values.
Whenever any of these issues arise in a simulation study and attibute values affect
the values that interarrival and service times assume, relying on distributional fitting as in
Section 10.8 runs the risk of seriously misrepresenting system dynamics within the corre-
sponding simulation model. Section 10.10.1 addresses this problem. When none of these
issues arise but attribute values nevertheless affect inter arrival and service times, the fitting
of unimodal distributions as in Section 10.8 may again be inappropriate. Section 10.10.2
addresses this topic.
If an attribute affects decision flow and also interarrival and service times, then, to
ensure the fidelity of the system's logic, the corresponding simulation program must incor-
porate procedures for explicitly sampling these quantities from distributions conditioned on
attribute values. For example, if customers in the airline reservation problem of Chapter 2
were selected for service based on type, then this mandate would apply. We use the service
time distributions for that problem to describe the issues that arise in estimating parameter
values.
In the airline reservation problem, recall that lOOp percent of callers want multides-
tination reservations and are assumed to have service times from the Erlang distribution
484 CHAPTER 10. PREPARING THE INPUT
Q(2, 1j w). Also, 100(1- p) percent of callers want a single-destination reservation and have
service times from £(Ijw). Suppose that the service-time distributions are unknown and
need to be estimated.
Three data-analysis scenarios are possible:
1. The proportion P is known and service-time data are available by type of customer.
2. The proportion P is known and service-time data are not identified by type.
4. The proportion p is unknown and service-time data are not identified by type.
When Scenario 1 obtains, a service-time distribution is fitted separately for each type
of data. Given the value of p and the two fitted distributions, a simulationist now has the
essentials for generating service times by type in the simulation.
If the historical data in Scenario 3 contain n I service times for single-destination
callers and n2 service times for multiple-destination callers, then one estimates p by P =
nz/(nI + n2) and fits the two service-time distributions as with Scenario 1.
If p is known but the historical data do not reveal type (Scenario 2), estimation becomes
much harder. Suppose we want to fit Q(aI, fh) to service times for single-destination callers
and Q(a2, f32) to service times for multiple-destination callers. That is, we want to estimate
aI, f31> a2, f32 in the mixtureofp.d.f.s
xa2-Iex/fJ2
+ p f3~2f'(a2)'
x ::: 0,
which is the p.d.f. of a randomly selected customer. Since we cannot identify service times
by type, the likelihood function for the service-time data X I, ... , Xn becomes
Finding aI, f31> a2, and f32 that maximize L is a considerably more challenging nonlinear
optimization problem than what Section 10.8 describes. The severity ofthe problem increases
if p is unknown and also has to be estimated as in Scenario 4.
The airline reservation problem with unknown service-time distribution merely il-
lustrates a more general data-fitting problem that arises whenever the data are not available
in a partition that reflects how a critical attribute or attributes influence the data values.
Inevitably, the challenge is to estimate the values of parameters in a mixture of distributions
P + ... + Pr = 1,
where Pi denotes the proportion of type i and It, ... , Ir are p.d.f.s or p.m.f.s. Whenever
Scenarios 2 and 4 prevail, convenient estimation via the maximum likelihood method is
usually not possible.
When attributes that affect service times do not influence decision flows, one can, in
principle, generate these times either by attribute type from the conditional distributions
11, ... , Ir or directly from the unconditional distribution I. Both options induce sample
paths during simulation execution that lead to sample averages that converge to correct
limits. However, data availability again limits the choice of options.
If Scenario 1 or 3 prevails, the simulationist is well advised to fit It, ... , Ir separately.
Since they are more likely to be unimodal than the unconditional distribution I, the method
of Section 10.8 for entries in Tables 10.2 and 10.3 applies to directly fitting It, ... , Ir more
often than to I. When Scenario 2 or 4 prevails, fitting 11, ... , Ir in this way is not possible.
Moreover, using the maximum likelihood method to fit I presents a formidable problem.
An alternative fits the data to a possibly multimodal distribution from which samples
can be drawn relatively directly during simulation execution. In principle, this approach
puts the mixture issue aside and concentrates on curve fitting. Wagner and Wilson (1996)
offer Windows-based software, PRIME (Probabilistic Input Modeling Environment), to
fit the data to a continuously differentiable I formulated by exploiting the properties of
Bezier curves. These are a special class of spline curves whose mathematical and numerical
properties are well suited to simulation input modeling.
PRIME offers a user the choice optimizing criteria for fitting the resulting Bezier
distribution. These include the methods ofleast squares, minimum L1 norm, minimum
Loo norm, moment matching, percentile matching, and maximum likelihood. A limita-
tion of PRIME is that it assumes bounded support. PRIME is available on the Internet at
http://www.ie.ncsu/jwilson by clicking on "software."
or
Since nonstrictly stationary input phenomena are inconsistent with a simulation method-
ology aimed at deriving estimates oflong-run averages, we ignore this case and concentrate
on stationary but dependent input phenomena. In what follows, we describe dependence as
it relates to an arrival process. However, the applicability of the concepts to a more general
setting should be apparent to the reader.
If dependence exists among the observations in a historical record of interarrival
times that one plans to use to create an interarrival-time generator in a simulation model,
neither does the method of Section 10.8 apply for fitting the data to a distribution nor
does the sample-generating procedure for i.i.d. interarrival times apply. To overcome these
impediments, we partition our discussion into two parts. Sections 10.11.1 and 10.14 address
problems in which the data are all functions of some exogenous phenomenon such as time.
Section 10.11.2 addresses the problem in which dependence in the data is tied to considerably
more localized considerations.
The commonly encountered concept of arrivals to a delay system is that they arise
from a large number of independent sources each of which contributes at a relatively small
rate. However, other arrival patterns do occur. For example, it may be that short interarrival
times occur in clusters, merely reflecting an institutional feature of the external world that
provides input to the system being simulated.
How does dependence among interarrival times effect queueing behavior? If depen-
dence takes the form of positive correlation and a procedure ignores this property but
nevertheless generates interarrival times from the correct marginal distribution, the result-
ing sample paths for queue length and waiting time tend to understate the level of congestion
10.11 . D E PEN DEN T HIS TOR I CAL DA TA 487
in the system. When suspected, the first task is to test for dependence. Testing the data for
a flat spectrum using the periodogram and Kolmogorov-Smirnov test provides a compre-
hensive approach (e.g., Brockwell and Davis 1991, p. 339). Rejection implies the presence
of dependence. Whenever applications software is available to perform this test, the sim-
ulationist is well advised to take advantage of it. When not available, other less powerful
procedures are occasionally used.
One approach relies on the von Neumann ratio (6.65)
with a two-sided test. That is, one rejects the hypothesis of independence H at the 100 x 8
percent significance level if
where
As Section 6.6.8 indicates, this procedure tests the hypothesis PI = 0, where PI denotes
the autocorrelation oflag 1 in the sequence (Section 6.5). If, in reality, the data are dependent
with a non-monotone-decreasing autocorrelation function (6.6), then it is possible that PI is
close to zero but subsequent auto correlations, Pj, I j I> 1, are substantially different from
zero. This consequence limits the value of the procedure.
To overcome this limitation, a third procedure uses the sample autocorrelations
_1_ ",n-j - )( - )
n-j L...d=1 (Xi - Xn X i + j - Xn
Pj = -"-----;:-::=::------=----- j = 1, ... , j*,
1 "'~ (X., - X n )2
n L..,,=I
for some user-selected lag j* « n. If the data are independent, then under relatively general
conditions
as n --+ 00.
We describe one ofseveral ways ofexploiting this limiting result. For some a E (0, 1), suppose
a simulationist regards a lagged correlation Pj E [-a, a 1as ofnegligible importance. If A j (a)
denotes this event, then for large n
488 CHAPTER 10. PREPARING THE INPUT
implying that under H we expect to encounter I Pj l:s a about 88.62 percent of the time.
If j* = 100 then the mean number of exceedances for PI, ... , PIOO is 100 x (1 - .8862) =
11.38. If a = .05, n = 2000, and j* = 100, the mean number of exceedances under H is
100(1 - .9746) = 2.54. Observing no more than the average number of exceedances gives
credibility to H.
Sometimes a significance level a is specified so that a = <I>-I(1-a/2). Then the mean
number of exceedances under H is j*a.
T; := interarrival time,
Ni := number of pages to be copied,
Si := photocopying time.
Times came to the simulationist rounded to the nearest minute. That is, if Tj' and S; were
customer i's true interarrival and photocopying times, respectively, in minutes, then the data
were the integers
T; = LTj' + .SJ
and
Si = LS; + .SJ.
Since both interarrival and photocopying times are continuous, the implications of the
recording method need to be understood. In particular, T; = 0 for 0 < Tj' < .5 and Si = 0
for 0 < S; < .5, which substantially misrepresented the true behavior of small interarrival
10.12. LIBRARY PHOTOCOPYING (SECTION 1.4 EXAMPLE) 489
and photocopying times. To reduce the severity of this error, Ti and Si were redefined as
{"25
if If' < .5,
Ti = LT{ +.5J if T{ :::: 1,
and
Si =
ILS;
.25
+.5J
if
if
S; < .5,
S; : : .5,
respectively. This enables us to regard {Ti} and {Sd as sequences of midpoints of the
discretization intervals [0, .5), [.5, 1.5), [1.5,2.5), ....
Table lOA shows the number of arrivals by time of day and day of week. If arrivals
were independent of these two phenomena, then a single sampling distribution would suffice
for all interarrival times, thereby simplifying the estimation procedure and the subsequent
sampling procedure. Accordingly, a two-way analysis of variance (ANOVA) was performed
on these data to test the hypotheses
and
10 a.m. 17 14 18 18 13 80
11 23 32 20 11 17 103
12 p.m. 15 19 19 17 17 87
1 27 21 22 19 25 114
2 23 24 6 14 27 94
3 15 18 13 32 20 98
4 13 18 15 11 8 65
Daily
total 133 146 113 122 127 641
490 C HAP TE R 1 0 . PRE PAR I N G THE I N PUT
For each test, the p-value estimates the probability of observing a test statistic in excess
of the corresponding computed F. Hence, the p-value decreases with increasing F. Common
practice rejects a hypothesis if its p-value is less than .05.
In the present case, the ANaVA provides little support for rejecting HI> H 2, or HI U
H 2. However, we must be cognizant of two factors. First the statistical power of a test to
detect differences is often low when the alternative hypothesis consists of all possible types
of differences, as is the case here. Second, the pattern of library usage was known to have
fewer arrivals in the early morning (10-11) and in the late afternoon (4-5) than during the
remainder of the day (11-4). These factors encouraged testing H2 against the hypothesis
H3 : Arrival rates in hours 10-11 and 4-5 differ from those in hours 11-4.
The data in Table lOA also arouse suspicion that the large number of arrivals on Tuesday
indicate that this day differs from the remaining four. This observation encouraged testing
of HI against the hypothesis
Testing one hypothesis against a specific alternative, as in the case ofH 2 versus H3 and HI
versus H 4, increases the statistical power of ANaVA to detect differences, when they exist.
Table 10.6 displays results of these ANavAs. They reject H2 in favor of H3 at the
.05 level but provide no support for H4 over HI. Accordingly, interarrival time data were
partitioned into two groups. The analysis that follows focuses on the arrivals in the peak
interval 11-4.
The aggregated sample consisted of n = 493 interarrival times with sample mean,
variance, and standard errors
the last of which attests to the relative stability of (LT as an estimate of the true mean J-tT.
Figure 1O.6a shows the empirical histogram. Together with the discretization, described
earlier, the absence of mass at 11, 17, 18, 20, 23, 25, 27, and 28 minutes would severely
limit the values of interarrival times, were the histogram used as the basis for sampling
in a simulation. Accordingly, we fit a continuous distribution. The shape of the histogram
10.12. LIB RA RY PH 0 Toe 0 P YIN G (S E C T ION 1.4 Ex AMP L E ) 491
encouraged the fitting of a Gamma distribution 9 (a, (3) (Section 8.13). However, the sample
coefficient of variation fir / fiT = 1.100 is relatively close to unity, which is the coefficient of
variation of the exponential distribution, a special case, 9 (1, (3), of the Gamma. Both options
were considered. First, we describe the effect of discretization on the parameter estimation
procedure.
Because of discretization, the likelihood function is
L(a, f3, no, nl, .. ·, nk) = [F(.5Wo Il~=l [F(j + .5) - F(j - .5Wj, (10.6)
where
In effect, the approximations .5f(.25) ~ F(.5) and f(j) ~ F(j + .5) - F(j - .5) for
j = 1, ... , k were used.
Maximizing with respect to a and f3 led to the m.l.e.
where the relative errors attest to the stability of &and ~ as estimates of the unknown a and
f3. The corresponding fitted distribution, which would serve as the basis for sampling in the
492 CHAPTER 10. PREPARING THE INPUT
0.20
I
0,115
0.10
0.06
0.00
10 12 14 16 18 20 22 24 2S 28 30
time (minutes)
(b) Gamma fi t
1.00
0 .10
0 .60
:E 0 .500
2
£ 0 .40
0 .30
0 .20
0,10
0.00
'0 ,10 - 10
" 20 25
••
time (minutes)
0.02
~
~ 0 .01
""6
0
.(l.Ot
-0.02
0 5 to 15 20 25 30
lime (minutes)
simulation, is
Note that & < 1 implies a monotone decreasing p.d.f. unbounded at t = O. Statistical tests
of how well {F(t)} approximates {F(t) = [,8ar(a)]-1 f;
za-l e-z/Pdz, t :::: O} customarily
rely on a comparison of F and the empirical d.f.
1
L I[Ti,oo)(t),
n
F(t) = - (10.8)
n i=l
Figure 1O.6b displays the fitted exceedance d.f. {l- F(t), t :::: O} in black and the dif-
ferences {F(t) - F(t), t :::: O} in gray. As discussed in Section 10.3.2, visual assessment of the
difference graph provides one statistical evaluation, albeit a subjective one. The appearance
of the difference curve suggests a relatively good fit.
Now to the special case of the exponential distribution g(1,,8) with p.d.f.
,8 > 0, t :::: O.
Clearly, & = 1.047 adds considerable plausibility to the hypothesis Q: a = 1. Moreover, the
aggregate arrival process to the library's photocopiers fits our description in Section 1004.1
of a superposition of many independent renewal processes each with comparatively small
arrival rate. Thus the distribution of the interarrival times for the aggregate process are well
approximated by the exponential where the error of approximation tends to decrease as the
number of renewal processes increases.
Maximizing the likelihood function (10.7) with respect to ,8 yields the m.l.e. =Pe
ILT = 3.030, which has the same standard errors as ILT in expression (10.1). The
corresponding fitted d.f. is
t :::: O. (10.9)
Figure 1O.6c shows a marginal superiority for the Gamma fit, which is to be expected.
How are we to choose between the two fits? Let us summarize the facts:
• The interarrival time data estimate the mean as ILT = 3.030 and variance as &/ =
11.12, implying a coefficient of variation 1.10.
• The Gamma fit estimates the mean as &P = 3.030 and variance as &p 2 = 8.766,
implying a coefficient of variation .9771.
• The exponential fit estimates the mean as Pe = 3.030 and variance as P; = 9.181,
implying coefficient of variation unity.
494 C HAP TE R 1 0 . PRE PAR I N G THE I N PUT
• Sampling from [(Se) is less time consuming than sampling from Q(a, S).
Interestingly, the Gamma fit has the lowest coefficient of variation. As discussed earlier,
system congestion tends to grow with increasing coefficient of variation. Therefore, sampling
from either Q(a, S) or [(Se) induces less congestion than sampling from the empirical
dJ. {F(t)} would. However, this reduction is less for [(Se)' This, together with less costly
sampling, favors the exponential choice.
a
In the present case, the proximity of to unity encourages us to choose the exponential
a
fit. However, what would we have done if were, say, 1.1 or 1.2? A perusal of difference curves,
as in Figure 10.6c, would provide some help. However, a more objective statistical criterion of
acceptability is desirable. The likelihood-ratio test provides a basis for increased objectivity.
Recall that L*(1, fJ) is merely the likelihood function L*(a, fJ) in expression (10.7)
under the hypothesis Q : a = 1. Because of this constrained optimization in the exponential
case, the likelihood ratio
R ._ _L_*_(1_,-,-S.".e,_n_o_,_n_l,_._._._'n_k...:...)
.- L*(a, S, no, nl, ... , nk)
where X~-l denotes a chi-squared random variable with n - 1 degrees of freedom. In the
present case
-21n R = 17.15.
For the distributional limit (10.10),
which is an estimate of the probability of observing a Xi92 random variable greater than
-21n R = 17.15. In the present case the p-value gives no support to rejecting Q.
An analysis of the data for the off-peaks hours (10, 11] U (4,5] gave sample mean
(IT = 3.528 and variance 8-j = 12.80 for inter arrival time. Moreover, maximum likelihood
estimation and likelihood ratio testing led to the conclusion that off-peak interarrival times
10.12. LI B RARY PHOTOCOPYI NG (S ECTI 0 N 1.4 EXAMP LE) 495
were from £(3.528). Section 10.14.1 addresses the issue of how to merge the peak and
off-peak arrival processes for sampling.
e-AA i
pr(X = i) = -.-'r-'
I.
A> 0, i = 0,1, ....
If Y has the negative binomial distribution N B(r, p), then
varX
variance-to-mean ratio = EX = 1.
By contrast, N B(r, p) has EY = rp/(l- p) and var Y = rp/(l- p)2, so that
. . varY 1
vanance-to-mean ratio = - - = - - > 1.
EY 1- P
Since the data yielded the sample mean {LN = 22.94 and sample variance a~ = 1661
for a sample variance-to-mean ratio 72.40, and since the empirical histogram in Figure 10.7a
revealed substantial right skewness uncharacteristic of the Poisson, the negative binomial
distribution was chosen for fitting. The resulting m.l.e.s are
P = .9740, ft = .9594,
s.e.(p) = .0520, s.e.(ft) = .002626,
r.e.(P) = .05360, r.e.(ft) = .00274,
corr(P,ft) = .7947.
Figure 10.7b shows the fitted exceedance dJ. in black and the difference between the empirical
and fitted d.f.s (in gray). The difference curve reveals no absolute difference greater than .06
between these dJ.s. It also shows that each difference is relatively small when compared with
its corresponding ordinate on the fitted dJ.
496 C HAP TE R 1 0 . PRE PAR I N G THE I N PUT
0.90
• F'ned ~~ 6,( N8(.970lw9S94)
. clT1'iicald.(-IRdd.L
0 .70
I
~ 0 .50
0 30
0.4
0.3
>.
'2i 0.2
~ 0.1
0.0
.(l.1
1'111~1111I1111111111I1111I1I11111I1U11111I1I1II11I11I',"""''''.',"'
.(l.2
o 10 20 30 40 50 60 70 80 90 100
N
While the sample variance-to-mean ratio supported the decision to fit the negative
binomial rather than the Poisson distribution, it is nevertheless instructive to show the
results of fitting the latter with 5. = MN = 22.94. Figure 1O.7c shows the differences with
the empirical d.f. The superior fit of the negative binomial is unequivocal.
with
N
S=a+ LVj =a+bN+N I / 2 E, (10.11)
j=1
where
a := setup time,
L (Vj - b),
N
E := N I / 2
j=1
EE = 0,
var E = (f2.
80
]'
~
60
~
">
40
20
0
0 50 100 150 200 250 300
: ::::::=:=:::~:~:::~:~:=~:=:~
3 .. '
0.70
0.50
0.30
0.10
.(l.10 --------------,-""""""'''''''''''''''''''''-
o 5 10 15 20 25 30 35 40
S (minutes)
with three parameters a, b, and 0'2 to be estimated. This was done by choosing a and b to
minimize the sum of squared errors
1 1
L El = L (Si -a -bNY,
i=l i=l
giving
and
~L
1
&2 = N i- 1 (Si - a- b N )2 i
[ i=l
~L
1
= N i- 1 {(Si - a - b Ni) - [a - a + (b - b)N;]}2
I ;=1
= .7685,
Therefore,
and
a
Substituting &2 for &2, we estimate the standard errors of and b as
and
s > 0,
10.12. LIB RA RY PHOT 0 COP YIN G (S E C T ION 1. 4 ExAMP L E) 501
so that S given N has dJ. {F(s; aN, fiN), s ::: OJ. Then
1
L
A n
FG(s) := - F(s; aNi' fiN,), s > 0,
n ;=1
provides an estimator of the unconditional dJ. of copying time S independent of the number
of copies N. For the data SI, ... , Sf> the empirical d.f. is
1
L
I
Pes) =I I(Si. oo) (s), s ::: o.
;=1
Figure 1O.8c displays the fitted unconditional exceedance dJ. {l - FG (s)} and the
difference {Pes) - FG(s)}. The relatively small absolute differences encourage us to accept
this method of approximating the conditional dJ.s of photocopying time.
It is of interest to cast this estimation procedure in the context of general linear re-
gression and to contrast the model (10.11) with the more commonly encountered form of
linear regression. Let
and
and
If the data in Figure 1O.8a had revealed deviations {S; - a - bN;; i = 1, ... , I}
that fluctuated independently of the N;, then we would have been tempted to use the more
502 CHAPTER 10. PREPARING THE INPUT
and
y'=c}
10.13 WASTE GENERATION (SECTION 1.5 EXAMPLE)
An analysis of daily waste-generation data for the incinerator problem in Section 1.5 illus-
trates one way in which empirical distributions can be the basis for sampling workload. Recall
that each of the four sites or campuses produces liquid waste, which it stores in 55-gallon
drums until they can be transferred to the incinerator for disposal. Let
and
Table 10.7 shows these frequencies. Since no waste generation occurs on weekends and
holidays, these days have been omitted. The generating processes at the four campuses
proceed independently of day of week, week of month, and month of year. These properties
suggest that daily waste generation at each campus be sampled from its own empirical
distribution.
Campusi 0 1 2 3 4 Total
1 193 32 0 227
2 145 60 28 13 4 250
3 204 25 13 3 246
4 176 6 0 0 183
10.13. WASTE GENERATION (SECTION 1.5 EXAMPLE) 503
Pij := probability that on an arbitrarily selected day the campus generatesj drums,
Given the marginal sums N 1 , ••. , N 4 , the maximum likelihood estimates of the Pij
are
Nij
(10.14)
A
Pij=-
Ni
and correlations
j =j:. k.
Table 10.8 Maximum likelihood estimates of the Pij for daily waste generation
Campus Pij
j=O j=1 j=2 j=3 j=4
1 .8502 .1410 .004405 .004105 O•
2 .5800 .2400 .1120 .05200 .0160
3 .8293 .1016 .05285 .01220 .004065
4 .9617 .03279 .005464 O. O.
504 CHAPTER 10. PREPARING THE INPUT
through 1'; := the number of days that elapse between successive positive waste generation
at campus i. Since 1 - PiO is the probability of waste generation on a given day,
t = 1,2, ... ,
with mean
1
E1'; = ri:= - - - .
1 - PiO
Since
we have the approximating 100 x (1 - 8) percent confidence interval [WI (Nij, N i , <I> -1 (1 -
8/2», w2(Nij' N i , <1>-1(1 - 8/2»] for Pij, where
z + fJ2/2 + 8( _I)' [fJ2 /4 + zen - z)/nj1/2
w,(z, n, fJ) := (n + fJ)2
This follows from solving the inequality
for Pij'
For j = 0, these results yield the point estimate 1/(1 - PiO) and interval
estimate [1/[1 - WI (NiO , N i , <1>-1(1- 8/2»], 1/[1 - W2(NiO , Ni, <1>-1(1 - 8/2»1] for rio
Table 10.10 displays these for 8 = .01. The variation inherent in the mean estimate is con-
sistent with that seen in the fli of Table 10.9. However, in this form we can more easily offer
a sensitivity analysis that exploits the method of sampling.
The most direct way to generate waste daily in the simulation of Section 1.5 is to sample
the number of drums Di for Campus i from the empirical distribution tpiO, ... , Pi4} via
Algorithm ITR in Section 8.1.3. For five ordinates, this algorithm compares favorably in
computing time with the cutpoint method in Algorithm CM in Section 8.2 and the alias
method in Algorithm ALIAS in Section 8.4, whose superiority materializes for larger numbers
of ordinates. However, this direct generating approach has a limitation. For example, if one
were to generate waste daily in this way for Campus 1, then the mean number of days between
successive positive waste generations in the simulation would be I/O - PlO) = 227/34 =
6.676. That is, this approach generates zero drums on 5.676 successive days on average before
generating a positive number. This result follows from the observation that the number of
days between successive positive waste generations is 1 + Z, where Z has the geometric
distribution Qe(PlO), as in Section 8.19.
To improve computational efficiency, we resort to a procedure that skips the zeros. For
j = 1, ... , 4 and i = 1, ... , 4, let
I Pij
Pij = 1- PiO
= probability of generating j drums
given that at least one drum is generated
Let
Then on the day of the most recent positive waste generation on Campus i, Algorithm
WASTE samples fl Ti' schedules the next positive waste generation, and samples the number
of drums Di that are to be generated on that day.
ALGORITHM WASTE
Purpose: To schedule the next positive waste generation for Campus i and to
determine its number of drums.
506 CHAPTER 10. PREPARING THE INPUT
Given: AI
Pio an d {AI
qij:= AI
qi,j-l
A I
; ] = 1, ... ,4}.
+ Pij; qiO:= O'
Method:
Sample Z from ge(PiO).
I!!.:r:i +-- 1 + Z.
Schedule the next positive waste generation on day t' + Do t'i •
Sample U for U(O, 1).
j +-- 1
While U > %, j +-- j + 1.
Di +-- j.
Table 10.11 displays the relevant distributions along with Pio, PiO/O - pio), the mean
number of zero waste generations between successive positive generations, and the mean
number of comparisions in sampling Di := Pil + 2Pi2 + 3Pi3 + 4Pi4' Note the substan-
tiai mean numbers of days skipped with regard to zero-waste generation. Also note that
the relatively small mean numbers of comparisons are consequences of P;j ::: P;,j+! for
j = 1, ... , 3. When these orderings do not arise naturally in a problem, reordering the
probabilities so that comparisons proceed from largest to smallest always reduces the mean
number of comparisons.
Table 10.11 Waste generation probabilities (p;j := pij / (I - PiO); j = 1, ... ,4)
then N(t) has the Poisson distribution peAt). Suppose we simulate the times of arrivals for
a day starting at hour 10 (a.m.) and ending at hour 17 (5 p.m.). Let
to := 10,
tl := 11,
t2 := 16,
t3 := 17,
Al := 60/3.050 = hourly arrival rate in peak interval(tl' t2],
A2 := 60/3.528 = hourly arrival rate in off-peak intervals (to , tIl U (t2, t31.
Then
where
A(t):= itto
A(s)ds, to < t ~ t3, (10.16)
r
and
to < t ~ tlo
A(t):= A2, tl < t ~ t2, (10.17)
AI, t2 < t ~ t3.
Here interarrival times form a nonhomogeneous Poisson process with instantaneous intensity
function {A(t)} that varies with time of day.
A special case of this nonhomogeneous Poisson process is the homogeneous Poisson
process, wherein {A(t)} is invariant with respect to t so that A(t) ex: (t - to). More generally,
{N (t ), t 2: O} is said to be a nonhomogeneous Poisson process with instantaneous intensity
function {A(t), t 2: O} iffor each h 2: 0 (e.g., Ross, 1980 p. 187)
i. N(O) = 0,
508 CHAPTER 10. PREPARING THE INPUT
Since {A(t)} in (10.17) is right continuous, property iv can be satisfied in the present setting.
The relationship between homogeneous and nonhomogeneous Poisson processes pro-
vides a means for sampling interarrival times for the latter, provided that {A(t)} is finite.
Algorithm NHPP generates samples from the homogeneous Poisson process P(A max t),
where Amax ~ A(t) Vt, and thins them by an acceptance-rejection test. The acceptance
probability in an arbitrarily selected trial is no less than AdAJ = .9354. More generally, if
Amax is considerably larger than most values of {A(t)}, then thinning is not a particularly
efficient sampling procedure.
ALGORITHM NHPP
In addition to the photocopying problem in Section 1.4, the library requested a simu-
lation study to evaluate the benefits of alternative reshelving policies for books and journals
that patrons leave on study tables and reshelving carts. Several times daily a student employee
makes tours of these areas and collects the materials for eventual reshelving. Hereafter, we
use the generic term "book" to mean journal as well as book.
The simulation called for a means of sampling the number of books that are cleared
from tables and reshelving carts each time a clearing tour occurs. For this study, a day began
at hour 7.75 (7:45 a.m.) and ended at hour 22 (10 p.m.). Table 10.12 shows data collected
on 31 tours. It reveals that tours did not occur on a fixed time schedule. This variation in
clearing times created a challenge for the simulationist to provide a generating procedure.
10.14. NONHOMOGENEOUS POISSON PROCESSES 509
~(t) = ~~=1 [B;/(ti - Si)] [(Si,t;] (t), 7.75 < t ~ 22, (10.18)
Li=1 [(Si,t'] (t)
where Bi , Si, and ti are as defined in Table 10.12 for i = 1, ... , k. Figure 10.9 shows
{A(t), 7.75 < t ~ 22}, which shows lowerintensityin the earlymorningpriorto hour 9 and
in the evening after hour 17.
Let ro := 7.75 and r1 := 22. To devise a procedure for sampling B, the number of
books cleared on a tour, from P (A (r )) efficiently for
A(r) := l'
'0
A(t)dt,
where {A(t)} is defined in expression (I0.18), we first partition the hours (7.75, 22] into 57
quarter-hour intervals of which the jth corresponds to (ro + .25{j - I), ro + .25j]. Then
40
11
35
30
r--- niL-
..---J
25
A.(t) 20 - L...--
~
L, Il
15 '---' L-
10
o
7 8 9 10 11 12 13 14 15 18 17 18 19 20 21 22
t (hours)
By contrast with the need to generate arrival times in the photocopying problem in Sec-
tion 10.14, the clearing problem provides a daily sequence of clearing times and requires the
simulationist to sample B, the number of books cleared, at time r from P(A(r) - A(t)),
where t < r denote the times of two successive clearings on a single day. Algorithm CLEAR
does this by retaining Aold := A (t) from the previous sampling.
ALGORITHM CLEAR
Likewise, for the example in Section 10.12.1, if simulated time consists of a sequence of seven-
hour days beginning at hour 10 and ending at hour 17, then for all t :::: 10 its instantaneous
intensity function satisfies
Note thatthe assignment (10.17) satisfies expression (10.22), whereas the assignment (10.18)
satisfies expression (10.21).
The forms of these intensity functions suggest another more formal method of esti-
mating {A(t)} that exploits their inherent periodicities. In this alternative, {A(t)} assumes
the form
p
h(t, p, 0) := ao + Lak sin(bkt + Ck), (10.24)
k=l
and
TO = 7.75,
bj = 2rrj/14.25, j = 1, . .. ,p,
512 CHAPTER 10. PREPARING THE INPUT
where b I is the daily fundamental frequency of book clearing intensity and b2 , •.• , bp are
its first p - 1 harmonics. For the photocopying problem,
'fo = 10,
b j = 2rrj/7, j = 1, ... ,p.
In both cases the relevant p is unknown and needs to be estimated along with aI, ... , a p
and CI, ... , cpo
The form (10.23) guarantees thatA(t) is nonnegative for allt ::: 'fo. Moreover, it allows
us to cast parameter estimation in terms of the likelihood function. Recall that N (t) denotes
the number of arrivals or more generically, the number of events in (0, tl. If N(t) is from
P(A(t», then
j = 0,1, ... ,
where
Therefore,
(10.25)
= probability that exactly one event occurs in(tI' t2)'
Suppose {A(t)} has theform (10.23) and that Zn = {Zo := to < ZI < ... < Zn} denotes a
sample sequence of times at which n successive events occur. Then expression (10.25) implies
the likelihood function
when b l , ... , b p are known. If they are not, then the additional equations
8 In L(p, 8, Zn)
- - - ' - - - - = 0, j = 1, ... ,p,
8b j
apply as well.
The form (10.26) severely impedes a direct approach to computing the m.l.e. Kuhl
et al. (1997) describe an iterative technique that overcomes the impediment by exploiting
approximations that lead to useful initial values for iterative estimation. Public-domain
software that implements their procedures is available at http://www.ie.ncsu.edu/jwilson/
page3.html. It also allows for estimation of{). (t ) } when it contains an exponential polynomial
trend. For an alternative approach to estimating {).(t)}, see Kao and Chang (1988).
• Interarrival times are frequently modeled as i.i.d. random variables. When time of
day, week, month, or year affects the arrival rate, this assumption is inappropriate.
The concept of a nonhomogeneous Poisson process provides a means of accounting
for this dependence in generating samples.
10.16 REFERENCES
AbouRizk, S.M., D.W. Halpin, and J.R Wilson (1994). Fitting Beta distributions based on
sample data, Journal of Construction Engineering and Management, 120, 288-305.
Ahrens, J.H., and K.D. Kohrt (1981). Computer methods for efficient sampling from largely
arbitrary statistical distributions, Computing, 26,19-31.
Beckman, RJ., and G.L. Tietjen (1978). Maximum likelihood estimation for the Beta
distribution, J. Statist. Comput. Simul., 7, 253-258.
Brockwell, P.J., and RA. Davis (1991). Time Series: Theory and Methods, second edition,
Springer-Verlag, New York.
Conover, w.J. (1999). Practical Nonparametric Statistics, third edition, Wiley, New York.
Fielitz, B.D., and B.L. Myers (1975). Estimation of parameters in the Beta distribution,
Decision Sciences, 6, 1-13.
Fishman, G.S. (1973). Concepts and Methods in Discrete Event Digital Simulation, Wiley, New
York.
Gnanadesikan, R, RS. Pinkham, and L.P. Hughes (1967). Maximum likelihood estimation
of the parameters of the Beta distribution from smallest order Statistics, Technometrics,
9,607-620.
Gnedenko, B.Y., and LN. Kovalenko (1989). Introduction to Queueing Theory, Birkhiiuser,
Boston.
Grigelionis, B.L (1962). Accuracy of approximation of a superposition of renewal processes
by a Poisson process, Litovskit Mathemalicheskit Sbornik, II, (2), 135-143.
K611erstrom, J. (1974). Heavy traffic theory for queues with several servers. I, J. Appl. Prob.,
11, 544-552.
Kuhl, M.E., J.R. Wilson, and M.A. Johnson (1997). Estimating and simulating Poisson
processes having trends or multiple periodicities, lIE Transactions, 29, 201-211.
Kulkarni, V.G. (1995). Modeling and Analysis of Stochastic Systems, Chapman and Hall,
London.
Law, A.M., and w.D. Kelton (1991). Simulation Modeling and Analysis, McGraw-Hill, New
York.
Lewis, P.A.W., and J. Shedler (1979). Simulation of nonhomogeneous Poisson process by
thinning, Nav. Res. Logist. Quart., 26, 403-413.
Nelson, B.L., and M. Yamnitsky (1998). Input modeling tools for complex problems, 1998
Winter Simulation Conference Proceedings, D.J. Medeiros, E.F. Watson, J.S. Carson,
and M.S. Manivannan, eds., Association for Computing Machinery, New York.AU :see
editors note
Ross, S.M. (1980). Introduction to Probability Models, Academic Press, New York.
Wagner, M.A., and J.R. Wilson (1996). Using univariate Bezier distributions to model
simulation input processes, lIE Transactions, 28, 699-711.
Zacks, S. (1971). The Theory of Statistical Inference, Wiley, New York.
ApPENDIX
More on the
Batch-Means
Method
Procedure FNB describes the principal steps for implementing the FNB rule in Section 6.6.4.
tj +- 2tj_l (= 11bj )
Collect observations X t /(tHl, ••• , Xt
ComputeXt
Output:
Xt is the point estimate of /1-.
C[(8) +- [X t ± t'1_1 (1 - 81 2 )Jb J (I) Wlbl(tJt 1is the approximating
100 x (1 - 8) percent confidence interval for /1-.
{b j Wlb j; j = 1, ... , J (t)} is the sequence of successive estimates of a~.
As an example, consider again the MIMII simulation queueing model with v .90 =
interarrival rate and unit service rate. The simulation began in the steady state, used II = 7
and b 1 = 5, and terminated when customer t = 107 entered service. Figure A.I shows
the LABATCH.2-generated sequences {A =
Jb j Wllb j ; j =
1, ... , J(t)}. The graphs
reveal a tendency for Vlj initially to increase with j and eventually to fluctuate around their
respective true aoo's.
Figures A.la and A.2b reveal an additional property. After dissipating systematic vari-
ance error, the size of fluctuations remains relatively constant in both graphs, in contrast to
the behavior in Figures 6.7 a and 6.7b. The origins of this constancy are not hard to find.
For {l(tj) = II, j :::: I}, EVII(t) -+ a~ as t -+ 00, but
2a~(l1 + 1) 2
var VrJ(t) -+ (11 _ 2)2 + 0(11/ 1 ) as t -+ 00, (A.I)
implying that Vr does not converge in mean square and thus is not a consistent estimator
of a~. However, under relatively weak. conditions on {X;}, the limit (6.53) holds, implying
that CII (8) remains an asymptotically valid confidence interval for /1-.
Although this settles the issue of validity, it does not address the issue of statistical
efficiency, which, in the present case, can be measured by2t'1,_, (1- 81 2 )JVII (t) It, the width
of the confidence interval for /1-. Expanding V//2 in Taylor series about a oo leads to
(A.2)
as t -+ 00. (A.3)
350
300 -
250 -
!if
o:!
t .
200-
~
IT 150 -
til .
100-
50-
0
0 5 10 15 20
Interim review J
1.75 -
1.5 -
!if 1.25 :
::!
~t: 1~
IT
til
0.75 -
0.5 -
0.25 -
0
0 5 10 15 20
Interim review J
(AA)
revealing that the expected interval width based on a strongly consistent estimator of a~
never exceeds the mean interval width based on the FNB rule. In this regard, statistical
efficiency favors a strongly consistent estimator.
Let
Z ._ X t - f..i (A.S)
Ib .- -y'-=W=lb=I=Z
and let Fib denote the distribution function (d.f.) of Zib with Edgeworth expansion
where cI> denotes the standard normal d.f. and Ki (Zlb), the i th cumulant of Zlb. If K; denotes
the ith cumulant of a random variable Y, say for i = 1, ... ,4, then KI = EY, K2 =
E(Y - Kd 2, K3 = E(Y - KI)3, and K4 = E(Y - Kl)4 - 3Ki-
IfEIX I - f..i1 20 < 00 and {X;} is ¢-mixing with ¢i = 0(i-l3), then (Chien 1989, p.
46)
Actually, Chien gives slightly weaker conditions for the first three cumulants.
As an immediate consequence,
revealing thatl(t) ()( t i / 2 and bet) ()( t i / 2 induce the fastest convergence of the true coverage
rate to the specified theoretical coverage rate 1 - 8. In this case, Vt has 0(1/t i / 2 ) systematic
error and 0(1/ti/2) random error. To exploit these convergence properties, the SQRT rule
defines {(l j, b j); j :::: I} as in expressions (6.55) and (6.56).
Procedure SQRT describes the principal steps in employing the SQRT rule.
350
,- ~
.
\
\
I \
300 - I
I
•
I
.
2.5 0 -
iif \
d 200- I • ~ ~ \ ,.
--------------------------------~-----------~---~-----~---~----
t
E' '
" ../ \ I
•
.,. 150-
<IJ
100 -
,, ~
•
. . . _.,,
' ..~
.. ' /
SO- I
I
I
~ .
0
0 5 10 15 20
Interim review J
Figure A.2 LABATCH.2 estimation of a oo for waiting time in queue (FNB rule: light
dashed line, SQRT rule: solid line, a oo = 189.3: heavy dashed line)
comes close to a oo after review 15. This contrast in behavior reflects the O{ l/tj) systematic
variance error dissipation rate for the FNB rule as compared to the 0{I/tJ I2) rate for the
SQRT rule. However, sampling fluctuations for the FNB sequence are 0(1), in contrast to
0{I/tJ I2) for the SQRT rule. We conclude that the FNB rule offers a benefit initially, but
the SQRT rule ultimately offers an advantage. The next section describes batching rules that
exploit the benefits of both rules.
too burdensome for some users, LABATCH.2 merely requires that t be specified and then
chooses II and b l to maximize t'(t).
Let l3(t) denote the subset of l3 that maximizes t'(t). LABATCH.2 chooses (II, b l )
to be the element of l3(t) that maximizes J(t), the number of interim reviews. As the
following example shows, this algorithm reduces the number of elements in l3 that need to
be considered in maximizing t'(t). Suppose that (ai, a2) and (a3, a4) E l3 maximize t'(t)
and that for some integer ex :::: 1, alaz = 2aa3a4. Then clearly, the choice (ai, az) induces
A.3. C H 005 I N G t I II I AND b1 (S E C T ION 6.6.6) 523
more reviews than (a3, a4). As a consequence of this example, LABATCH.2 considers only
the underlined 2-tuples in B in Table 6.3 in maximizing t'(t). As illustration, t'(107)
9,175,040 is maximal for each 2-tuple in
B(107) = {(7, 5), (14, 5), (25,5), (10, 7), (20, 7), (14, 10), (28, 10), (20,14), (28, 20)}.
but (7, 5) allows for the maximal number of reviews, J(107) = 19.
For 10 :s t :s 107 , Table A.l shows the smallest proportion of observations used
for WLJII)BJ(I) when t'(t) is maximized subject to alternative upper bounds on II. Recall that
11 :s 100 implies optimization over all entries in B. In this case, choosingt ::: 500 implies that
no less than 89.8 percent of the data is used for computing WLlltl BJII)' Alternatively, imposing
the constraint 11 :s 30 in choosing (11, bd to maximize t'(t) reduces this percentage to 88.9.
We recommend either of these options for t ::: 500.
We now reconcile
Xt - fL (A.7)
t
A := JBJ(t) WLJ(t)BJIt)/t'
whose properties establish the basis for the confidence interval (6.48), with l(t)
LJ(t), b(t) = BJ(t) and Wl(t)b(t) = Vt'(t)/ BJ(t) and
Xt'(I) - fL
(A.8)
G I := JBJ(t) WLJ(I)BJltJt'(t) '
whose properties are described in Theorem 6.6 for j = J(t). Recall that t'(t) = tJ(t) =
LJ(t)BJ(t). Whereas At uses all t observations to estimate fL, G t uses only the firstt' (t) obser-
vations.However, both use BJ(t) WLJlt)BJ(tl asanestimateof(J'~. Since (Xt'(t) -fL)/ J(J'~/t'(t)
and (X t - fL)/J(J'~/t are both asymptotically N (0,1), by ASA, and since BLJ(t) WLJ(t)BJ(t)
is strongly consistent, it appears that a modification of the proof of Theorem 1 in Yarberry
(1993) can yield asymptotic normality for At as well. With regard to statistical efficiency, At
reduces interval width bya factor of 1 - Jt'(t)/t :s 1- J.889 = .0571 when (llbl) E B(t)
for t ::: 500.
524 A P PEN D I X. M 0 REO NTH E BAT C H - MEA N 5 MET HOD
A.4 REFERENCES
Chien, C.H. (1989). Small-sample theory for steady state confidence intervals, Technical
Report -37, Department of Operations Research, Stanford University.
Yarberry, L.S. (1993). Incorporating a dynamic batch size selection mechanism in a fixed-
sample-size batch means procedure, unpublished Ph.D. dissertation, Department of
Operations Research, University of North Carolina, Chapel Hill.
Author Index
Cornish, E.A., 345, 412 Kachitvichyanukul, Y., 381, 384, 388, 413,
414
Dahl, O.J., 35 Kao, E.P.C., 513, 515
Daley, D., 38, 69 Karlin, A.R., 412
Damerdji, H., 252, 292 Karr, H.W., 104, 174
Davis, R.A., 487,514 Kelton, W.D., 100, 148, 149, 174,254,268,
Derflinger, G., 328,413,427,450 293,296,307,324,480,515
Devroye, L., 329, 330, 367, 381, 385, 412 Kendall, M.G., 324
Dieter, u., 341, 343, 352, 361, 362, 364, Kinderman, A.J., 352, 355, 402, 413
365,368,369,375,381,385,400, Kingston, J.H., 209, 217
411,412 Kiviat, P.J., 104, 174
Knuth, D., 186,217
Easton, M.C., 415 Kohrt, K.D., 462, 514
Evans, J.B., 203, 217 Kollerstrom, J., 182,217,465,466,515
Kotz, S., 413, 514
Feast, G.M., 369, 371, 372, 374, 412 Kovalenko, LN., 465, 514
Feller, W., 412 Kronmal, R.A., 343, 413
Fielitz, B.D., 480 Kuhl, M.E., 513, 515
Fieller, E.C., 282, 292 Kulkarni, Y.G., 413,515
Fisher, R.A., 345, 412 Kumaran, K., 60
Fishman, G.S., 40, 69,148,159,174,259,
265,268,292,296,324,334,336, Lal, R., 369, 414
343,378,385,399,412,413,450 Lamb, J.D., 67, 69
LaVal, D.K., 69
Gerontidis, 1., 413 Law, A.M., 148, 174,293,296,307,324,
Gibson, R., 163, 173 480,515
Gnanadesikan, R., 480, 514 L'Ecuyer, P., 442, 443, 444, 445, 446, 450
Gnedenko, B.V., 465,514 Lewis, P.A.w., 515
Goldsman, D., 250, 292, 293, 324 Lurie, D., 413
Gordon, G., 58, 69,149,174
Grigelionis, B.I., 465, 514 Ma, X., 20, 35
MacLaren, M.D., 339, 361,413,414
Halpin, D.W., 514 Markowitz, H.M., 104, 174
Hartley, H.O., 413 Marsaglia, G., 358, 364, 369, 413, 414
Hastings, c., Jr., 382, 413 Marsaglia, J., 414
Hausner, B., 104, 174 Matejcik, EJ., 296, 324, 325, 404
Henriksen, J.O., 100, 174,207,209,214, McCormack, W.M., 198, 199,209,217
217 Meketon, M.S., 251, 293
Hoeffding, W., 413 Melamed, B., 292
Hopcroft, J.E., 410 Miller, K.w., 427, 450
Hormann, W., 328, 410, 413, 427, 450 Minh, D.L., 369, 414
Huff, B., 35 Mitra, D., 60
Hughes, L.P., 514 Monahan, J.E, 352, 355, 402, 413
Moore, L.R., 334, 336, 412, 413, 450
Jannson, B., 424, 450 Moro, B., 331, 414
Johnson, M.A., 515 Muller, M.E., 364, 411
Johnson, N.L., 378, 413, 470, 474, 514 Myers, B.L., 480
Jones, D.W., 200, 210, 217 Myhraug, B., 35
IN D EX 527