24package umontreal.ssj.stat.matrix;
26import umontreal.ssj.stat.Tally;
27import umontreal.ssj.stat.TallyStore;
28import cern.colt.matrix.DoubleMatrix2D;
29import umontreal.ssj.util.PrintfFormat;
30import cern.colt.list.DoubleArrayList;
31import cern.colt.matrix.impl.DenseDoubleMatrix2D;
32import umontreal.ssj.stat.list.ListOfTallies;
55 super(numRows, numColumns);
69 super(name, numRows, numColumns);
83 for (
int r = 0; r < numRows; r++)
84 for (
int c = 0; c < numColumns; c++)
100 for (
int r = 0; r < numRows; r++)
101 for (
int c = 0; c < numColumns; c++)
122 public void add(DoubleMatrix2D x) {
126 throw new IllegalArgumentException(
"Incompatible matrix dimensions: given " + x.rows() +
"x" + x.columns()
129 for (
int r = 0; r <
rows; r++)
130 for (
int c = 0; c <
columns; c++) {
131 double v = x.getQuick(r, c);
132 Tally ta =
get(r, c);
133 if (!Double.isNaN(v) && ta !=
null)
142 public void add(
double[][] x) {
145 if (x.length !=
rows)
146 throw new IllegalArgumentException(
"Incompatible number of rows: given " + x.length +
", required " +
rows);
148 for (
int r = 0; r <
rows; r++) {
150 throw new IllegalArgumentException(
"Incompatible number of columns in row " + r +
": given "
151 + x[r].length +
", but required " +
columns);
152 for (
int c = 0; c <
columns; c++) {
154 Tally ta =
get(r, c);
155 if (!Double.isNaN(v) && ta !=
null)
172 Tally t0 =
get(0, 0);
184 final int nr =
rows();
187 for (
int r = 0; r < nr; r++)
188 for (
int c = 0; c < nc; c++) {
202 for (
int i = 0; i < m.rows(); i++)
203 for (
int j = 0; j < m.columns(); j++) {
204 Tally ta =
get(i, j);
228 if (m.rows() !=
rows())
229 throw new IllegalArgumentException(
230 "Invalid number of rows in the given matrix: required " +
rows() +
" but found " + m.rows());
232 throw new IllegalArgumentException(
233 "Invalid number of columns in the given matrix: required " +
columns() +
" but found " + m.columns());
234 for (
int r = 0; r <
rows(); r++)
235 for (
int c = 0; c <
columns(); c++) {
236 Tally tally =
get(r, c);
237 m.setQuick(r, c, tally !=
null && tally.
numberObs() >= 2 ? tally.
variance() : Double.NaN);
255 if (m.rows() !=
rows())
256 throw new IllegalArgumentException(
257 "Invalid number of rows in the given matrix: required " +
rows() +
" but found " + m.rows());
259 throw new IllegalArgumentException(
260 "Invalid number of columns in the given matrix: required " +
columns() +
" but found " + m.columns());
261 for (
int r = 0; r <
rows(); r++)
262 for (
int c = 0; c <
columns(); c++) {
263 Tally tally =
get(r, c);
This class is a variant of Tally for which the individual observations are stored in a list implement...
double standardDeviation()
Returns the sample standard deviation of the observations since the last initialization.
double average()
Returns the average value of the observations since the last initialization.
int numberObs()
Returns the number of observations given to this probe since its last initialization.
double variance()
Returns the sample variance of the observations since the last initialization.
void add(double x)
Gives a new observation x to the statistical collector.
MatrixOfStatProbes(int numRows, int numColumns)
void notifyListeners(DoubleMatrix2D x)
void standardDeviation(DoubleMatrix2D m)
For each tally in the matrix, computes the standard deviation, and stores it into the given matrix.
void add(DoubleMatrix2D x)
Adds the observation x.get(r, c) in the tally whose row is r and column is c, for r = 0,...
boolean areAllNumberObsEqual()
Tests that every tally in this matrix contains the same number of observations.
MatrixOfTallies(int numRows, int numColumns)
Constructs a new unnamed matrix of tallies with numRows rows, and numColumns columns,...
static MatrixOfTallies< Tally > createWithTally(int numRows, int numColumns)
This factory method constructs and returns a matrix of tallies with numRows rows, numColumns columns,...
MatrixOfTallies(String name, int numRows, int numColumns)
Constructs a new matrix of tallies with name name, numRows rows, and numColumns columns,...
int numberObs()
Assuming that each tally in this matrix contains the same number of observations, returns the number ...
static MatrixOfTallies< TallyStore > createWithTallyStore(int numRows, int numColumns)
This factory method constructs and returns a matrix of tallies with numRows rows, numColumns columns,...
void average(DoubleMatrix2D m)
Computes the average for each tally in the matrix.
void add(double[][] x)
Same as add(DoubleMatrix2D) for a 2D array.
MatrixOfTallies< E > clone()
Clones this object.
void variance(DoubleMatrix2D m)
For each tally in the matrix, computes the sample variance, and stores it into the given matrix.
Provides facilities to construct and manage rectangular 2D arrays of statistical probes.