A subclass of StatProbe. More...
Classes | |
| enum | CIType |
Public Member Functions | |
| Tally () | |
| Constructs a new unnamed Tally statistical probe. | |
| Tally (String name) | |
| Constructs a new Tally statistical probe with name name. | |
| void | setName (String name) |
| Set the name of this Tally to name. | |
| void | init () |
| Initializes the statistical collector. | |
| void | add (double x) |
| Gives a new observation x to the statistical collector. | |
| void | add (double[] x, int number) |
| Adds the first number observations from the array x to this probe. | |
| int | numberObs () |
| Returns the number of observations given to this probe since its last initialization. | |
| double | sum () |
| Returns the sum cumulated so far for this probe. | |
| double | average () |
| Returns the average value of the observations since the last initialization. | |
| double | variance () |
| Returns the sample variance of the observations since the last initialization. | |
| double | standardDeviation () |
| Returns the sample standard deviation of the observations since the last initialization. | |
| void | confidenceIntervalNormal (double level, double[] centerAndRadius) |
| Computes a confidence interval on the mean. | |
| void | confidenceIntervalStudent (double level, double[] centerAndRadius) |
| Computes a confidence interval on the mean. | |
| String | formatCINormal (double level, int d) |
| Similar to confidenceIntervalNormal. | |
| String | formatCINormal (double level) |
| Equivalent to formatCINormal (level, 3). | |
| String | formatCIStudent (double level, int d) |
| Similar to confidenceIntervalStudent. | |
| String | formatCIStudent (double level) |
| Equivalent to formatCIStudent (level, 3). | |
| void | confidenceIntervalVarianceChi2 (double level, double[] interval) |
| Computes a confidence interval on the variance. | |
| String | formatCIVarianceChi2 (double level, int d) |
| Similar to confidenceIntervalVarianceChi2. | |
| String | report () |
| Returns a formatted string that contains a report on this probe. | |
| String | report (double level, int d) |
| Returns a formatted string that contains a report on this probe with a confidence interval level level using \(d\) fractional decimal digits. | |
| String | shortReportHeader () |
| Returns a string containing the name of the values returned in the report strings. | |
| String | shortReport () |
| Formats and returns a short statistical report for this tally. | |
| String | reportAndCIStudent (double level, int d) |
| Returns a formatted string that contains a report on this probe (as in report ), followed by a confidence interval (as in formatCIStudent ), using \(d\) fractional decimal digits. | |
| String | reportAndCIStudent (double level) |
Same as reportAndCIStudent(level, 3). | |
| double | getConfidenceLevel () |
| Returns the level of confidence for the intervals on the mean displayed in reports. | |
| void | setConfidenceLevel (double level) |
| Sets the level of confidence for the intervals on the mean displayed in reports. | |
| void | setConfidenceIntervalNone () |
| Indicates that no confidence interval needs to be printed in reports formatted by report, and shortReport. | |
| void | setConfidenceIntervalNormal () |
| Indicates that a confidence interval on the true mean, based on the central limit theorem, needs to be included in reports formatted by report and shortReport. | |
| void | setConfidenceIntervalStudent () |
| Indicates that a confidence interval on the true mean, based on the normality assumption, needs to be included in reports formatted by report and shortReport. | |
| void | setShowNumberObs (boolean showNumObs) |
| Determines if the number of observations must be displayed in reports. | |
| Tally | clone () |
| Clones this object. | |
| Public Member Functions inherited from umontreal.ssj.stat.StatProbe | |
| String | getName () |
| Returns the name associated with this probe, or null if no name was specified upon construction. | |
| double | min () |
| Returns the smallest value taken by the variable since the last initialization of this probe. | |
| double | max () |
| Returns the largest value taken by the variable since the last initialization of this probe. | |
| boolean | isBroadcasting () |
| Determines if this statistical probe is broadcasting observations to registered observers. | |
| void | setBroadcasting (boolean b) |
| Instructs the probe to turn its broadcasting ON or OFF. | |
| boolean | isCollecting () |
| Determines if this statistical probe is collecting values. | |
| void | setCollecting (boolean b) |
| Turns ON or OFF the collection of statistical observations. | |
| void | addObservationListener (ObservationListener l) |
| Adds the observation listener l to the list of observers of this statistical probe. | |
| void | removeObservationListener (ObservationListener l) |
| Removes the observation listener l from the list of observers of this statistical probe. | |
| void | clearObservationListeners () |
| Removes all observation listeners from the list of observers of this statistical probe. | |
| void | notifyListeners (double x) |
| Notifies the observation x to all registered observers if broadcasting is ON. | |
Additional Inherited Members | |
| Static Public Member Functions inherited from umontreal.ssj.stat.StatProbe | |
| static String | report (String globalName, StatProbe[] probes) |
| Formats short reports for each statistical probe in the array probes while aligning the probes’ names. | |
| static String | report (String globalName, Iterable<? extends StatProbe > probes) |
| Equivalent to report(String,StatProbe[]), except that probes is an Iterable object instead of an array. | |
A subclass of StatProbe.
This type of statistical collector takes a sequence of real-valued observations \(X_1,X_2,X_3,…\) and can return the average, the variance, a confidence interval for the theoretical mean, etc. Each call to add provides a new observation. When the broadcasting to observers is activated, the method add will also pass this new information to its registered observers. This type of collector does not memorize the individual observations, but only their number, sum, sum of squares, maximum, and minimum. The subclass TallyStore offers a collector that memorizes the observations.
Definition at line 47 of file Tally.java.
| umontreal.ssj.stat.Tally.Tally | ( | ) |
Constructs a new unnamed Tally statistical probe.
Definition at line 66 of file Tally.java.
| umontreal.ssj.stat.Tally.Tally | ( | String | name | ) |
Constructs a new Tally statistical probe with name name.
| name | name of the tally |
Definition at line 76 of file Tally.java.
| void umontreal.ssj.stat.Tally.add | ( | double | x | ) |
Gives a new observation x to the statistical collector.
If broadcasting to observers is activated for this object, this method also transmits the new information to the registered observers by invoking the method notifyListeners.
| x | observation being added to this Tally object |
Reimplemented in umontreal.ssj.stat.HistogramOnly, umontreal.ssj.stat.TallyHistogram, and umontreal.ssj.stat.TallyStore.
Definition at line 109 of file Tally.java.
| void umontreal.ssj.stat.Tally.add | ( | double[] | x, |
| int | number ) |
Adds the first number observations from the array x to this probe.
Definition at line 131 of file Tally.java.
| double umontreal.ssj.stat.Tally.average | ( | ) |
Returns the average value of the observations since the last initialization.
Reimplemented from umontreal.ssj.stat.StatProbe.
Reimplemented in umontreal.ssj.stat.HistogramOnly.
Definition at line 155 of file Tally.java.
| Tally umontreal.ssj.stat.Tally.clone | ( | ) |
Clones this object.
Reimplemented from umontreal.ssj.stat.StatProbe.
Reimplemented in umontreal.ssj.stat.HistogramOnly, umontreal.ssj.stat.TallyHistogram, and umontreal.ssj.stat.TallyStore.
Definition at line 599 of file Tally.java.
| void umontreal.ssj.stat.Tally.confidenceIntervalNormal | ( | double | level, |
| double[] | centerAndRadius ) |
Computes a confidence interval on the mean.
Returns, in elements 0 and 1 of the array object centerAndRadius[], the center and half-length (radius) of a confidence interval on the true mean of the random variable \(X\), with confidence level level, assuming that the \(n\) observations given to this collector are independent and identically distributed (i.i.d.) copies of \(X\), and that \(n\) is large enough for the central limit theorem to hold. This confidence interval is computed based on the statistic
\[ Z = {\bar{X}_n - \mu\over{S_{n,x}/\sqrt{n}}} \]
where \(n\) is the number of observations given to this collector since its last initialization, \(\bar{X}_n =\) average() is the average of these observations, \(S_{n,x} =\) standardDeviation() is the empirical standard deviation. Under the assumption that the observations of \(X\) are i.i.d. and \(n\) is large, \(Z\) has the standard normal distribution. The confidence interval given by this method is valid only if this assumption is approximately verified.
| level | desired probability that the (random) confidence interval covers the true mean (a constant) |
| centerAndRadius | array of size 2 in which are returned the center and radius of the confidence interval, respectively |
Definition at line 221 of file Tally.java.
| void umontreal.ssj.stat.Tally.confidenceIntervalStudent | ( | double | level, |
| double[] | centerAndRadius ) |
Computes a confidence interval on the mean.
Returns, in elements 0 and 1 of the array object centerAndRadius[], the center and half-length (radius) of a confidence interval on the true mean of the random variable \(X\), with confidence level level, assuming that the observations given to this collector are independent and identically distributed (i.i.d.) copies of \(X\), and that \(X\) has the normal distribution. This confidence interval is computed based on the statistic
\[ T = {\bar{X}_n - \mu\over{S_{n,x}/\sqrt{n}}} \]
where \(n\) is the number of observations given to this collector since its last initialization, \(\bar{X}_n =\) average() is the average of these observations, \(S_{n,x} =\) standardDeviation() is the empirical standard deviation. Under the assumption that the observations of \(X\) are i.i.d. and normally distributed, \(T\) has the Student distribution with \(n-1\) degrees of freedom. The confidence interval given by this method is valid only if this assumption is approximately verified, or if \(n\) is large enough so that \(\bar{X}_n\) is approximately normally distributed.
| level | desired probability that the (random) confidence interval covers the true mean (a constant) |
| centerAndRadius | array of size 2 in which are returned the center and radius of the confidence interval, respectively |
Definition at line 254 of file Tally.java.
| void umontreal.ssj.stat.Tally.confidenceIntervalVarianceChi2 | ( | double | level, |
| double[] | interval ) |
Computes a confidence interval on the variance.
Returns, in elements 0 and 1 of array interval, the left and right boundaries
\([I_1,I_2]\) of a confidence interval on the true variance \(\sigma^2\) of the random variable \(X\), with confidence level level, assuming that the observations given to this collector are independent and identically distributed (i.i.d.) copies of \(X\), and that \(X\) has the normal distribution. This confidence interval is computed based on the statistic \( \chi^2_{n-1} = (n-1)S^2_n/\sigma^2 \) where \(n\) is the number of observations given to this collector since its last initialization, and \(S^2_n =\) variance() is the empirical variance of these observations. Under the assumption that the observations of \(X\) are i.i.d. and normally distributed, \(\chi^2_{n-1}\) has the chi-square distribution with \(n-1\) degrees of freedom. Given the level \( = 1 - \alpha\), one has \(P[\chi^2_{n-1} < x_1] = P[\chi^2_{n-1} > x_2] = \alpha/2\) and \([I_1,I_2] = [(n-1)S^2_n/x_2,\; (n-1)S^2_n/x_1]\).
| level | desired probability that the (random) confidence interval covers the true mean (a constant) |
| interval | array of size 2 in which are returned the left and right boundaries of the confidence interval, respectively |
Definition at line 357 of file Tally.java.
| String umontreal.ssj.stat.Tally.formatCINormal | ( | double | level | ) |
Equivalent to formatCINormal (level, 3).
| level | desired probability that the (random) confidence interval covers the true mean (a constant) |
Definition at line 294 of file Tally.java.
| String umontreal.ssj.stat.Tally.formatCINormal | ( | double | level, |
| int | d ) |
Similar to confidenceIntervalNormal.
Returns the confidence interval in a formatted string of the form
using \(d\) fractional decimal digits.
| level | desired probability that the (random) confidence interval covers the true mean (a constant) |
| d | number of fractional decimal digits |
Definition at line 276 of file Tally.java.
| String umontreal.ssj.stat.Tally.formatCIStudent | ( | double | level | ) |
Equivalent to formatCIStudent (level, 3).
| level | desired probability that the (random) confidence interval covers the true mean (a constant) |
Definition at line 328 of file Tally.java.
| String umontreal.ssj.stat.Tally.formatCIStudent | ( | double | level, |
| int | d ) |
Similar to confidenceIntervalStudent.
Returns the confidence interval in a formatted string of the form
using \(d\) fractional decimal digits.
| level | desired probability that the (random) confidence interval covers the true mean (a constant) |
| d | number of fractional decimal digits |
Definition at line 310 of file Tally.java.
| String umontreal.ssj.stat.Tally.formatCIVarianceChi2 | ( | double | level, |
| int | d ) |
Similar to confidenceIntervalVarianceChi2.
Returns the confidence interval in a formatted string of the form
using \(d\) fractional decimal digits.
| level | desired probability that the (random) confidence interval covers the true variance |
| d | number of fractional decimal digits |
Definition at line 381 of file Tally.java.
| double umontreal.ssj.stat.Tally.getConfidenceLevel | ( | ) |
Returns the level of confidence for the intervals on the mean displayed in reports.
The default confidence level is 0.95.
Definition at line 540 of file Tally.java.
| void umontreal.ssj.stat.Tally.init | ( | ) |
Initializes the statistical collector.
Reimplemented from umontreal.ssj.stat.StatProbe.
Reimplemented in umontreal.ssj.stat.HistogramOnly, umontreal.ssj.stat.TallyHistogram, and umontreal.ssj.stat.TallyStore.
Definition at line 91 of file Tally.java.
| int umontreal.ssj.stat.Tally.numberObs | ( | ) |
Returns the number of observations given to this probe since its last initialization.
Definition at line 143 of file Tally.java.
| String umontreal.ssj.stat.Tally.report | ( | ) |
Returns a formatted string that contains a report on this probe.
Reimplemented from umontreal.ssj.stat.StatProbe.
Reimplemented in umontreal.ssj.stat.HistogramOnly.
Definition at line 397 of file Tally.java.
| String umontreal.ssj.stat.Tally.report | ( | double | level, |
| int | d ) |
Returns a formatted string that contains a report on this probe with a confidence interval level level using \(d\) fractional decimal digits.
| level | desired probability that the confidence interval covers the true mean |
| d | number of fractional decimal digits |
Definition at line 410 of file Tally.java.
| String umontreal.ssj.stat.Tally.reportAndCIStudent | ( | double | level | ) |
Same as reportAndCIStudent(level, 3).
| level | desired probability that the (random) confidence interval covers the true mean (a constant) |
Definition at line 529 of file Tally.java.
| String umontreal.ssj.stat.Tally.reportAndCIStudent | ( | double | level, |
| int | d ) |
Returns a formatted string that contains a report on this probe (as in report ), followed by a confidence interval (as in formatCIStudent ), using \(d\) fractional decimal digits.
| level | desired probability that the (random) confidence interval covers the true mean (a constant) |
| d | number of fractional decimal digits |
Definition at line 510 of file Tally.java.
| void umontreal.ssj.stat.Tally.setConfidenceIntervalNone | ( | ) |
Indicates that no confidence interval needs to be printed in reports formatted by report, and shortReport.
This restores the default behavior of the reporting system.
Definition at line 564 of file Tally.java.
| void umontreal.ssj.stat.Tally.setConfidenceIntervalNormal | ( | ) |
Indicates that a confidence interval on the true mean, based on the central limit theorem, needs to be included in reports formatted by report and shortReport.
The confidence interval is formatted using formatCINormal.
Definition at line 573 of file Tally.java.
| void umontreal.ssj.stat.Tally.setConfidenceIntervalStudent | ( | ) |
Indicates that a confidence interval on the true mean, based on the normality assumption, needs to be included in reports formatted by report and shortReport.
The confidence interval is formatted using formatCIStudent.
Definition at line 582 of file Tally.java.
| void umontreal.ssj.stat.Tally.setConfidenceLevel | ( | double | level | ) |
Sets the level of confidence for the intervals on the mean displayed in reports.
| level | desired probability that the (random) confidence interval covers the true mean (a constant) |
Definition at line 551 of file Tally.java.
| void umontreal.ssj.stat.Tally.setName | ( | String | name | ) |
Set the name of this Tally to name.
| name | name of the tally |
Reimplemented from umontreal.ssj.stat.StatProbe.
Definition at line 87 of file Tally.java.
| void umontreal.ssj.stat.Tally.setShowNumberObs | ( | boolean | showNumObs | ) |
Determines if the number of observations must be displayed in reports.
By default, the number of observations is displayed.
| showNumObs | the value of the indicator. |
Definition at line 592 of file Tally.java.
| String umontreal.ssj.stat.Tally.shortReport | ( | ) |
Formats and returns a short statistical report for this tally.
The returned single-line report contains the minimum value, the maximum value, the average, the variance, and the standard deviation, in that order, separated by three spaces. If the number of observations is shown in the short report, a column containing the number of observations in this tally is added.
Reimplemented from umontreal.ssj.stat.StatProbe.
Reimplemented in umontreal.ssj.stat.HistogramOnly.
Definition at line 467 of file Tally.java.
| String umontreal.ssj.stat.Tally.shortReportHeader | ( | ) |
Returns a string containing the name of the values returned in the report strings.
The returned string must depend on the type of probe and on the reporting options only. It must not depend on the observations received by the probe. This can be used as header when printing several reports. For example,
System.out.println (probe1.shortReportHeader());
System.out.println (probe1.getName() + " " + probe1.shortReport());
System.out.println (probe2.getName() + " " + probe2.shortReport());
...
Alternatively, one can use report(String,StatProbe[]) to get a report with aligned probe names.
Reimplemented from umontreal.ssj.stat.StatProbe.
Reimplemented in umontreal.ssj.stat.HistogramOnly.
Definition at line 443 of file Tally.java.
| double umontreal.ssj.stat.Tally.standardDeviation | ( | ) |
Returns the sample standard deviation of the observations since the last initialization.
This returns Double.NaN if the tally contains less than two observations.
Definition at line 195 of file Tally.java.
| double umontreal.ssj.stat.Tally.sum | ( | ) |
Returns the sum cumulated so far for this probe.
The meaning of this sum depends on the subclass (e.g., Tally or
umontreal.ssj.simevents.Accumulate ). This returns 0 if the probe was not updated since the last initialization.
Reimplemented from umontreal.ssj.stat.StatProbe.
Reimplemented in umontreal.ssj.stat.HistogramOnly.
Definition at line 148 of file Tally.java.
| double umontreal.ssj.stat.Tally.variance | ( | ) |
Returns the sample variance of the observations since the last initialization.
This returns Double.NaN if the tally contains less than two observations.
Reimplemented in umontreal.ssj.stat.HistogramOnly.
Definition at line 174 of file Tally.java.