SSJ
3.3.1
Stochastic Simulation in Java
|
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...
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< Tally > | createWithTally (int size) |
This factory method constructs and returns a list of tallies with size instances of umontreal.ssj.stat.Tally. More... | |
static ListOfTalliesWithCovariance< TallyStore > | createWithTallyStore (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< Tally > | createWithTally (int size) |
This factory method constructs and returns a list of tallies with size instances of umontreal.ssj.stat.Tally. More... | |
static ListOfTallies< TallyStore > | createWithTallyStore (int size) |
This factory method constructs and returns a list of tallies with size instances of umontreal.ssj.stat.TallyStore. More... | |
static ListOfTallies< TallyStore > | createWithTallyStore (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... | |
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:
But the following code is always correct:
Creates an empty list of tallies with covariance support.
One must fill the list with tallies, and call #init before adding any observation.
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.
name | the name of the new list. |
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.
x | the new vector of observations. |
ListOfTalliesWithCovariance<E> 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.
|
static |
This factory method constructs and returns a list of tallies with size
instances of umontreal.ssj.stat.Tally.
size | the size of the list. |
|
static |
This factory method constructs and returns a list of tallies with size
instances of umontreal.ssj.stat.TallyStore.
size | the size of the list. |