SSJ
V. labo.

umontreal.iro.lecuyer.stat.matrix
Class MatrixOfFunctionOfMultipleMeansTallies<E extends FunctionOfMultipleMeansTally>

java.lang.Object
  extended by umontreal.iro.lecuyer.stat.matrix.MatrixOfStatProbes<E>
      extended by umontreal.iro.lecuyer.stat.matrix.MatrixOfFunctionOfMultipleMeansTallies<E>
All Implemented Interfaces:
Cloneable, Iterable<E>

public class MatrixOfFunctionOfMultipleMeansTallies<E extends FunctionOfMultipleMeansTally>
extends MatrixOfStatProbes<E>

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


Constructor Summary
MatrixOfFunctionOfMultipleMeansTallies(int numRows, int numColumns)
          Constructs a new unnamed matrix of function of multiple means tallies with numRows rows, and numColumns columns, and filled with null references.
MatrixOfFunctionOfMultipleMeansTallies(String name, int numRows, int numColumns)
          Constructs a new empty matrix of function of multiple means tallies with name name, numRows rows, and numColumns columns, and filled with null references.
 
Method Summary
 void add(double[][][] x)
          For each function of multiple means tally with row index r and column index c, adds the vector of observations x[r][c] if collecting is turned ON.
 void add(cern.colt.matrix.DoubleMatrix3D x)
          Equivalent to add (x.toArray()), without copying the elements of x into a temporary 3D array.
 void addSameDimension(cern.colt.matrix.DoubleMatrix2D... x)
          For each element (r, c) of this matrix of tallies, adds the vector of observations x[0].get (r, c), ..., x[d-1].get (r, c).
 boolean areAllNumberObsEqual()
          Tests that every tally in this matrix contains the same number of observations.
 void average(cern.colt.matrix.DoubleMatrix2D m)
          Computes the average for each function of multiple means tally in the matrix.
 MatrixOfFunctionOfMultipleMeansTallies<E> clone()
          Clones this object.
static MatrixOfFunctionOfMultipleMeansTallies<FunctionOfMultipleMeansTally> create(MultivariateFunction func, int d, int numRows, int numColumns)
          This factory method constructs and returns a matrix of function of multiple means tallies with numRows rows, numColumns columns, and filled with instances of
FunctionOfMultipleMeansTally.
 int getDimension()
          Assuming that each tally in this matrix has the same dimension, returns the dimension of tally (0, 0), or 0 if the matrix has no row or column.
 int numberObs()
          Assuming that each tally in this matrix contains the same number of observations, returns the number of observations in tally (0, 0), or 0 if the matrix has no row or column.
 void standardDeviation(cern.colt.matrix.DoubleMatrix2D m)
          For each tally in the matrix, computes the standard deviation, and stores it into the matrix m.
 void variance(cern.colt.matrix.DoubleMatrix2D m)
          For each tally in the matrix, computes the sample variance, and stores it into the given matrix.
 
Methods inherited from class umontreal.iro.lecuyer.stat.matrix.MatrixOfStatProbes
addMatrixOfObservationListener, clearMatrixOfObservationListeners, columnReport, columns, get, getName, init, isBroadcasting, isCollecting, iterator, notifyListeners, removeMatrixOfObservationListener, rowReport, rows, set, setBroadcasting, setCollecting, setColumns, setName, setRows, sum, viewColumn, viewRow
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MatrixOfFunctionOfMultipleMeansTallies

public MatrixOfFunctionOfMultipleMeansTallies(int numRows,
                                              int numColumns)
Constructs a new unnamed matrix of function of multiple means tallies with numRows rows, and numColumns columns, and filled with null references.

Parameters:
numRows - the number of rows in the matrix.
numColumns - the number of columns in the matrix.
Throws:
NegativeArraySizeException - if numRows or numColumns are negative.

MatrixOfFunctionOfMultipleMeansTallies

public MatrixOfFunctionOfMultipleMeansTallies(String name,
                                              int numRows,
                                              int numColumns)
Constructs a new empty matrix of function of multiple means tallies with name name, numRows rows, and numColumns columns, and filled with null references.

Parameters:
name - the global name of the matrix.
numRows - the number of rows in the matrix.
numColumns - the number of columns in the matrix.
Throws:
NegativeArraySizeException - if numRows or numColumns are negative.
Method Detail

