SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
umontreal.ssj.simexp.SimExp Class Referenceabstract

Represents a framework for performing experiments using simulation. More...

Inheritance diagram for umontreal.ssj.simexp.SimExp:
umontreal.ssj.simexp.BatchMeansSim umontreal.ssj.simexp.RepSim

Public Member Functions

final Simulator simulator ()
 Returns the simulator linked to this experiment object.
final void setSimulator (Simulator sim)
 Sets the simulator associated with this experiment to sim.
boolean isSimulating ()
 Determines if the simulation is in progress.
abstract void simulate ()
 Performs an experiment whose logic depends on the used subclass.

Static Public Member Functions

static int getRequiredNewObservations (StatProbe[] a, double targetError, double level)
 Returns the approximate number of additional observations required to reach a relative error smaller than or equal to targetError for each tally in the array a when confidence intervals are computed with confidence level level.
static int getRequiredNewObservations (Iterable<? extends StatProbe > it, double targetError, double level)
 Returns the approximate number of additional observations required to reach a relative error smaller than or equal to targetError for each tally enumerated by it when confidence intervals are computed with confidence level level.
static int getRequiredNewObservations (StatProbe probe, double targetError, double level)
 Calls getRequiredNewObservations(double,double,int,double) with the average, confidence interval radius, and number of observations given by the statistical probe probe.
static int getRequiredNewObservationsTally (Tally ta, double targetError, double level)
 Calls getRequiredNewObservations(double,double,int,double) with the average, confidence interval radius, and number of observations given by the tally ta.
static int getRequiredNewObservationsTally (FunctionOfMultipleMeansTally fmmt, double targetError, double level)
 Calls getRequiredNewObservations(double,double,int,double) with the average, confidence interval radius, and number of observations given by the function of multiple means fmmt.
static int getRequiredNewObservations (double center, double radius, int numberObs, double targetError)
 Returns the approximate number of additional observations needed for the point estimator \(\bar{X}_n=\) center, computed using.

Protected Member Functions

 SimExp ()
 Constructs a new object for performing experiments using the default simulator returned by Simulator.getDefaultSimulator().
 SimExp (Simulator sim)
 Constructs a new object performing experiments using the given simulator sim.

Protected Attributes

boolean simulating = false
 Determines if the simulation is in progress.

Detailed Description

Represents a framework for performing experiments using simulation.

This class defines an abstract simulate method that should implement the simulation logic. It also provides utility methods to estimate the required number of additional observations that would be necessary for an estimator to reach a given precision, for sequential sampling.

This class is the base class of BatchMeansSim and RepSim implementing the logic for a simulation on infinite and finite horizon, respectively.

Definition at line 44 of file SimExp.java.

Constructor & Destructor Documentation

◆ SimExp() [1/2]

umontreal.ssj.simexp.SimExp.SimExp ( )
protected

Constructs a new object for performing experiments using the default simulator returned by Simulator.getDefaultSimulator().

Definition at line 56 of file SimExp.java.

◆ SimExp() [2/2]

umontreal.ssj.simexp.SimExp.SimExp ( Simulator sim)
protected

Constructs a new object performing experiments using the given simulator sim.

Parameters
simthe simulator attached to this object.

Definition at line 66 of file SimExp.java.

Member Function Documentation

◆ getRequiredNewObservations() [1/4]

int umontreal.ssj.simexp.SimExp.getRequiredNewObservations ( double center,
double radius,
int numberObs,
double targetError )
static

Returns the approximate number of additional observations needed for the point estimator \(\bar{X}_n=\) center, computed using.

\(n=\) numberObs observations and with a confidence interval having radius \(\delta_n/\sqrt{n}=\) radius, to have a relative error less than or equal to \(\epsilon=\) targetError. It is assumed that \(\bar{X}_n\) is an estimator of a mean \(\mu\), \(n\) is the number of observations numberObs, and that \(\delta_n/\sqrt{n}\to0\) when \(n\to\infty\).

                        If @f$n@f$ is less than 1, this method returns 0.
                        Otherwise, the relative error given
                        by @f$\delta_n/|\sqrt{n}\bar{X}_n|@f$ should be
                        smaller than or equal to @f$\epsilon@f$. If the
                        inequality is true, this returns 0. Otherwise,
                        the minimal @f$n^*@f$ for which this inequality
                        holds is approximated as follows. The target
                        radius is given by @f$\delta^*=\epsilon|\mu|@f$,
                        which is approximated
                        by @f$\epsilon|\bar{X}_n|<\delta_n/\sqrt{n}@f$.
                        The method must select @f$n^*@f$ for
                        which @f$\delta_{n^*}/\sqrt{n^*}\le\delta^*@f$,
                        which will be approximately true
                        if @f$\delta_{n^*}/\sqrt{n^*}\le\epsilon|\bar{X}_n|@f$.
                        Therefore, @f[
                        n^*\ge(\delta_{n^*}/(\epsilon|\bar{X}_n|))^2\approx(\delta_n/(\epsilon|\bar{X}_n|))^2. @f]
                        The method returns

\(\mathrm{round}((\delta_n\sqrt{n}/(\epsilon|\bar{X}_n|))^2)-n\) where \(\mathrm{round}(\cdot)\) rounds its argument to the nearest integer.

Parameters
centerthe value of the point estimator.
radiusthe radius of the confidence interval.
numberObsthe number of observations.
targetErrorthe target relative error.
Returns
an estimate of the required number of additional observations to reach the precision.
Exceptions
IllegalArgumentExceptionif `radius` or `targetError` are negative.

