SSJ  3.3.1
Stochastic Simulation in Java
Public Member Functions | List of all members
TallyStore Class Reference

This class is a variant of Tally for which the individual observations are stored in a list implemented as a DoubleArrayList. More...

Inheritance diagram for TallyStore:
[legend]
Collaboration diagram for TallyStore:
[legend]

Public Member Functions

 TallyStore ()
 Constructs a new TallyStore statistical probe.
 
 TallyStore (String name)
 Constructs a new TallyStore statistical probe with name name. More...
 
 TallyStore (int capacity)
 Constructs a new TallyStore statistical probe with given initial capacity capacity for its associated array. More...
 
 TallyStore (String name, int capacity)
 Constructs a new TallyStore statistical probe with name name and given initial capacity capacity for its associated array. More...
 
 TallyStore (DoubleArrayList a)
 Constructs a new TallyStore statistical probe with given associated array. More...
 
void init ()
 
void add (double x)
 Adds one observation x to this probe.
 
double [] getArray ()
 Returns the observations stored in this probe. More...
 
DoubleArrayList getDoubleArrayList ()
 Returns the DoubleArrayList object that contains the observations for this probe. More...
 
void quickSort ()
 Sorts the elements of this probe using the quicksort from Colt.
 
double covariance (TallyStore t2)
 Returns the sample covariance of the observations contained in this tally, and the other tally t2. More...
 
TallyStore clone ()
 Clones this object and the array which stores the observations.
 
TallyStore extractSubrange (double a, double b)
 Returns a new TallyStore instance that contains all the observations of this TallyStore than are in the interval (a, b). More...
 
TallyStore aggregate (int gsize)
 Returns a new TallyStore instance that contains aggregate observations from this TallyStore. More...
 
String toString ()
 Returns the observations stored in this object as a String.
 
- Public Member Functions inherited from Tally
 Tally ()
 Constructs a new unnamed Tally statistical probe.
 
 Tally (String name)
 Constructs a new Tally statistical probe with name name. More...
 
void setName (String name)
 Set the name of this Tally to name. More...
 
void init ()
 
void add (double x)
 Gives a new observation x to the statistical collector. More...
 
void add (double[] x, int number)
 Adds the first number observations from the array x to this probe.
 
int numberObs ()
 Returns the number of observations given to this probe since its last initialization. More...
 
double sum ()
 
double average ()
 Returns the average value of the observations since the last initialization.
 
double variance ()
 Returns the sample variance of the observations since the last initialization. More...
 
double standardDeviation ()
 Returns the sample standard deviation of the observations since the last initialization. More...
 
void confidenceIntervalNormal (double level, double[] centerAndRadius)
 Computes a confidence interval on the mean. More...
 
void confidenceIntervalStudent (double level, double[] centerAndRadius)
 Computes a confidence interval on the mean. More...
 
String formatCINormal (double level, int d)
 Similar to confidenceIntervalNormal. More...
 
String formatCINormal (double level)
 Equivalent to formatCINormal (level, 3). More...
 
String formatCIStudent (double level, int d)
 Similar to confidenceIntervalStudent. More...
 
String formatCIStudent (double level)
 Equivalent to formatCIStudent (level, 3). More...
 
void confidenceIntervalVarianceChi2 (double level, double[] interval)
 Computes a confidence interval on the variance. More...
 
String formatCIVarianceChi2 (double level, int d)
 Similar to confidenceIntervalVarianceChi2. More...
 
String report ()
 Returns a formatted string that contains a report on this probe. More...
 
String report (double level, int d)
 Returns a formatted string that contains a report on this probe with a confidence interval level level using \(d\) fractional decimal digits. More...
 
String shortReportHeader ()
 
String shortReport ()
 Formats and returns a short statistical report for this tally. More...
 
String reportAndCIStudent (double level, int d)
 Returns a formatted string that contains a report on this probe (as in report ), followed by a confidence interval (as in formatCIStudent ), using \(d\) fractional decimal digits. More...
 
String reportAndCIStudent (double level)
 Same as reportAndCIStudent(level, 3). More...
 
double getConfidenceLevel ()
 Returns the level of confidence for the intervals on the mean displayed in reports. More...
 
void setConfidenceLevel (double level)
 Sets the level of confidence for the intervals on the mean displayed in reports. More...
 
void setConfidenceIntervalNone ()
 Indicates that no confidence interval needs to be printed in reports formatted by report, and shortReport. More...
 
void setConfidenceIntervalNormal ()
 Indicates that a confidence interval on the true mean, based on the central limit theorem, needs to be included in reports formatted by report and shortReport. More...
 
void setConfidenceIntervalStudent ()
 Indicates that a confidence interval on the true mean, based on the normality assumption, needs to be included in reports formatted by report and shortReport. More...
 
void setShowNumberObs (boolean showNumObs)
 Determines if the number of observations must be displayed in reports. More...
 
Tally clone ()
 Clones this object.
 
- Public Member Functions inherited from StatProbe
abstract void init ()
 Initializes the statistical collector.
 
void setName (String name)
 Sets the name of this statistical collector to name.
 
String getName ()
 Returns the name associated with this probe, or null if no name was specified upon construction. More...
 
double min ()
 Returns the smallest value taken by the variable since the last initialization of this probe. More...
 
double max ()
 Returns the largest value taken by the variable since the last initialization of this probe. More...
 
