|
Most simulations are
designed so they converge to what might
be called the "true solution"
of the model. But, because a simulation
can only be run for a finite amount of
time, this true solution can never be
known. This gives rise to two important
questions: What is the accuracy in the
results of a simulation's output? How
long should a simulation be run in order
to obtain a given accuracy? These questions
can be answered using confidence intervals
and run-length control algorithms.
Using an ad hoc technique
instead of the methods described in this
section can be dangerous as well as wasteful.
Running a simulation for too short an
amount of time will result in performance
statistics that are highly inaccurate.
Running a simulation for an unnecessarily
long amount of time wastes computing resources
and delays the completion of the simulation
study. Without some type of formal analysis,
the errors in simulation results cannot
be quantified.
A confidence
interval is a range of values in
which the true answer is believed to lie
with a high probability. The interval
can be specified in two equivalent ways,
either by specifying the midpoint of the
interval (which could be considered the
"best guess" for the true answer)
and the half-width of the interval, or
by specifying the lower and upper bounds
of the interval. CSIM reports the confidence
interval in both formats, as illustrated
below:
4.114119 +/- 0.296434
= [3.817684, 4.410553]
The probability that
the true answer lies within the interval
is called the confidence
level. Since a confidence level
of 100% would result in an infinitely
wide confidence interval, confidence levels
from 90% to 99% are most often used. Be
aware that there is always a small probability
(dictated by the confidence level) that
the true answer lies outside the confidence
interval.
Confidence intervals
can be automatically generated for the
mean values in any table, qtable, meter,
or box simply by calling one of the following
functions immediately after the statistics
object has been initialized.
Prototype:
void table::confidence(void)
Prototype:
void qtable::confidence(void)
Prototype:
void meter::confidence(void)
Prototype:
void box::time_confidence(void)
Prototype:
void box::number_confidence(void)
The technique used to
calculate confidence intervals is called
batch means
analysis. It is beyond the scope
of this manual to describe the mathematics
underlying this technique, but any good
simulation text should provide details.
If confidence intervals have been requested
for a table, qtable, meter, or box, the
statistics report will include a section
like the following.
Notice that confidence
intervals are calculated for three commonly
used confidence levels: 90%, 95%, and
98%. The confidence intervals are reported
in both of the formats described previously.
The relative error measures the accuracy
in the midpoint of the interval as an
estimate of the true answer. It is defined
to be the half-width divided by the lower
bound of the interval. Like any relative
error, its value suggests how many accurate
digits there are in the estimate.
The algorithm for computing
confidence intervals groups the observations
into fixed size batches and uses only
complete batches. For this reason, the
number of observations used in the calculation
of the confidence intervals may be slightly
less than the number of observations used
in computing the other performance statistics.
For example, in the above report 50,000
observations were used to calculate the
confidence intervals. The part of the
report not shown may give the mean, variance,
standard deviation, etc.
based on 50,472 observations.
The algorithm also requires a minimum
number of observations for its results
to be valid. This minimum number cannot
be known before running the simulation
because it depends on the amount of correlation
found in the statistic. If a report is
produced before sufficient observations
have been obtained, the message
> insufficient
observations to compute confidence intervals
will appear in place
of the confidence intervals. To obtain
confidence intervals, run the simulation
longer or use the run length control algorithm.
All values calculated
by the confidence interval algorithm can
be retrieved during the execution of a
model or upon its completion.
| Prototype: |
Functional
value: |
| long table::batch_size() |
size of batch |
| long table::batch_count()
|
number of batches |
| double table::conf_mean() |
midpoint of interval |
| double table::conf_halfwidth(lv) |
half-width of interval |
| double table::conf_lower(lv) |
lower bound of
interval |
| double table::conf_upper(lv) |
upper bound of
interval |
| double table::conf_accuracy(lv) |
accuracy achieved |
| Prototype:
|
Functional
value: |
| long qtable::batch_size |
size of batch |
| long qtable::batch_count |
number of batches |
| double qtable::conf_mean |
midpoint of interval |
| double qtable::conf_halfwidth
|
half-width of interval |
| double qtable::conf_lower |
lower bound of
interval |
| double qtable::conf_upper |
upper bound of
interval |
| double qtable::conf_accuracy |
accuracy achieved |
If confidence intervals
have not been requested or if there have
not been sufficient observations to calculate
confidence intervals, all of the above
functions return zero values.
To inspect confidence
interval information for meters and boxes,
pass to the appropriate function listed
above a pointer returned by one of the
following functions: meter::ip_table,
box::time_table,
or box::number_qtable.
If the reported confidence
intervals show that the needed accuracy
has not been achieved, a simulation could
be run again for a longer amount of time.
This has two disadvantages: repeating
part of the simulation is wasteful, and
it may not be clear how much longer to
run the simulation the second time.
A better method is to
use the run length control algorithm that
is built into CSIM. This algorithm monitors
the confidence interval as it narrows
and automatically terminates the simulation
when the desired accuracy has been achieved.
To use run length control,
choose a performance measure that will
be used to decide when the simulation
should terminate. Instrument the model
to gather statistics on this performance
measure using a table, qtable, meter,
or box. Immediately after the statistics
gathering object has been initialized,
call the appropriate function below.
Prototype:
void table::run_length(double
accuracy,
double conf_level, double max_time)
Dynamic Example:
t->run_length
(0.01, 0.95, 10000.0);
Prototype:
void qtable::run_length(double
accuracy,
double conf_level, double max_time)
Prototype:
void meter::run_length(double
accuracy,
double conf_level, double max_time)
Prototype:
void box::time_run_length(double
accuracy,
double conf_level, double max_time)
Prototype:
void box::number_run_length(double
accuracy, double conf_level, double
max_time)
The accuracy parameter
specifies the maximum relative error that
will be allowed in the mean value of this
performance measure. A value of 0.1 is
usually used to request one digit of accuracy,
0.01 is used to request two digits of
accuracy, and so forth. The conf_level
parameter is the confidence level and
usually has a value between 0.90 and 0.99.
The max_time
parameter places an upper bound on how
long the simulation will run. If the specified
accuracy cannot be achieved within this
time, the simulation will terminate and
a warning message will appear in the report.
In the main CSIM process, place the following
call to the wait
function.
converged.wait();
"Converged"
is a built-in event that does not need
to be declared or initialized. This event
is set when the run length control algorithm
determines that the requested accuracy
has been achieved or when the maximum
time has passed.
If run length control
has been enabled, the statistics report
will include a section like the following.
| results
of run length control using confidence
intervals |
| |
| cpu time limit |
10.0 |
accuracy requested |
0.005000 |
| cpu time used |
1.8 |
accuracy achieved |
0.005000 |
|
95.0% confidence
interval: 0.998735 +/- 0.004969
= [0.993767, 1.003704]
|
The
confidence interval is reported in both
formats for the confidence level that
was specified. If the requested accuracy
was not achieved or if there were not
enough observations to calculate confidence
intervals, a warning message will appear
in the report.
The
mechanics for running a simulation until
multiple performance measures have been
obtained to desired accuracy are simple.
Call the appropriate run length function
for several statistics gathering objects
and then wait on the "converged"
event as many times as there are statistics
to converge. However, there are some subtleties
in the theory underlying this procedure.
Persons interested in this topic should
read section 9.7 of Simulation
Modeling and Analysis
by Law and Kelton.
Confidence
intervals attempt to bound the errors
in performance statistics caused by running
a simulation for a finite amount of time.
They in no way measure the errors caused
by the model being an unfaithful representation
of the actual system.
All
known techniques for computing confidence
intervals are heuristics. Detecting and
removing correlation from performance
data is a mathematically difficult problem.
Confidence intervals should always be
considered to be estimates.
In
spite of these limitations, it is our
belief that confidence intervals and run
length control play an essential role
in any simulation study. Simply running
a simulation for a "long time"
and hoping that the performance measures
will be highly accurate is an unprofessional
and dangerous approach.
Next
Section
|