SSJ
V. labo.

umontreal.iro.lecuyer.stat.list
Class ListOfFunctionOfMultipleMeansTallies<E extends FunctionOfMultipleMeansTally>

java.lang.Object
  extended by umontreal.iro.lecuyer.stat.list.ListOfStatProbes<E>
      extended by umontreal.iro.lecuyer.stat.list.ListOfFunctionOfMultipleMeansTallies<E>
All Implemented Interfaces:
Cloneable, Iterable<E>, Collection<E>, List<E>, RandomAccess

public class ListOfFunctionOfMultipleMeansTallies<E extends FunctionOfMultipleMeansTally>
extends ListOfStatProbes<E>

Represents a list of tally statistical collectors for a vector of functions of multiple means. Each element of such a list is an instance of FunctionOfMultipleMeansTally, and observations can be added with the add method. This class defines a factory method to construct a list of tallies computing the same function and sharing the same dimension.


Constructor Summary
ListOfFunctionOfMultipleMeansTallies()
          Constructs a new empty list of tallies.
ListOfFunctionOfMultipleMeansTallies(String name)
          Constructs a new empty list of tallies with name name.
 
Method Summary
 void add(double[][] x)
          For each tally i in this list, adds the vector x[i].
 void add(DoubleMatrix2D x)
          Equivalent to add (x.toArray()), without copying the elements of x into a temporary 2D array.
 void addSameDimension(double[]... x)
          For each element i of this list of tallies, adds the vector of observations x[0][i], ..., x[d-1][i].
 void addSameDimension(DoubleMatrix1D... x)
          Equivalent to addSameDimension x.toArray(), without copying the elements of x into a temporary 1D array.
 boolean areAllNumberObsEqual()
          Tests that every tally in this list contains the same number of observations.
 void average(double[] a)
          Computes the function of averages for each tally in this list.
 ListOfFunctionOfMultipleMeansTallies<E> clone()
          Clones this object.
static ListOfFunctionOfMultipleMeansTallies<FunctionOfMultipleMeansTally> create(MultivariateFunction func, int d, int size)
          This factory method constructs and returns a list of tallies with size instances of
FunctionOfMultipleMeansTally.
 int getDimension()
          Assuming that each tally in this list has the same dimension, returns the dimension of tally 0, or 0 if this list is empty.
 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.
 void standardDeviation(double[] v)
          For each tally in this list, computes the standard deviation, and stores it into v.
 void variance(double[] v)
          For each tally in this list, computes the sample variance and stores it into v.
 
Methods inherited from class umontreal.iro.lecuyer.stat.list.ListOfStatProbes
add, add, addAll, addAll, addArrayOfObservationListener, clear, clearArrayOfObservationListeners, contains, containsAll, equals, get, getName, hashCode, indexOf, init, isBroadcasting, isCollecting, isEmpty, isModifiable, iterator, lastIndexOf, listIterator, listIterator, notifyListeners, remove, remove, removeAll, removeArrayOfObservationListener, report, retainAll, set, setBroadcasting, setCollecting, setName, setUnmodifiable, size, subList, sum, toArray, toArray
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ListOfFunctionOfMultipleMeansTallies

public ListOfFunctionOfMultipleMeansTallies()
Constructs a new empty list of tallies.


ListOfFunctionOfMultipleMeansTallies

public ListOfFunctionOfMultipleMeansTallies(String name)
Constructs a new empty list of tallies with name name.

Parameters:
name - the name of this list.
Method Detail

create

public static ListOfFunctionOfMultipleMeansTallies<FunctionOfMultipleMeansTally> create(MultivariateFunction func,
                                                                                        int d,
                                                                                        int size)
This factory method constructs and returns a list of tallies with size instances of
FunctionOfMultipleMeansTally. Each tally computes the multivariate function func, in d dimensions.

Parameters:
func - the multivariate function computed by the tallies.
d - the dimension of the tallies.
size - the size of the list.
Returns:
the created list.

add

public void add(double[][] x)
For each tally i in this list, adds the vector x[i]. Since each element of the 2D array x can have a different dimension, it is not necessary for x to be rectangular, although this is generally the case. If collecting is turned ON, x[i] is added into the ith tally of this list.

Parameters:
x - the array of vectors of observations being added.
Throws:
IllegalArgumentException - if the length of x does not correspond to size(), or the length of x[i] does not correspond to the dimension of the underlying tally i, for at least one i.

add

public void add(DoubleMatrix2D x)
Equivalent to add (x.toArray()), without copying the elements of x into a temporary 2D array. This can be used only when all the function of multiple means tallies in this list share the same dimension.

Parameters:
x - the matrix of observations being added, each row corresponding to a vector added to a tally.
Throws:
IllegalArgumentException - if the number of rows in x does not correspond to size(), or the number of columns does not correspond to the dimension of the underlying tallies.

addSameDimension

public void addSameDimension(double[]... x)
For each element i of this list of tallies, adds the vector of observations x[0][i], ..., x[d-1][i]. This method can be used only when all tallies in this list share the same dimension. It creates a transposed 2D array compatible with add, and calls the latter method with this array. For example, let lt be a list of tallies whose l elements correspond to ratios. If a program can generate two arrays num and den of length l representing observations for the numerator and denominator of the ratios, respectively, the observations can be added using lt.add (num, den) instead of creating an intermediate matrix of observations.

Parameters:
x - the 2D array of observations.
Throws:
IllegalArgumentException - if the length of x does not correspond to the dimension of the tally, or the length of the arrays x[j] are not equal for all j=0,...,d-1.

addSameDimension

public void addSameDimension(DoubleMatrix1D... x)
Equivalent to addSameDimension x.toArray(), without copying the elements of x into a temporary 1D array. This can be used only when all the function of multiple means tallies in this list share the same dimension.


getDimension

public int getDimension()
Assuming that each tally in this list has the same dimension, returns the dimension of tally 0, or 0 if this list is empty.

Returns:
the dimension.

numberObs

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

areAllNumberObsEqual

public 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 the list is empty.

Returns:
the success indicator of the test.

average

public void average(double[] a)
Computes the function of averages for each tally in this list. If the tally i has no vector of observations, the Double.NaN value is stored at index i of the array a.

Overrides:
average in class ListOfStatProbes<E extends FunctionOfMultipleMeansTally>
Parameters:
a - the array to be filled with averages.

variance

public void variance(double[] v)
For each tally in this list, computes the sample variance and stores it into v. If, for some tally i, there are not enough observations for estimating the variance, Double.NaN is stored at index i of the array v.

Parameters:
v - the array to be filled with sample variances.
Throws:
NullPointerException - if v is null.
IllegalArgumentException - if v.length does not correspond to size.

standardDeviation

public void standardDeviation(double[] v)
For each tally in this list, computes the standard deviation, and stores it into v. This is equivalent to calling variance and performing a square root on every element of the filled array.

Parameters:
v - the array to be filled with standard deviations.
Throws:
NullPointerException - if v is null.
IllegalArgumentException - if v.length does not correspond to size().

clone

public ListOfFunctionOfMultipleMeansTallies<E> clone()
Clones this object. This makes a shallow copy of this list, i.e., this does not clone all the objects in the list. The created clone is modifiable, even if the original list is unmodifiable.

Overrides:
clone in class ListOfStatProbes<E extends FunctionOfMultipleMeansTally>

SSJ
V. labo.

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