create

public static MatrixOfFunctionOfMultipleMeansTallies<FunctionOfMultipleMeansTally> create(MultivariateFunction func,
                                                                                          int d,
                                                                                          int numRows,
                                                                                          int numColumns)
This factory method constructs and returns a matrix of function of multiple means tallies with numRows rows, numColumns columns, and filled with 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.
numRows - the number of rows in the matrix.
numColumns - the number of columns in the matrix.
Returns:
the created matrix.

add

public void add(double[][][] x)
For each function of multiple means tally with row index r and column index c, adds the vector of observations x[r][c] if collecting is turned ON.

Parameters:
x - the vectors of observations to be added.
Throws:
IllegalArgumentException - if the dimensions of x, x[r], or x[r][c] are incorrect.

add

public void add(cern.colt.matrix.DoubleMatrix3D x)
Equivalent to add (x.toArray()), without copying the elements of x into a temporary 3D array. Each slice of the 3D matrix x corresponds to a row of the matrix of probes. Each row of the 3D matrix corresponds to a column of the matrix of probes. Each column of the 3D matrix corresponds to a component of a vector of observations added to a function of multiple means tally. This can be used only when all the function of multiple means tallies in the array share the same dimension.

Parameters:
x - the matrix of observations.
Throws:
IllegalArgumentException - if the dimensions of the matrix are incorrect.

addSameDimension

public void addSameDimension(cern.colt.matrix.DoubleMatrix2D... x)
For each element (r, c) of this matrix of tallies, adds the vector of observations x[0].get (r, c), ..., x[d-1].get (r, c). This method can be used only when all tallies in this matrix share the same dimension. It creates a transposed 3D array compatible with add, and calls the latter method with this array. For example, let mt be a matrix of tallies with dimensions r×c whose l = rc elements correspond to ratios. If a program can generate two matrices num and den of dimensions r×c representing observations for the numerator and denominator of the ratios, respectively, the observations can be added using mt.add (num, den) instead of creating an intermediate 3D array of observations.

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

getDimension

public int getDimension()
Assuming that each tally in this matrix has the same dimension, returns the dimension of tally (0, 0), or 0 if the matrix has no row or column.

Returns:
the dimension.

numberObs

public int numberObs()
Assuming that each tally in this matrix contains the same number of observations, returns the number of observations in tally (0, 0), or 0 if the matrix has no row or column.

Returns:
the number of observations.

areAllNumberObsEqual

public boolean areAllNumberObsEqual()
Tests that every tally in this matrix contains the same number of observations. This returns true if and only if the matrix has no row and no column, or if all tallies have the same number of observations.

Returns:
the success indicator of the test.

average

public void average(cern.colt.matrix.DoubleMatrix2D m)
Computes the average for each function of multiple means tally in the matrix. If the tally (r, c) has no observation, the Double.NaN value is stored in the given matrix, at row r, column c.

Overrides:
average in class MatrixOfStatProbes<E extends FunctionOfMultipleMeansTally>
Parameters:
m - the matrix to be filled with averages.

variance

public void variance(cern.colt.matrix.DoubleMatrix2D m)
For each tally in the matrix, computes the sample variance, and stores it into the given matrix. If, for some tally (r, c), there are not enough observations for estimating the variance, Double.NaN is stored in the corresponding element of the given matrix m.

Parameters:
m - the matrix to be filled with sample variances.
Throws:
NullPointerException - if m is null.
IllegalArgumentException - if m.rows() does not correspond to rows, or m.columns() does not correspond to columns.

standardDeviation

public void standardDeviation(cern.colt.matrix.DoubleMatrix2D m)
For each tally in the matrix, computes the standard deviation, and stores it into the matrix m. This is equivalent to calling variance and performing a square root on every element of the filled matrix.

Parameters:
m - the matrix to be filled with standard deviations.
Throws:
NullPointerException - if m is null.
IllegalArgumentException - if m.rows() does not correspond to rows, or m.columns() does not correspond to columns.

clone

public MatrixOfFunctionOfMultipleMeansTallies<E> clone()
Clones this object. Makes a shallow copy of this matrix, i.e., does not clone all the probes in the matrix.

Overrides:
clone in class MatrixOfStatProbes<E extends FunctionOfMultipleMeansTally>

SSJ
V. labo.

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