Professional Documents
Culture Documents
=
=
n
i
i
n
Y
n
1
1
lim
Goal: estimate a steady-state parameter
Simulation 8
Output Data Autocorrelation : Example
Fast food restaurant (McDonalds drive) with a
single drive-thru window
If one car must wait a long time because they joined the
end of a long queue, then it is likely that cars arriving
just before or just after this car will also experience
longer waits
Conversely, if a car arrives and the driver immediately
places an order, then it is likely that the next car
arriving will experience at most a short delay.
Cars arriving in close proximity to one another are
more likely to exhibit similar waiting times
Positively autocorrelated data
Simulation 9
Output analysis for steady-state simulation:
Problems
Estimating steady -state parameters when
part of the samples are taken while the
model has not yet reached the steady state
are not representative
How to determine the start of the steady
state?
Simulation cannot run forever
How to choose n to terminate simulation?
Achieve desired precision/confidence
interval in presence of output data
autocorrelation
Simulation 10
Outline
Motivation and Terminology
Recall: sampling distribution and mean
Confidence intervals for mean and quintiles
Estimators and Correlation
Terminating simulations
Non-terminating Simulations:Steady state
estimation
Transient Removal
Stopping Rules
Independent Replications, Batch means and
Regeneration methods
Simulation 11
Transient Removal
Difficult to define exactly what constitutes end of
transient state
Use heuristics:
Long runs
Proper initialization
Truncation
Initial data deletion
Moving average of replications
Batch means
Simulation 12
Long Runs
Use very long runs
Effects of transient state will be amortized
But wastes resources
And tough to choose how long is enough
Recommendation dont use long runs alone
Simulation 13
Proper Initialization
Start simulation in a state close to equilibrium
Put some customers into the queue of a queuing
system, e.g CPU scheduler may start with some jobs in
the queue
Determine starting conditions by previous
simulations or simple analysis
Difficult to identify state information that is close
to steady state yet not limiting the possible
different outcomes of a model
May result in decreased run length, but still may not
provide confidence that are in stable condition
Simulation 14
Truncation
Assume variability during
steady state is less than
during transient state
Variability measured in
terms of range
(min, max)
If a trajectory of range
stabilizes, then assume
stable state is achieved
Method:
Given n observations {x
1
,
x
2
, , x
n
}
ignore first k observations
Calculate (min,max) of
remaining n-k
Repeat for k = 1n
Stop when k+1-th
observation is neither min
nor max
(Example next)
Simulation 15
Truncation Example
Sequence: 1, 2, 3, 4, 5, 6,
7, 8, 9, 10, 11, 10, 9, 10,
11, 10, 9
Ignore first (k=1), range is
(2, 11) and 2
nd
observation
(k+1) is the min
Ignore second (k=2),
range is (3,11) and 3
rd
observation (k+1) is min
Finally, k=9 and range is
(9,11) and 10
th
observation is neither min
nor max
So, discard first 9
observations
Transient
Interval
Simulation 16
Initial Data Deletion (1 of 3)
Observation: in steady state, the average of
samples is not very sensitive to the deletion of
some observations
On the other hand, average over observation
changes when data from initial transient is
included or not
Problem: To protect against small random
fluctuations, each individual observation needs to
be smoothed
Simulation 17
Initial Data Deletion (2 of 3)
Given n replications m size each with x
ij
j-th observation of
i-th replication; i=1,2,,n ; j=1,2,,m, Note j varies
along time axis and i varies across replications
Get mean trajectory:
Get overall mean:
Set k=1. Assume transient state of k samples , delete first
k and repeat for remaining m-k
Compute relative change
Repeat with k from 1 to n-1. Plot. Relative change graph
will stabilize at knee. Choose k there and delete 1 through
k
=
ij j
x
n
x
1
=
j
x
m
x
1
+ =
=
m
k j
j k
x
k m
x
1
) (
1
x x x
k
/ ) (
Simulation 18
Initial Data Deletion (3 of 3)
x
ij
j
x
j
j
x
k
k
(
x
k
x
)
/
x
k
transient
interval
knee
n replications m size each Mean trajectory over n
k-samples transient state
Relative change
Simulation 19
Moving Average (Welchs Procedure)
1. Make n replications of the simulation (n>5)
each of length m observations (m large)
Let Y
ji
be the i-th observation from the j-th
replication (j=1,2,...,n; i=1,2,...,m)
2. Define the averaged output process
n Y Var Var
Y E E
Now
. ,...,m , /n, i Y
i
i
n
j
ji
/ ) ( ) Y (
) ( ) Y (
,
2 1 Y
i
i
1
i
=
=
= =
=
Simulation 20
Moving Average
3. To further smooth out the statistical
fluctuations calculate the moving average
4
1
1 2
1
1 2
) ( Y
1
1
i
m/ atisf ies w window w s where the
,...,w if i
i
Y
,...,m-w w if i
w
Y
w
i
) (i s
s i
w
w s
s i
s
=
+
+ =
+
=
=
+
=
+
Simulation 21
Moving Average
4. Plot the resulting process for i=1,2,...,m-w and
choose the length of the warm-up period to be
the value of i beyond which the sequence
appears to have converged
Simulation 22
Moving Average: Example
M/M/1 Queue (=0.5, =1, n=10, w=0)
Simulation 23
Moving Average: Example
M/M/1 Queue (=0.5, =1, n=10, w=10)
Simulation 24
Moving Average: Example
M/M/1 Queue (=0.5, =1, n=10, w=10)
Simulation 25
Moving Average: Example
M/M/1 Queue (=0.5, =1, n=10, w=20)
Simulation 26
Moving Average: Recommendations
Use as many samples m per replication as is
feasible
Choose window size w <= m/4
Make sure to use the smallest window size for
which the curve is sufficiently smooth
Larger windows over-aggregate the data, no real
information present any longer
Start with only n=5 or n=10 replications, with m
being large (the larger the better)
If good estimate for the transient period was not
found (curve stays to edgy even for k=n/4), add
another 5 or 10 replications and repeat
Simulation 27
Batch Means
Run for long time, N observations
Divide up into batches
m batches size n each so m = N/n
Compute batch mean
Compute variance of batch means as
function of batch size
Start with batch size n=1, then increase n
Plot variance versus size n
When variance starts decreasing, have
transient
R
e
s
p
o
n
s
e
s
Observation number
n 2n 3n 4n 5n
V
a
r
i
a
n
c
e
o
f
b
a
t
c
h
m
e
a
n
s
transient
interval
Batch size n
(Ignore)
i
x
mean overall X
X x
m
x Var
m
i
i
); (
) 1 (
1
) (
1
=
=
Simulation 28
Why does batch means method work?
Assume: actual length of transient period is T
While batch sizes are small, several batches will
come from the initial transient These batches have
different means than batches from the steady state
Many different batch means, resulting in a large
variance of the set of batch means
As batch size increases, fewer and fewer batches
come from the initial transient
These fewer batches will have a smaller and smaller
impact on the variance
Eventually, when batch size exceeds T, only one batch
from initial transient
Simulation 29
Outline
Motivation and Terminology
Recall: sampling distribution and mean
Confidence intervals for mean and quintiles
Estimators and Correlation
Terminating simulations
Non-terminating Simulations:Steady state
estimation
Transient Removal
Stopping Rules
Independent Replications, Batch means and
Regeneration methods
Simulation 30
When to stop?
Suppose the initial transient has been determined
Suppose an estimate for the steady-state mean of a
random process is to be computed
What rule to apply to stop a simulation?
Too short: results are highly variable (depending on
initial conditions like RNG seed)
Too long: waste of resources
Simulation 31
When to stop
Accuracy criteria: run simulation until confidence
interval for the mean is sufficiently narrow
Straightforward from sample mean and its
variance
However, formulas only apply for samples
consisting of independent observations
Observations in simulations are usually correlated,
hence not independent
Applying formulas for independent observations
to non-independent ones results in
underestimation of the sample mean variance
Simulation 32
When to stop
Problem Statement: Find procedures that properly
estimate the variance of an interdependent set of values
Similar to the transient removal problem
Two basic approaches possible
Fixed sample size:
Run a simulation of a fixed size
Construct a confidence interval from the resulting data
Sequential procedures
Increment the length of simulation run until a given quality criterion is
met
Quality criterion: (relative) length of confidence interval, absolute or
relative error
Often based on fixed-sample-size approaches
Simulation 33
Fixed sample size procedures
Multiple replications
Independent Replications
Single replication
Batch means
Regeneration
Simulation 34
Outline
Motivation and Terminology
Recall: sampling distribution and mean
Confidence intervals for mean and quintiles
Estimators and Correlation
Terminating simulations
Non-terminating Simulations:Steady state
estimation
Transient Removal
Stopping Rules
Independent Replications, Batch means and
Regeneration methods
Simulation 35
Independent Replications
Procedure to compute a point estimate and confidence
interval for steady-state mean
Similar to terminating case, but only take into account
observations after initial transient
Procedure
Perform n independent simulation runs of length m each m
much larger than initial transient k
For each replication, compute average of all observations
after initial transient
These averages are IID random variables, hence, usual point
estimates and confidence intervals can be computed
Using multiple independent replications eliminates the
problem of dependencies within a single simulation
Simulation 36
Independent Replications: Formally
n
X
X
n
i
i
n
=
=
1
n j
k m
X
X
m
k i
j i
j
... 2 , 1 ,
1
,
=
=
+ =
( )
1
1
2
2
=
n
X X
S
n
j
n j
n
n
S
t X
n
n n
2
, 1 o
=
N j n X X
j
n
i
j i j
j
... 2 , 1 ,
1
,
=
=
=
=
; 1
1
2 2
( ) ) (or
1 1 1
= = =
= =
N
j
j
N
j
j
N
j
j
n Y X N n Y X
N n
S
t X
Y
n o , 1
=
Simulation 47
Regeneration: Pros and Cons
Advantages
Removal of initial transients is not necessary
usually part of each regeneration cycle
Easy to understand and implement
Disadvantages
Cycles are often rather difficult to determine
In complex systems, regeneration points can be
very rare (many conditions have to be met
simultaneously)
Length is unknown in advance
Complicated checks can be necessary to test for
a regeneration point
Simulation 48
Comparison of Methods
1. Independent Replications
Makes multiple runs to estimate m; in each replication
observations during the warm-up period are lost and each
run should be long enough to obtain an accurate estimate
for m.
2. Batch means
Makes a single run to estimate m; key point is the choice
of the batch size to obtain uncorrelated batch means.
3. Regenerative Method
Makes a single run to estimate m. No warm-up period
needed if one starts at regeneration point and no problem
with correlated output; but the mean length of a
regenerative cycle may be very large