double sum ()
 Returns the sum cumulated so far for this probe. More...
 
abstract double average ()
 Returns the average for this collector. More...
 
abstract String report ()
 Returns a string containing a report for this statistical collector. More...
 
abstract String shortReport ()
 Formats and returns a short, one-line report about this statistical probe. More...
 
abstract String shortReportHeader ()
 Returns a string containing the name of the values returned in the report strings. More...
 
boolean isBroadcasting ()
 Determines if this statistical probe is broadcasting observations to registered observers. More...
 
void setBroadcasting (boolean b)
 Instructs the probe to turn its broadcasting ON or OFF. More...
 
boolean isCollecting ()
 Determines if this statistical probe is collecting values. More...
 
void setCollecting (boolean b)
 Turns ON or OFF the collection of statistical observations. More...
 
void addObservationListener (ObservationListener l)
 Adds the observation listener l to the list of observers of this statistical probe. More...
 
void removeObservationListener (ObservationListener l)
 Removes the observation listener l from the list of observers of this statistical probe. More...
 
void clearObservationListeners ()
 Removes all observation listeners from the list of observers of this statistical probe.
 
void notifyListeners (double x)
 Notifies the observation x to all registered observers if broadcasting is ON. More...
 
StatProbe clone () throws CloneNotSupportedException
 

Additional Inherited Members

- Static Public Member Functions inherited from StatProbe
static String report (String globalName, StatProbe[] probes)
 Formats short reports for each statistical probe in the array probes while aligning the probes’ names. More...
 
static String report (String globalName, Iterable<? extends StatProbe > probes)
 Equivalent to #report(String,StatProbe[]), except that probes is an Iterable object instead of an array. More...
 
- Protected Attributes inherited from Tally
int numObs
 
CIType confidenceInterval = CIType.CI_NONE
 
double level = 0.95
 
int digits = 3
 
- Protected Attributes inherited from StatProbe
String name
 
double maxValue
 
double minValue
 
double sumValue
 
boolean collect = true
 
boolean broadcast = false
 
boolean showNobs = true
 

Detailed Description

This class is a variant of Tally for which the individual observations are stored in a list implemented as a DoubleArrayList.

The class DoubleArrayList is imported from the COLT library and provides an efficient way of storing and manipulating a list of real-valued numbers in a dynamic array. The DoubleArrayList object used to store the values can be either passed to the constructor or created by the constructor, and can be accessed via the getDoubleArrayList method.

The same counters as in Tally are maintained and are used by the inherited methods. One must access the list of observations to compute quantities not supported by the methods in Tally, and/or to use methods provided by the COLT package.

Never add or remove observations directly on the DoubleArrayList object, because this would put the counters of the TallyStore object in an inconsistent state.

There are two potential reasons for using a TallyStore object instead of directly using a DoubleArrayList object: (a) it can broadcast observations and (b) it maintains a few additional counters that may speed up some operations such as computing the average.

Constructor & Destructor Documentation

◆ TallyStore() [1/4]

TallyStore ( String  name)

Constructs a new TallyStore statistical probe with name name.

Parameters
namethe name of the tally.

◆ TallyStore() [2/4]

TallyStore ( int  capacity)

Constructs a new TallyStore statistical probe with given initial capacity capacity for its associated array.

Parameters
capacityinitial capacity of the array of observations

◆ TallyStore() [3/4]

TallyStore ( String  name,
int  capacity 
)

Constructs a new TallyStore statistical probe with name name and given initial capacity capacity for its associated array.

Parameters
namethe name of the tally.
capacityinitial capacity of the array of observations

◆ TallyStore() [4/4]

TallyStore ( DoubleArrayList  a)

Constructs a new TallyStore statistical probe with given associated array.

This array must be empty.

Parameters
aarray that will contain observations

Member Function Documentation

◆ aggregate()

TallyStore aggregate ( int  gsize)

Returns a new TallyStore instance that contains aggregate observations from this TallyStore.

This method divides the observations in blocks of size gsize successive observations, compute the average of each group, and then inserts the average of each group in a new TallyStore object.

Note that this method does not sort the observations. It will aggregate the observations according to their actual order in the array. To aggregate the sorted observations (e.g., to plot a approximation of the cdf), the user should sort this TallyStore object before calling this method.

Parameters
gsizethe group size to use when performing the aggregation
Returns
a new TallyStore object with aggregated observations

◆ covariance()

double covariance ( TallyStore  t2)

Returns the sample covariance of the observations contained in this tally, and the other tally t2.

Both tallies must have the same number of observations. This returns Double.NaN if the tallies do not contain the same number of observations, or if they contain less than two observations.

Parameters
t2the other tally.
Returns
the sample covariance.

◆ extractSubrange()

TallyStore extractSubrange ( double  a,
double  b 
)

Returns a new TallyStore instance that contains all the observations of this TallyStore than are in the interval (a, b).

This method does not sort the observations.

Returns
a new TallyStore object with the selected observations

◆ getArray()

double [] getArray ( )

Returns the observations stored in this probe.

Returns
the array of observations associated with this object

◆ getDoubleArrayList()

DoubleArrayList getDoubleArrayList ( )

Returns the DoubleArrayList object that contains the observations for this probe.

WARNING: In early releases, this function was named getArray.

Returns
the array of observations associated with this object

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