24package umontreal.ssj.stat;
26import umontreal.ssj.util.MultivariateFunction;
27import umontreal.ssj.stat.list.ListOfTalliesWithCovariance;
28import umontreal.ssj.util.PrintfFormat;
29import umontreal.ssj.probdist.NormalDist;
30import java.util.logging.Level;
31import java.util.logging.Logger;
71 private double[] temp;
72 private double[] delta;
74 private Logger log = Logger.getLogger(
"umontreal.ssj.stat");
81 protected double level = 0.95;
111 ta.setUnmodifiable();
128 throw new NullPointerException(
"The list of tallies cannot be null");
131 ta.setUnmodifiable();
192 public void add(
double... x) {
193 if (x.length != ta.size())
194 throw new IllegalArgumentException(
"Incompatible length of vectors of observations: given length is "
195 + x.length +
", but required length is " + ta.size());
207 return ta.numberObs();
219 if (temp.length != ta.size())
221 temp =
new double[ta.size()];
223 return func.evaluate(temp);
268 if (ta.numberObs() < 2) {
273 log.logp(Level.WARNING,
"FunctionOfMultipleMeansTally",
"variance",
"FunctionOfMultipleMeansTally " + name
274 +
": calling variance() with " + ta.numberObs() +
" observation");
277 if (temp.length != ta.size()) {
279 temp =
new double[ta.size()];
280 delta =
new double[ta.size()];
283 for (
int i = 0; i < delta.length; i++)
284 delta[i] = func.evaluateGradient(i, temp);
285 for (
int i = 0; i < temp.length; i++) {
287 for (
int j = 0; j < delta.length; j++)
288 temp[i] += delta[j] * ta.covariance(j, i);
291 for (
int i = 0; i < temp.length; i++)
292 sigma += temp[i] * delta[i];
295 return sigma < 0 ? 0 : sigma;
359 centerAndRadius[0] =
average();
377 double ci[] =
new double[2];
380 str.
append(
" " + (100 * level) +
"%");
381 str.
append(
" confidence interval for function of means: (");
403 str.
append(
"REPORT on Tally stat. collector ==> " + name);
410 if (confidenceInterval ==
CIType.CI_DELTA) {
427 CIType oldCIType = confidenceInterval;
428 double oldLevel = this.level;
431 confidenceInterval =
CIType.CI_DELTA;
435 confidenceInterval = oldCIType;
436 this.level = oldLevel;
454 pf.
append(-9,
"std. dev.");
457 if (confidenceInterval !=
CIType.CI_NONE)
483 if (confidenceInterval ==
CIType.CI_DELTA) {
484 double[] ci =
new double[2];
514 throw new IllegalArgumentException(
"level < 0");
516 throw new IllegalArgumentException(
"level >= 1");
526 confidenceInterval =
CIType.CI_NONE;
535 confidenceInterval =
CIType.CI_DELTA;
545 showNobs = showNumObs;
569 private void internalInit() {
571 throw new IllegalArgumentException(
"The dimension of the function must be equal to d, or equal to -1");
572 temp =
new double[ta.size()];
573 delta =
new double[ta.size()];
589 }
catch (CloneNotSupportedException cne) {
590 throw new IllegalStateException(
"CloneNotSupportedException for a class implementing Cloneable");
594 for (
int i = 0; i < ta.size(); i++) {
595 mta.ta.add(ta.get(i).clone());
598 mta.temp =
new double[ta.size()];
599 mta.delta =
new double[ta.size()];
Extends the class ContinuousDistribution for the normal distribution (e.g., tjoh95a (page 80)).
static double inverseF01(double u)
Same as inverseF(0, 1, u).
double getConfidenceLevel()
Returns the level of confidence for the intervals on the mean displayed in reports.
FunctionOfMultipleMeansTally clone()
Clones this object.
String shortReport()
Formats and returns a short statistical report for this function of multiple means tally.
void init()
Initializes the statistical collector.
FunctionOfMultipleMeansTally(MultivariateFunction func, String name, int d)
Constructs a function of multiple means tally with name name, dimension d, and function func.
String report()
Returns a string containing a formatted report on this probe.
FunctionOfMultipleMeansTally(MultivariateFunction func, int d)
Constructs a function of multiple means tally with dimension d, and function func.
int numberObs()
Returns the number of vectors of observations given to this probe since its last initialization.
void setConfidenceIntervalNone()
Indicates that no confidence interval needs to be printed in reports formatted by report,...
String reportAndCIDelta(double level, int d)
Returns a string containing a formatted report on this probe (as in report ), followed by a confidenc...
void setConfidenceIntervalDelta()
Indicates that a confidence interval on the true mean, based on the delta and central limit theorems,...
void setName(String name)
Sets the name of this statistical collector to name.
double max()
Returns Double.NaN.
String formatCIDelta(double level)
Same as formatCIDelta(level, 3).
double average()
Computes , an estimate of the function of means .
double min()
Returns Double.NaN.
void setConfidenceLevel(double level)
Sets the level of confidence for the intervals on the mean displayed in reports.
double sum()
Returns Double.NaN.
String shortReportHeader()
Returns a string containing the name of the values returned in the report strings.
void setShowNumberObs(boolean showNumObs)
Determines if the number of observations must be displayed in reports.
FunctionOfMultipleMeansTally(MultivariateFunction func, ListOfTalliesWithCovariance< Tally > ta)
Constructs a function of multiple means tally using the function func and the list of tallies ta for ...
MultivariateFunction getFunction()
Returns the function of multiple means used by this tally.
ListOfTalliesWithCovariance< Tally > getListOfTallies()
Returns the (unmodifiable) list of tallies internally used by this object.
String formatCIDelta(double level, int d)
Similar to confidenceIntervalDelta(double,double[]), but returns the confidence interval in a formatt...
int getDimension()
Returns the dimension of this tally, i.e., the size of any vector of observations.
String reportAndCIDelta(double level)
Same as reportAndCIDelta(level, 3).
void confidenceIntervalDelta(double level, double[] centerAndRadius)
Computes a confidence interval with confidence level level on.
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...
The objects of this class are statistical probes or collectors, which are elementary devices for coll...
Extends ListOfTallies to add support for the computation of the sample covariance between each pair o...
static ListOfTalliesWithCovariance< Tally > createWithTally(int size)
This factory method constructs and returns a list of tallies with size instances of umontreal....
Represents a function of multiple variables.
int getDimension()
Returns , the dimension of the function computed by this implementation.