SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
umontreal.ssj.stat.list.ListOfTallies< E extends Tally > Class Template Reference

Represents a list of tally statistical collectors. More...

Inheritance diagram for umontreal.ssj.stat.list.ListOfTallies< E extends Tally >:
umontreal.ssj.stat.list.ListOfStatProbes< E > umontreal.ssj.mcqmctools.anova.AnovaVarianceCollector

Public Member Functions

 ListOfTallies ()
 Constructs a new empty list of tallies.
 ListOfTallies (String name)
 Constructs a new empty list of tallies with name name.
void add (double[] x)
 Adds the observation x[i] in tally i of this list, for i = 0,…, size() - 1.
int numberObs ()
 Assuming that each tally in this list contains the same number of observations, returns the number of observations in tally 0, or 0 if this list is empty.
boolean areAllNumberObsEqual ()
 Tests that every tally in this list contains the same number of observations.
void average (double[] r)
 Computes the average for each tally in this list, and stores the averages in the array r.
void variance (double[] v)
 For each tally in this list, computes the sample variance, and stores the variances into the array v.
void standardDeviation (double[] std)
 For each tally in this list, computes the sample standard deviation, and stores the standard deviations into the array std.
double covariance (int i, int j)
 Returns the empirical covariance of the observations in tallies with indices i and j.
double correlation (int i, int j)
 Returns the empirical correlation between the observations in tallies with indices i and j.
void covariance (DoubleMatrix2D c)
 Constructs and returns the sample covariance matrix for the tallies in this list.
void correlation (DoubleMatrix2D c)
 Similar to covariance(DoubleMatrix2D) for computing the sample correlation matrix.
ListOfTallies< E > clone ()
 Clones this object.
Public Member Functions inherited from umontreal.ssj.stat.list.ListOfStatProbes< E >
 ListOfStatProbes ()
 Constructs an empty list of statistical probes.
String getName ()
 Returns the global name of this list of statistical probes.
void setName (String name)
 Sets the global name of this list to name.
boolean isModifiable ()
 Determines if this list of statistical probes is modifiable, i.e., if probes can be added or removed.
void setUnmodifiable ()
 Forbids any future modification to this list of statistical probes.
void init ()
 Initializes this list of statistical probes by calling umontreal.ssj.stat.StatProbe.init on each element.
void sum (double[] s)
 For each probe in the list, computes the sum by calling umontreal.ssj.stat.StatProbe.sum, and stores the results into the array s.
void average (double[] a)
 For each probe in this list, computes the average by calling umontreal.ssj.stat.StatProbe.average, and stores the results into the array a.
boolean isCollecting ()
 Determines if this list of statistical probes is collecting values.
void setCollecting (boolean c)
 Sets the status of the statistical collecting mechanism to c.
boolean isBroadcasting ()
 Determines if this list of statistical probes is broadcasting observations to registered observers.
void setBroadcasting (boolean b)
 Sets the status of the observation broadcasting mechanism to b.
void addArrayOfObservationListener (ArrayOfObservationListener l)
 Adds the observation listener l to the list of observers of this list of statistical probes.
void removeArrayOfObservationListener (ArrayOfObservationListener l)
 Removes the observation listener l from the list of observers of this list of statistical probes.
void clearArrayOfObservationListeners ()
 Removes all observation listeners from the list of observers of this list of statistical probes.
void notifyListeners (double[] x)
 Notifies the observation x to all registered observers if broadcasting is ON.
String report ()
 Formats a report for each probe in the list of statistical probes.
ListOfStatProbes< E > clone ()
 Clones this object.

Static Public Member Functions

static ListOfTallies< TallycreateWithTally (int size)
 This factory method constructs and returns a list of tallies with size instances of umontreal.ssj.stat.Tally.
static ListOfTallies< TallyStorecreateWithTallyStore (int size)
 This factory method constructs and returns a list of tallies with size instances of umontreal.ssj.stat.TallyStore.
static ListOfTallies< TallyStorecreateWithTallyStore (int size, int t)
 This factory method constructs and returns a list of tallies with size instances of umontreal.ssj.stat.TallyStore, each of size \(t\).

Detailed Description

Represents a list of tally statistical collectors.

Each element of the list is an instance of umontreal.ssj.stat.Tally, and a vector of observations can be added with the add(double[]) method. This class defines factory methods to fill a newly-constructed list with Tally or TallyStore instances.

