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

Extends ListOfTallies to add support for the computation of the sample covariance between each pair of elements in a list, without storing all observations. More...

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

Public Member Functions

 ListOfTalliesWithCovariance ()
 Creates an empty list of tallies with covariance support. More...
 
 ListOfTalliesWithCovariance (String name)
 Creates an empty list of tallies with covariance support and name name. More...
 
void init ()
 
void add (double[] x)
 Adds a new vector of observations x to this list of tallies, and updates the internal data structures computing averages, and sums of products. More...
 
void add (DoubleMatrix1D x)
 
double covariance (int i, int j)
 
ListOfTalliesWithCovariance< E > clone ()
 Clones this object. More...
 
- Public Member Functions inherited from ListOfTallies< E >
 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...
 
void covariance (DoubleMatrix2D c)
 Constructs and returns the sample covariance matrix for the tallies in this list. More...
 
double correlation (int i, int j)
 Returns the empirical correlation between the observations in tallies with indices i and j. More...
 
void correlation (DoubleMatrix2D c)
 Similar to covariance(DoubleMatrix2D) for computing the sample correlation matrix. More...
 
ListOfTallies< E > clone ()
 Clones this object. More...
 

Static Public Member Functions

static ListOfTalliesWithCovariance< TallycreateWithTally (int size)
 This factory method constructs and returns a list of tallies with size instances of umontreal.ssj.stat.Tally. More...
 
static ListOfTalliesWithCovariance< TallyStorecreateWithTallyStore (int size)
 This factory method constructs and returns a list of tallies with size instances of umontreal.ssj.stat.TallyStore. More...
 
- Static Public Member Functions inherited from ListOfTallies< E >
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...
 

Detailed Description

Extends ListOfTallies to add support for the computation of the sample covariance between each pair of elements in a list, without storing all observations.

This list of tallies contains internal structures to keep track of \(\bar{X}_{n, i}\) for \(i=0, …, d-1\), and \(\sum_{k=0}^{n-1} (X_{i, k} - \bar{X}_{k, i})(X_{j, k} - \bar{X}_{k, j})/n\), for \(i=0,…, d-2\) and \(j=1,…,d-1\), with \(j>i\). Here, \(\bar{X}_{n, i}\) is the \(i\)th component of \(\bar{\mathbf{X}}_n\), the average vector, and \(\bar{X}_{0, i}=0\) for \(i=0,…,d-1\). The value \(X_{i,k}\) corresponds to the \(i\)th component of the \(k\)th observation \(\mathbf{X}_k\). These sums are updated every time a vector is added to this list, and are used to estimate the covariances.

Note: the size of the list of tallies must remain fixed because of the data structures used for computing sample covariances. As a result, the first call to init makes this list unmodifiable.

Note: for the sample covariance to be computed between a pair of tallies, the number of observations in each tally should be the same. It is therefore recommended to always add complete vectors of observations to this list. Moreover, one must use the add method in this class to add vectors of observations for the sums used for covariance estimation to be updated correctly. Failure to use this method, e.g., adding observations to each individual tally in the list, will result in an incorrect estimate of the covariances, unless the tallies in the list can store observations. For example, the following code, which adds the vector v in the list of tallies list, works correctly only if the list contains instances of umontreal.ssj.stat.TallyStore:

for (int i = 0; i < v.length; i++)
list.get (i).add (v[i]);

But the following code is always correct:

list.add (v);

Constructor & Destructor Documentation

◆ ListOfTalliesWithCovariance() [1/2]

Creates an empty list of tallies with covariance support.

One must fill the list with tallies, and call #init before adding any observation.

◆ ListOfTalliesWithCovariance() [2/2]

ListOfTalliesWithCovariance ( String  name)

Creates an empty list of tallies with covariance support and name name.

One must fill the list with tallies, and call #init before adding any observation.

Parameters
namethe name of the new list.

Member Function Documentation

◆ add()

void add ( double []  x)

Adds a new vector of observations x to this list of tallies, and updates the internal data structures computing averages, and sums of products.

One must use this method instead of adding observations to individual tallies to get a covariance estimate.

Parameters
xthe new vector of observations.

◆ clone()

Clones this object.

This clones the list of tallies and the data structures holding the sums of products but not the tallies comprising the list. The created clone is modifiable, even though the original list is unmodifiable.

◆ createWithTally()

static ListOfTalliesWithCovariance<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()

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

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