24package umontreal.ssj.stat.matrix;
26import umontreal.ssj.stat.FunctionOfMultipleMeansTally;
27import umontreal.ssj.util.MultivariateFunction;
28import cern.colt.matrix.DoubleMatrix2D;
29import cern.colt.matrix.DoubleMatrix3D;
30import umontreal.ssj.stat.Tally;
31import umontreal.ssj.stat.list.ListOfFunctionOfMultipleMeansTallies;
32import umontreal.ssj.stat.list.ListOfTallies;
33import umontreal.ssj.util.PrintfFormat;
60 super(numRows, numColumns);
75 super(name, numRows, numColumns);
92 int d,
int numRows,
int numColumns) {
95 for (
int r = 0; r < numRows; r++)
96 for (
int c = 0; c < numColumns; c++)
110 public void add(
double[][][] x) {
111 if (x.length !=
rows())
112 throw new IllegalArgumentException(
113 "The length of the given array must " +
"correspond to the number of rows in the matrix");
115 for (
int i = 0; i < x.length; i++) {
117 throw new IllegalArgumentException(
118 "The length of the array x[" + i +
"] must correspond to the number of columns in the matrix");
119 for (
int j = 0; j < x[i].length; j++)
120 get(i, j).add(x[i][j]);
137 public void add(DoubleMatrix3D x) {
138 if (x.rows() !=
rows())
139 throw new IllegalArgumentException(
"The number of rows of the given matrix must "
140 +
"correspond to the number of rows in the matrix of probes");
142 throw new IllegalArgumentException(
"The number of columns of the given matrix must "
143 +
"correspond to the number of columns in the matrix of probes");
145 for (
int i = 0; i <
rows(); i++)
146 for (
int j = 0; j < x.columns(); j++)
147 get(i, j).add(x.viewSlice(i).viewRow(j).toArray());
171 final int nr =
rows();
176 throw new IllegalArgumentException(
177 "The length of the given array must be " + d +
" while its actual length is " + x.length);
179 if (x.length == 0 || nr == 0 || nc == 0)
183 throw new IllegalArgumentException(
"The given matrices must have the same dimensions");
185 for (
int i = 0; i < x.length - 1; i++)
187 throw new IllegalArgumentException(
"The given arrays must have the same length");
189 if ((temp ==
null) || (temp.length != nr) || (temp[0].length != nc) || (temp[0][0].length != d))
190 temp =
new double[nr][nc][d];
192 for (
int r = 0; r < nr; r++)
193 for (
int c = 0; c < nc; c++)
194 for (
int j = 0; j < d; j++)
195 temp[r][c][j] = x[j].getQuick(r, c);
234 final int nr =
rows();
237 for (
int r = 0; r < nr; r++)
238 for (
int c = 0; c < nc; c++) {
253 for (
int i = 0; i < m.rows(); i++)
254 for (
int j = 0; j < m.columns(); j++)
255 if (!Double.isNaN(m.getQuick(i, j)) &&
get(i, j).numberObs() == 0)
256 m.setQuick(i, j, Double.NaN);
273 if (m.rows() !=
rows())
274 throw new IllegalArgumentException(
275 "Invalid number of rows in the given matrix: required " +
rows() +
" but found " + m.rows());
277 throw new IllegalArgumentException(
278 "Invalid number of columns in the given matrix: required " +
columns() +
" but found " + m.columns());
279 for (
int r = 0; r <
rows(); r++)
280 for (
int c = 0; c <
columns(); c++) {
282 m.setQuick(r, c, tally !=
null && tally.
numberObs() >= 2 ? tally.
variance() : Double.NaN);
299 if (m.rows() !=
rows())
300 throw new IllegalArgumentException(
301 "Invalid number of rows in the given matrix: required " +
rows() +
" but found " + m.rows());
303 throw new IllegalArgumentException(
304 "Invalid number of columns in the given matrix: required " +
columns() +
" but found " + m.columns());
305 for (
int r = 0; r <
rows(); r++)
306 for (
int c = 0; c <
columns(); c++) {
319 clone.temp =
new double[temp.length][temp[0].length][temp[0].length];
320 for (
int i = 0; i < temp.length; i++)
321 for (
int j = 0; j < temp[i].length; i++)
322 for (
int k = 0; k < temp[i][j].length; k++)
323 clone.temp[i][j][k] = temp[i][j][k];
Represents a statistical collector for estimating a function of multiple means with a confidence inte...
int numberObs()
Returns the number of vectors of observations given to this probe since its last initialization.
int getDimension()
Returns the dimension of this tally, i.e., the size of any vector of observations.
double standardDeviation()
Returns the square root of variance.
double variance()
Estimates where is the number of vectors of observations given to this collector since the last ini...
int getDimension()
Assuming that each tally in this matrix has the same dimension, returns the dimension of tally (0,...
void addSameDimension(DoubleMatrix2D... x)
For each element (r, c) of this matrix of tallies, adds the vector of observations x[0]....
void add(DoubleMatrix3D x)
Equivalent to add(x.toArray()), without copying the elements of x into a temporary 3D array.
void average(DoubleMatrix2D m)
Computes the average for each function of multiple means tally in the matrix.
MatrixOfFunctionOfMultipleMeansTallies< E > clone()
Clones this object.
MatrixOfFunctionOfMultipleMeansTallies(int numRows, int numColumns)
Constructs a new unnamed matrix of function of multiple means tallies with numRows rows,...
void add(double[][][] x)
For each function of multiple means tally with row index r and column index c, adds the vector of o...
void variance(DoubleMatrix2D m)
For each tally in the matrix, computes the sample variance, and stores it into the given matrix.
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 numRow...
void standardDeviation(DoubleMatrix2D m)
For each tally in the matrix, computes the standard deviation, and stores it into the matrix m.
boolean areAllNumberObsEqual()
Tests that every tally in this matrix contains the same number of observations.
int numberObs()
Assuming that each tally in this matrix contains the same number of observations, returns the number ...
MatrixOfFunctionOfMultipleMeansTallies(String name, int numRows, int numColumns)
Constructs a new empty matrix of function of multiple means tallies with name name,...
MatrixOfStatProbes(int numRows, int numColumns)
Represents a function of multiple variables.
Provides facilities to construct and manage rectangular 2D arrays of statistical probes.