Definition at line 40 of file ListOfTallies.java.

Constructor & Destructor Documentation

◆ ListOfTallies() [1/2]

umontreal.ssj.stat.list.ListOfTallies< E extends Tally >.ListOfTallies ( )

Constructs a new empty list of tallies.

Definition at line 45 of file ListOfTallies.java.

◆ ListOfTallies() [2/2]

umontreal.ssj.stat.list.ListOfTallies< E extends Tally >.ListOfTallies ( String name)

Constructs a new empty list of tallies with name name.

Parameters
namethe name of the new list.

Definition at line 54 of file ListOfTallies.java.

Member Function Documentation

◆ add()

void umontreal.ssj.stat.list.ListOfTallies< E extends Tally >.add ( double[] x)

Adds the observation x[i] in tally i of this list, for i = 0,…, size() - 1.

No observation is added if the value is Double.NaN, or if collecting is turned OFF. If broadcasting is ON, the given array is notified to all registered observers. The given array x not being stored by this object, it can be freely used and modified after the call to this method.

Parameters
xthe array of observations.
Exceptions
NullPointerExceptionif `x` is `null`.
IllegalArgumentExceptionif the length of `x` does not correspond to size().

Reimplemented in umontreal.ssj.mcqmctools.anova.AnovaVarianceCollector.

Definition at line 115 of file ListOfTallies.java.

◆ areAllNumberObsEqual()

boolean umontreal.ssj.stat.list.ListOfTallies< E extends Tally >.areAllNumberObsEqual ( )

Tests that every tally in this list contains the same number of observations.

This returns true if and only if all tallies have the same number of observations, or if this list is empty. If observations are always added using the add(double[]) method from this class, and not umontreal.ssj.stat.Tally.add(double) from

umontreal.ssj.stat.Tally, this method always returns true.

Returns
the success indicator of the test.

Definition at line 153 of file ListOfTallies.java.

◆ average()

void umontreal.ssj.stat.list.ListOfTallies< E extends Tally >.average ( double[] r)

Computes the average for each tally in this list, and stores the averages in the array r.

If the tally i has no observation, the Double.NaN value is stored in the array, at index i.

Definition at line 169 of file ListOfTallies.java.

◆ clone()

Clones this object.

This makes a shallow copy of this list, i.e., this does not clone all the tallies in the list. The created clone is modifiable, even if the original list is unmodifiable.

Definition at line 343 of file ListOfTallies.java.

◆ correlation() [1/2]

void umontreal.ssj.stat.list.ListOfTallies< E extends Tally >.correlation ( DoubleMatrix2D c)

Similar to covariance(DoubleMatrix2D) for computing the sample correlation matrix.

Parameters
cthe matrix to be filled with the correlations.
Exceptions
NullPointerExceptionif `c` is `null`.
IllegalArgumentExceptionif the number of rows or columns in `c` does not correspond to umontreal.ssj.stat.list.ListOfStatProbes.size.

Definition at line 322 of file ListOfTallies.java.

◆ correlation() [2/2]

double umontreal.ssj.stat.list.ListOfTallies< E extends Tally >.correlation ( int i,
int j )

Returns the empirical correlation between the observations in tallies with indices i and j.

If the tally i contains a sample of the random variate \(X\) and the tally j contains a sample of

\(Y\), this corresponds to

\[ \mathrm{Cor}(X, Y)=\mathrm{Cov}(X, Y) /\sqrt{\mathrm{Var}(X)\mathrm{Var}(Y)}. \]

This method uses covariance(int,int) to obtain an estimate of the covariance, and umontreal.ssj.stat.Tally.variance in class umontreal.ssj.stat.Tally to obtain the sample variances.

Parameters
ithe index of the first tally.
jthe index of the second tally.
Returns
the value of the correlation.
Exceptions
ArrayIndexOutOfBoundsExceptionif one or both indices are out of bounds.

Definition at line 273 of file ListOfTallies.java.

◆ covariance() [1/2]

void umontreal.ssj.stat.list.ListOfTallies< E extends Tally >.covariance ( DoubleMatrix2D c)

Constructs and returns the sample covariance matrix for the tallies in this list.

The given \(d\times d\) matrix c, where

