SSJ
3.3.1
Stochastic Simulation in Java

A subclass of StatProbe. More...
Public Member Functions  
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, oneline 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 
Protected Attributes  
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 
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...  
A subclass of StatProbe.
This type of statistical collector takes a sequence of realvalued observations \(X_1,X_2,X_3,…\) and can return the average, the variance, a confidence interval for the theoretical mean, etc. Each call to add provides a new observation. When the broadcasting to observers is activated, the method add will also pass this new information to its registered observers. This type of collector does not memorize the individual observations, but only their number, sum, sum of squares, maximum, and minimum. The subclass TallyStore offers a collector that memorizes the observations.
Tally  (  String  name  ) 
Constructs a new Tally
statistical probe with name name
.
name  name of the tally 
void add  (  double  x  ) 
Gives a new observation x
to the statistical collector.
If broadcasting to observers is activated for this object, this method also transmits the new information to the registered observers by invoking the method notifyListeners.
x  observation being added to this Tally object 
void confidenceIntervalNormal  (  double  level, 
double []  centerAndRadius  
) 
Computes a confidence interval on the mean.
Returns, in elements 0 and 1 of the array object centerAndRadius[]
, the center and halflength (radius) of a confidence interval on the true mean of the random variable \(X\), with confidence level level
, assuming that the \(n\) observations given to this collector are independent and identically distributed (i.i.d.) copies of \(X\), and that \(n\) is large enough for the central limit theorem to hold. This confidence interval is computed based on the statistic
\[ Z = {\bar{X}_n  \mu\over{S_{n,x}/\sqrt{n}}} \]
where \(n\) is the number of observations given to this collector since its last initialization, \(\bar{X}_n =\) average()
is the average of these observations, \(S_{n,x} =\) standardDeviation()
is the empirical standard deviation. Under the assumption that the observations of \(X\) are i.i.d. and \(n\) is large, \(Z\) has the standard normal distribution. The confidence interval given by this method is valid only if this assumption is approximately verified.
level  desired probability that the (random) confidence interval covers the true mean (a constant) 
centerAndRadius  array of size 2 in which are returned the center and radius of the confidence interval, respectively 
void confidenceIntervalStudent  (  double  level, 
double []  centerAndRadius  
) 
Computes a confidence interval on the mean.
Returns, in elements 0 and 1 of the array object centerAndRadius[]
, the center and halflength (radius) of a confidence interval on the true mean of the random variable \(X\), with confidence level level
, assuming that the observations given to this collector are independent and identically distributed (i.i.d.) copies of \(X\), and that \(X\) has the normal distribution. This confidence interval is computed based on the statistic
\[ T = {\bar{X}_n  \mu\over{S_{n,x}/\sqrt{n}}} \]
where \(n\) is the number of observations given to this collector since its last initialization, \(\bar{X}_n =\) average()
is the average of these observations, \(S_{n,x} =\) standardDeviation()
is the empirical standard deviation. Under the assumption that the observations of \(X\) are i.i.d. and normally distributed, \(T\) has the Student distribution with \(n1\) degrees of freedom. The confidence interval given by this method is valid only if this assumption is approximately verified, or if \(n\) is large enough so that \(\bar{X}_n\) is approximately normally distributed.
level  desired probability that the (random) confidence interval covers the true mean (a constant) 
centerAndRadius  array of size 2 in which are returned the center and radius of the confidence interval, respectively 
void confidenceIntervalVarianceChi2  (  double  level, 
double []  interval  
) 
Computes a confidence interval on the variance.
Returns, in elements 0 and 1 of array interval
, the left and right boundaries \([I_1,I_2]\) of a confidence interval on the true variance \(\sigma^2\) of the random variable \(X\), with confidence level level
, assuming that the observations given to this collector are independent and identically distributed (i.i.d.) copies of \(X\), and that \(X\) has the normal distribution. This confidence interval is computed based on the statistic \( \chi^2_{n1} = (n1)S^2_n/\sigma^2 \) where \(n\) is the number of observations given to this collector since its last initialization, and \(S^2_n =\) variance()
is the empirical variance of these observations. Under the assumption that the observations of \(X\) are i.i.d. and normally distributed, \(\chi^2_{n1}\) has the chisquare distribution with \(n1\) degrees of freedom. Given the level
\( = 1  \alpha\), one has \(P[\chi^2_{n1} < x_1] = P[\chi^2_{n1} > x_2] = \alpha/2\) and \([I_1,I_2] = [(n1)S^2_n/x_2,\; (n1)S^2_n/x_1]\).
level  desired probability that the (random) confidence interval covers the true mean (a constant) 
interval  array of size 2 in which are returned the left and right boundaries of the confidence interval, respectively 
String formatCINormal  (  double  level, 
int  d  
) 
Similar to confidenceIntervalNormal.
Returns the confidence interval in a formatted string of the form
95% confidence interval for mean (normal): (32.431, 32.487)
",using \(d\) fractional decimal digits.
level  desired probability that the (random) confidence interval covers the true mean (a constant) 
d  number of fractional decimal digits 
String formatCINormal  (  double  level  ) 
Equivalent to formatCINormal (level, 3)
.
level  desired probability that the (random) confidence interval covers the true mean (a constant) 
String formatCIStudent  (  double  level, 
int  d  
) 
Similar to confidenceIntervalStudent.
Returns the confidence interval in a formatted string of the form
95% confidence interval for mean (student): (32.431, 32.487)
",using \(d\) fractional decimal digits.
level  desired probability that the (random) confidence interval covers the true mean (a constant) 
d  number of fractional decimal digits 
String formatCIStudent  (  double  level  ) 
Equivalent to formatCIStudent (level, 3)
.
level  desired probability that the (random) confidence interval covers the true mean (a constant) 
String formatCIVarianceChi2  (  double  level, 
int  d  
) 
Similar to confidenceIntervalVarianceChi2.
Returns the confidence interval in a formatted string of the form
95.0% confidence interval for variance (chi2): ( 510.642, 519.673 )
",using \(d\) fractional decimal digits.
level  desired probability that the (random) confidence interval covers the true variance 
d  number of fractional decimal digits 
double getConfidenceLevel  (  ) 
Returns the level of confidence for the intervals on the mean displayed in reports.
The default confidence level is 0.95.
int numberObs  (  ) 
Returns the number of observations given to this probe since its last initialization.
String report  (  ) 
Returns a formatted string that contains a report on this probe.
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.
level  desired probability that the confidence interval covers the true mean 
d  number of fractional decimal digits 
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.
level  desired probability that the (random) confidence interval covers the true mean (a constant) 
d  number of fractional decimal digits 
String reportAndCIStudent  (  double  level  ) 
Same as reportAndCIStudent(level, 3).
level  desired probability that the (random) confidence interval covers the true mean (a constant) 
void setConfidenceIntervalNone  (  ) 
Indicates that no confidence interval needs to be printed in reports formatted by report, and shortReport.
This restores the default behavior of the reporting system.
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.
The confidence interval is formatted using formatCINormal.
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.
The confidence interval is formatted using formatCIStudent.
void setConfidenceLevel  (  double  level  ) 
Sets the level of confidence for the intervals on the mean displayed in reports.
level  desired probability that the (random) confidence interval covers the true mean (a constant) 
void setName  (  String  name  ) 
Set the name of this Tally
to name
.
name  name of the tally 
void setShowNumberObs  (  boolean  showNumObs  ) 
Determines if the number of observations must be displayed in reports.
By default, the number of observations is displayed.
showNumObs  the value of the indicator. 
String shortReport  (  ) 
Formats and returns a short statistical report for this tally.
The returned singleline report contains the minimum value, the maximum value, the average, the variance, and the standard deviation, in that order, separated by three spaces. If the number of observations is shown in the short report, a column containing the number of observations in this tally is added.
double standardDeviation  (  ) 
Returns the sample standard deviation of the observations since the last initialization.
This returns Double.NaN
if the tally contains less than two observations.
double variance  (  ) 
Returns the sample variance of the observations since the last initialization.
This returns Double.NaN
if the tally contains less than two observations.