MCExperiment
Provides for the running of a monte-carlo experiment.
The simulation is performed in two loops: an outer loop called the macro replications and an inner loop called the micro replications. The user specifies a desired (half-width) error bound, an initial sample size (k), and a maximum sample size limit (M) for the macro replications. The initial sample size is used to generate a pilot sample from which an estimate of the number of samples needed to meet the absolute precision criteria. Let's call the estimated sample size, m. If m k, then an additional (m-k) samples will be taken or until the error criteria is met or the maximum number of samples M is reached. Thus, if m M, and the error criterion is not met during the macro replications a total of M observations will be observed. Thus, the total number of macro replications will not exceed M. If the error criteria is met before M is reached, the number of macro replications will be somewhere between k and M. The total number of macro replications can be found by using the statistic() method to get the macro replication statistics and using the count() method. Let's call the total number of macro replications executed, n. The reason that the simulation occurs in two loops is to make it more likely that the observed values for the macro replications are normally distributed because they will be the sample average across the micro replications. Thus, the theory for the stopping criteria and estimation of the number of needed samples will be more likely to be valid.
For each of the n, macro replications, a set of micro replications will be executed. Let r be the number of micro replications. The micro replications represent the evaluation of r observations of the Monte-Carlo evaluation.
Thus, the total number of observations will be n x r. The number of micro replications is controlled by the user via the microRepSampleSize property. There is no error criteria checking for the micro replications.
By default, the number of macro replications should be relatively small and the number of micro replications large. Specific settings will be problem dependent. The default initial sample size, k is 30, with a maximum number of macro replications of M = 10000. The default half-width error bound is 0.001. The default setting of the number of micro replications, r, is 100. Again, these are all adjustable by the user.
The user can check if the error criteria was met after the evaluation. If it is not met, the user can adjust the initial sample size, desired error, maximum sample size, or number of micro replications and run another evaluation.
The statistics associated with the estimate are readily available. The user may reset the underlying random number stream if a reproducible result is desired within the same execution frame.
By default, the underlying random number stream is not reset with each invocation of the runSimulation() method. The default confidence level is 95 percent.
Be aware that small desired absolute error may result in large execution times.
Implementors of subclasses of this abstract base class are responsible for implementing the abstract method, replication(int j). This method is responsible for computing a single evaluation of the simulation model.
Inheritors
Properties
the desired confidence level
the desired half-width bound for the experiment
the initial sample size for pilot simulation
the maximum number of samples permitted
the number of micro replications to perform
Indicates if initial results are printed
determines whether the reset stream option is on (true) or off (false)
Functions
See page 513 of Law & Kelton
Runs the rth replication for a sequence of replications r = 1, 2, ... , getMicroRepSampleSize()
The purpose of the initial sample is to estimate the variability and determine an approximate number of additional samples needed to meet the desired absolute error. This method must ensure or assumes that no previous sampling has occurred. All statistical accumulators should be reset when this is executed.
Runs numMacroReps macro replications of the micro replications. Does not check half-width or other stopping criteria. Uses the current setting of the number of micro replications per macro replication. Does not perform a pilot run to determine stopping criteria or number of samples to meet desired half-width. Requires 2 or more macro replications.