SSJ
V. 1.2.5.

umontreal.iro.lecuyer.stat
Class Tally

java.lang.Object
  extended by java.util.Observable
      extended by umontreal.iro.lecuyer.stat.StatProbe
          extended by umontreal.iro.lecuyer.stat.Tally
All Implemented Interfaces:
Cloneable
Direct Known Subclasses:
TallyStore

public class Tally
extends StatProbe
implements Cloneable

This type of statistical collector takes a sequence of real-valued observations 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.


Constructor Summary
Tally()
          Constructs a new Tally statistical probe.
Tally(String name)
          Constructs a new Tally statistical probe with name name.
 
Method Summary
 void add(double x)
          Gives a new observation x to the statistical collector.
 double average()
          Returns the average for this collector.
 Object clone()
          Clone this object.
 void confidenceIntervalStudent(double level, double[] centerAndRadius)
          Returns, in elements 0 and 1 of the array object centerAndRadius[], the center and half-length (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.
 String formatCIStudent(double level)
          An alias for formatConfidenceIntervalStudent.
 String formatCIStudent(double level, int d)
          An alias for formatConfidenceIntervalStudent.
 String formatConfidenceIntervalStudent(double level)
           
 String formatConfidenceIntervalStudent(double level, int d)
          Similar to confidenceIntervalStudent, but returns the confidence interval in a formatted string of the form ``95% confidence interval for mean: (32.431, 32.487)'', using d decimal digits of accuracy.
 void init()
          Initializes the statistical collector.
 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 reportAndCIStudent(double level)
          An alias for reportAndConfidenceIntervalStudent.
 String reportAndCIStudent(double level, int d)
          An alias for reportAndConfidenceIntervalStudent.
 String reportAndConfidenceIntervalStudent(double level)
          Same as reportAndConfidenceIntervalStudent(level, 3).
 String reportAndConfidenceIntervalStudent(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 formatConfidenceIntervalStudent), using d decimal digits of accuracy.
 double standardDeviation()
          Returns the standard deviation of the observations since the last initialization.
 double variance()
          Returns the variance of the observations since the last initialization.
 
Methods inherited from class umontreal.iro.lecuyer.stat.StatProbe
getName, max, min, setBroadcasting, setCollecting, setName, sum
 
Methods inherited from class java.util.Observable
addObserver, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Tally

public Tally()
Constructs a new Tally statistical probe.


Tally

public Tally(String name)
Constructs a new Tally statistical probe with name name.

Parameters:
name - name of the tally
Method Detail

init

public void init()
Description copied from class: StatProbe
Initializes the statistical collector.

Specified by:
init in class StatProbe

add

public void add(double x)
Gives a new observation x to the statistical collector. If broadcasting to observers is activated for this object, this method will also transmit the new information to the registered observers by invoking the methods setChanged and notifyObservers (new Double (x)) inherited from Observable.

Parameters:
x - observation being added to this tally

numberObs

public int numberObs()
Returns the number of observations given to this probe since its last initialization.


average

public double average()
Description copied from class: StatProbe
Returns the average for this collector.

Specified by:
average in class StatProbe
Returns:
the average value of the collected observations

variance

public double variance()
Returns the variance of the observations since the last initialization.

Returns:
the variance of the observations

standardDeviation

public double standardDeviation()
Returns the standard deviation of the observations since the last initialization.

Returns:
the standard deviation of the observations

confidenceIntervalStudent

public void confidenceIntervalStudent(double level,
                                      double[] centerAndRadius)
Returns, in elements 0 and 1 of the array object centerAndRadius[], the center and half-length (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-μ/(Sn, x/(n)1/2)

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, Sn, 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 n - 1 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.

Parameters:
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

formatConfidenceIntervalStudent

public String formatConfidenceIntervalStudent(double level,
                                              int d)
Similar to confidenceIntervalStudent, but returns the confidence interval in a formatted string of the form ``95% confidence interval for mean: (32.431, 32.487)'', using d decimal digits of accuracy.

Parameters:
level - desired probability that the (random) confidence interval covers the true mean (a constant)
d - number of decimal digits of accuracy
Returns:
a confidence interval formated as a string

formatConfidenceIntervalStudent

public String formatConfidenceIntervalStudent(double level)

formatCIStudent

public String formatCIStudent(double level,
                              int d)
An alias for formatConfidenceIntervalStudent.

Parameters:
level - desired probability that the (random) confidence interval covers the true mean (a constant)
d - number of decimal digits of accuracy
Returns:
a confidence interval formated as a string

formatCIStudent

public String formatCIStudent(double level)
An alias for formatConfidenceIntervalStudent.

Parameters:
level - desired probability that the (random) confidence interval covers the true mean (a constant)
Returns:
a confidence interval formated as a string

report

public String report()
Returns a formatted string that contains a report on this probe.

Specified by:
report in class StatProbe
Returns:
a statistical report formated as a string

reportAndConfidenceIntervalStudent

public String reportAndConfidenceIntervalStudent(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 formatConfidenceIntervalStudent), using d decimal digits of accuracy.

Parameters:
level - desired probability that the (random) confidence interval covers the true mean (a constant)
d - number of decimal digits of accuracy
Returns:
a statistical report with a confidence interval, formated as a string

reportAndConfidenceIntervalStudent

public String reportAndConfidenceIntervalStudent(double level)
Same as reportAndConfidenceIntervalStudent(level, 3).

Parameters:
level - desired probability that the (random) confidence interval covers the true mean (a constant)
Returns:
a statistical report with a confidence interval, formated as a string

reportAndCIStudent

public String reportAndCIStudent(double level,
                                 int d)
An alias for reportAndConfidenceIntervalStudent.

Parameters:
level - desired probability that the (random) confidence interval covers the true mean (a constant)
d - number of decimal digits of accuracy
Returns:
a statistical report with a confidence interval, formated as a string

reportAndCIStudent

public String reportAndCIStudent(double level)
An alias for reportAndConfidenceIntervalStudent.

Parameters:
level - desired probability that the (random) confidence interval covers the true mean (a constant)
Returns:
a statistical report with a confidence interval, formated as a string

clone

public Object clone()
Clone this object.

Overrides:
clone in class StatProbe

SSJ
V. 1.2.5.

To submit a bug or ask questions, send an e-mail to Pierre L'Ecuyer.