Definition at line 286 of file SimExp.java.

◆ getRequiredNewObservations() [2/4]

int umontreal.ssj.simexp.SimExp.getRequiredNewObservations ( Iterable<? extends StatProbe > it,
double targetError,
double level )
static

Returns the approximate number of additional observations required to reach a relative error smaller than or equal to targetError for each tally enumerated by it when confidence intervals are computed with confidence level level.

For each statistical collector returned by the iterator obtained from it, a confidence interval is computed independently of the other collectors, and an error check is performed by getRequiredNewObservations(StatProbe,double,double) to determine the required number of additional observations. The method returns the maximal number of required observations.

Parameters
itthe iterable used to enumerate probes.
targetErrorthe target relative error.
levelthe desired probability that, for a given statistical collector, the (random) confidence interval covers the true mean (a constant).
Returns
an estimate of the required number of additional observations to reach the precision.

Definition at line 163 of file SimExp.java.

◆ getRequiredNewObservations() [3/4]

int umontreal.ssj.simexp.SimExp.getRequiredNewObservations ( StatProbe probe,
double targetError,
double level )
static

Calls getRequiredNewObservations(double,double,int,double) with the average, confidence interval radius, and number of observations given by the statistical probe probe.

This method always returns 0 if the probe is not a tally. For a umontreal.ssj.stat.Tally, the confidence interval is computed using umontreal.ssj.stat.Tally.confidenceIntervalStudent(double,double[]). For a umontreal.ssj.stat.FunctionOfMultipleMeansTally, it is computed using umontreal.ssj.stat.FunctionOfMultipleMeansTally.confidenceIntervalDelta(double,double[]).

Parameters
probethe statistical probe being checked.
targetErrorthe target relative error.
levelthe desired probability that the (random) confidence interval covers the true mean (a constant).
Returns
the number of required additional observations.

Definition at line 189 of file SimExp.java.

◆ getRequiredNewObservations() [4/4]

int umontreal.ssj.simexp.SimExp.getRequiredNewObservations ( StatProbe[] a,
double targetError,
double level )
static

Returns the approximate number of additional observations required to reach a relative error smaller than or equal to targetError for each tally in the array a when confidence intervals are computed with confidence level level.

For each statistical collector in the given array, a confidence interval is computed independently of the other collectors, and an error check is performed by getRequiredNewObservations(StatProbe,double,double) to determine the required number of additional observations. The method returns the maximal number of required observations.

Parameters
athe array of probes.
targetErrorthe target relative error.
levelthe desired probability that, for a given statistical collector, the (random) confidence interval covers the true mean (a constant).
Returns
an estimate of the required number of additional observations to reach the precision.

Definition at line 134 of file SimExp.java.

◆ getRequiredNewObservationsTally() [1/2]

int umontreal.ssj.simexp.SimExp.getRequiredNewObservationsTally ( FunctionOfMultipleMeansTally fmmt,
double targetError,
double level )
static

Calls getRequiredNewObservations(double,double,int,double) with the average, confidence interval radius, and number of observations given by the function of multiple means fmmt.

The confidence interval is computed using umontreal.ssj.stat.FunctionOfMultipleMeansTally.confidenceIntervalDelta(double,double[]).

Parameters
fmmtthe function of multiple means being checked.
targetErrorthe target relative error.
levelthe desired probability that the (random) confidence interval covers the true mean (a constant).
Returns
the number of required additional observations.

Definition at line 231 of file SimExp.java.

◆ getRequiredNewObservationsTally() [2/2]

int umontreal.ssj.simexp.SimExp.getRequiredNewObservationsTally ( Tally ta,
double targetError,
double level )
static

Calls getRequiredNewObservations(double,double,int,double) with the average, confidence interval radius, and number of observations given by the tally ta.

The confidence interval is computed using umontreal.ssj.stat.Tally.confidenceIntervalStudent(double,double[]).

Parameters
tathe tally being checked.
targetErrorthe target relative error.
levelthe desired probability that the (random) confidence interval covers the true mean (a constant).
Returns
the number of required additional observations.

Definition at line 210 of file SimExp.java.

◆ isSimulating()

boolean umontreal.ssj.simexp.SimExp.isSimulating ( )

Determines if the simulation is in progress.

Returns
true if and only if simulation is in progress.

Definition at line 100 of file SimExp.java.

◆ setSimulator()

final void umontreal.ssj.simexp.SimExp.setSimulator ( Simulator sim)

Sets the simulator associated with this experiment to sim.

This method should not be called while this object is simulating.

Parameters
simthe new simulator

Definition at line 87 of file SimExp.java.

◆ simulate()

abstract void umontreal.ssj.simexp.SimExp.simulate ( )
abstract

Performs an experiment whose logic depends on the used subclass.

Before starting the simulation, this method should set simulating to true, and reset it to false after the simulation is done. It is recommended to reset simulating to false inside a finally clause to prevent the indicator from remaining true in the case of error during simulation.

Exceptions
IllegalStateExceptionif simulating is `true` when calling this method.

Reimplemented in umontreal.ssj.simexp.BatchMeansSim, and umontreal.ssj.simexp.RepSim.

◆ simulator()

final Simulator umontreal.ssj.simexp.SimExp.simulator ( )

Returns the simulator linked to this experiment object.

Returns
the simulator linked to the experiment object

Definition at line 77 of file SimExp.java.

Member Data Documentation

◆ simulating

boolean umontreal.ssj.simexp.SimExp.simulating = false
protected

Determines if the simulation is in progress.

Definition at line 50 of file SimExp.java.


The documentation for this class was generated from the following file: