SSJ  3.3.1
Stochastic Simulation in Java
Public Member Functions | Static Public Member Functions | List of all members
ListOfTallies< E extends Tally > Class Template Reference

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

Inheritance diagram for ListOfTallies< E extends Tally >:
[legend]
Collaboration diagram for ListOfTallies< E extends Tally >:
[legend]

Public Member Functions

 ListOfTallies ()
 Constructs a new empty list of tallies.
 
 ListOfTallies (String name)
 Constructs a new empty list of tallies with name name. More...
 
void add (double[] x)
 Adds the observation x[i] in tally i of this list, for i = 0,…, size() - 1. More...
 
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. More...
 
boolean areAllNumberObsEqual ()
 Tests that every tally in this list contains the same number of observations. More...
 
void average (double[] r)
 Computes the average for each tally in this list, and stores the averages in the array r. More...
 
void variance (double[] v)
 For each tally in this list, computes the sample variance, and stores the variances into the array v. More...
 
void standardDeviation (double[] std)
 For each tally in this list, computes the sample standard deviation, and stores the standard deviations into the array std. More...
 
double covariance (int i, int j)
 Returns the empirical covariance of the observations in tallies with indices i and j. More...
 
double correlation (int i, int j)
 Returns the empirical correlation between the observations in tallies with indices i and j. More...
 
void covariance (DoubleMatrix2D c)
 Constructs and returns the sample covariance matrix for the tallies in this list. More...
 
void correlation (DoubleMatrix2D c)
 Similar to covariance(DoubleMatrix2D) for computing the sample correlation matrix. More...
 
ListOfTallies< E > clone ()
 Clones this object. More...
 
- Public Member Functions inherited from ListOfStatProbes< E >
 ListOfStatProbes ()
 Constructs an empty list of statistical probes.
 
 ListOfStatProbes (String name)
 Constructs an empty list of statistical probes with name name. More...
 
String getName ()
 Returns the global name of this list of statistical probes. More...
 
void setName (String name)
 Sets the global name of this list to name. More...
 
boolean isModifiable ()
 Determines if this list of statistical probes is modifiable, i.e., if probes can be added or removed. More...
 
void setUnmodifiable ()
 Forbids any future modification to this list of statistical probes. More...
 
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. More...
 
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. More...
 
boolean isCollecting ()
 Determines if this list of statistical probes is collecting values. More...
 
void setCollecting (boolean c)
 Sets the status of the statistical collecting mechanism to c. More...
 
boolean isBroadcasting ()
 Determines if this list of statistical probes is broadcasting observations to registered observers. More...
 
void setBroadcasting (boolean b)
 Sets the status of the observation broadcasting mechanism to b. More...
 
void addArrayOfObservationListener (ArrayOfObservationListener l)
 Adds the observation listener l to the list of observers of this list of statistical probes. More...
 
void removeArrayOfObservationListener (ArrayOfObservationListener l)
 Removes the observation listener l from the list of observers of this list of statistical probes. More...
 
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. More...
 
String report ()
 Formats a report for each probe in the list of statistical probes. More...
 
ListOfStatProbes< E > clone ()
 Clones this object. More...
 
boolean add (E o)
 
void add (int index, E o)
 
boolean addAll (Collection<? extends E > c)
 
boolean addAll (int index, Collection<? extends E > c)
 
void clear ()
 
boolean contains (Object o)
 
boolean containsAll (Collection<?> c)
 
boolean equals (Object o)
 
get (int index)
 
int hashCode ()
 
int indexOf (Object o)
 
boolean isEmpty ()
 
Iterator< E > iterator ()
 
int lastIndexOf (Object o)
 
ListIterator< E > listIterator ()
 
ListIterator< E > listIterator (int index)
 
remove (int index)
 
boolean remove (Object o)
 
boolean removeAll (Collection<?> c)
 
boolean retainAll (Collection<?> c)
 
set (int index, E element)
 
int size ()
 
List< E > subList (int fromIndex, int toIndex)
 
Object [] toArray ()
 

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. More...
 
static ListOfTallies< TallyStorecreateWithTallyStore (int size)
 This factory method constructs and returns a list of tallies with size instances of umontreal.ssj.stat.TallyStore. More...
 
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\). More...
 

Additional Inherited Members

- Protected Attributes inherited from ListOfStatProbes< E >
boolean collect
 
boolean broadcast
 
String name
 
- Package Functions inherited from ListOfStatProbes< E >
public< T > T [] toArray (T[] a)
 

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.

Constructor & Destructor Documentation

◆ ListOfTallies()

ListOfTallies ( String  name)

Constructs a new empty list of tallies with name name.

Parameters
namethe name of the new list.

Member Function Documentation

◆ add()

void 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().

◆ areAllNumberObsEqual()

boolean 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.

◆ average()

void 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.

◆ clone()

ListOfTallies<E> 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.

◆ correlation() [1/2]

double 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.

◆ correlation() [2/2]

void 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.

◆ covariance() [1/2]

double 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.

◆ covariance() [2/2]

void 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().

◆ createWithTally()

static ListOfTallies<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.

◆ createWithTallyStore() [1/2]

static ListOfTallies<TallyStore> 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.

◆ createWithTallyStore() [2/2]

static ListOfTallies<TallyStore> 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.

◆ numberObs()

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.

Returns
the number of observations.

◆ standardDeviation()

void 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().

◆ variance()

void 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.

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