\(d=\) size(), is filled with the computed sample covariances. Element c.get (i, j) corresponds to the result of covariance (i, j).

Parameters
cthe matrix to be filled with the sample covariances.
Exceptions
NullPointerExceptionif `c` is `null`.
IllegalArgumentExceptionif the number of rows or columns in `c` does not correspond to size().

Definition at line 296 of file ListOfTallies.java.

◆ covariance() [2/2]

double umontreal.ssj.stat.list.ListOfTallies< E extends Tally >.covariance ( int i,
int j )

Returns the empirical covariance of the observations in tallies with indices i and j.

If \(x_1,…,x_n\) represent the observations in tally i whereas \(y_1,…,y_n\) represent the observations in tally j, then the covariance is given by

\[ S_{X, Y} = \frac{1}{n-1}\sum_{k=1}^n (x_k - \bar{X}_n)(y_k - \bar{Y}_n) = \frac{1}{n-1}\left(\sum_{k=1}^n x_ky_k - \frac{1}{n} \sum_{k=1}^n x_k\sum_{r=1}^n y_r\right). \]

This returns Double.NaN if the tallies do not contain the same number of observations, or if they contain less than two observations. This method throws an exception if the underlying tallies are not capable of storing observations, i.e. if the tallies are not TallyStores. The ListOfTalliesWithCovariance subclass provides an alternative implementation of this method which does not require the observations to be stored.

Parameters
ithe index of the first tally.
jthe index of the second tally.
Returns
the value of the covariance.
Exceptions
ArrayIndexOutOfBoundsExceptionif one or both indices are out of bounds.

Definition at line 247 of file ListOfTallies.java.

◆ createWithTally()

ListOfTallies< Tally > umontreal.ssj.stat.list.ListOfTallies< E extends Tally >.createWithTally ( int size)
static

This factory method constructs and returns a list of tallies with size instances of umontreal.ssj.stat.Tally.

Parameters
sizethe size of the list.
Returns
the created list.

Definition at line 65 of file ListOfTallies.java.

◆ createWithTallyStore() [1/2]

ListOfTallies< TallyStore > umontreal.ssj.stat.list.ListOfTallies< E extends Tally >.createWithTallyStore ( int size)
static

This factory method constructs and returns a list of tallies with size instances of umontreal.ssj.stat.TallyStore.

Parameters
sizethe size of the list.
Returns
the created list.

Definition at line 79 of file ListOfTallies.java.

◆ createWithTallyStore() [2/2]

ListOfTallies< TallyStore > umontreal.ssj.stat.list.ListOfTallies< E extends Tally >.createWithTallyStore ( int size,
int t )
static

This factory method constructs and returns a list of tallies with size instances of umontreal.ssj.stat.TallyStore, each of size \(t\).

Parameters
sizethe size of the list.
tsize of each TallyStore in this list.
Returns
the created list.

Definition at line 95 of file ListOfTallies.java.

◆ numberObs()

int umontreal.ssj.stat.list.ListOfTallies< E extends Tally >.numberObs ( )

Assuming that each tally in this list contains the same number of observations, returns the number of observations in tally 0, or 0 if this list is empty.

Returns
the number of observations.

Definition at line 136 of file ListOfTallies.java.

◆ standardDeviation()

void umontreal.ssj.stat.list.ListOfTallies< E extends Tally >.standardDeviation ( double[] std)

For each tally in this list, computes the sample standard deviation, and stores the standard deviations into the array std.

This is equivalent to calling variance(double[]) and performing a square root on every element of the filled array.

Parameters
stdthe array to be filled with standard deviations.
Exceptions
NullPointerExceptionif `std` is `null`.
IllegalArgumentExceptionif `std.length` does not correspond to size().

Definition at line 214 of file ListOfTallies.java.

◆ variance()

void umontreal.ssj.stat.list.ListOfTallies< E extends Tally >.variance ( double[] v)

For each tally in this list, computes the sample variance, and stores the variances into the array v.

If, for some tally i, there are not enough observations for estimating the variance, Double.NaN is stored in the array.

Parameters
vthe array to be filled with sample variances.
Exceptions
NullPointerExceptionif `v` is `null`.
IllegalArgumentExceptionif `v.length` does not correspond to umontreal.ssj.stat.list.ListOfStatProbes.size.

Definition at line 191 of file ListOfTallies.java.


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