The objects of this class are statistical probes or collectors, which are elementary devices for collecting statistics. More...
Public Member Functions | |
| abstract void | init () |
| Initializes the statistical collector. | |
| void | setName (String name) |
| Sets the name of this statistical collector to name. | |
| 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. | |
| double | sum () |
| Returns the sum cumulated so far for this probe. | |
| abstract double | average () |
| Returns the average for this collector. | |
| abstract String | report () |
| Returns a string containing a report for this statistical collector. | |
| abstract String | shortReport () |
| Formats and returns a short, one-line report about this statistical probe. | |
| abstract String | shortReportHeader () |
| Returns a string containing the name of the values returned in the report strings. | |
| 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. | |
Static Public Member Functions | |
| 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. | |
The objects of this class are statistical probes or collectors, which are elementary devices for collecting statistics.
Each probe collects statistics on a given variable. The subclasses Tally,
TallyStore, and umontreal.ssj.simevents.Accumulate (from package umontreal.ssj.simevents ) implement two kinds of probes, for the case of successive observations \(X_1,X_2,X_3,…\), and for the case of a variable whose value evolves in time, respectively.
Each instance of StatProbe contains a list of ObservationListener that can listen to individual observations. When a probe is updated, i.e., receives a new statistical observation, it broadcasts this new data to all registered observers. The broadcasting of observations to registered observers can be turned ON or OFF at any time. It is initially OFF by default and should stay OFF when there are no registered observers, to avoid unnecessary overhead.
The data collection by the statistical probe itself can also be turned ON or OFF. By default, it is initially ON. We can turn it OFF, for example, if we want to use the statistical probe only to pass data to the observers, and do not need it to store any information.
In the simplest programs, collection is ON, broadcast is OFF, and the overall stats are accessed via the methods min, max, sum, average, ... of the collector.
Definition at line 60 of file StatProbe.java.
| void umontreal.ssj.stat.StatProbe.addObservationListener | ( | ObservationListener | l | ) |
Adds the observation listener l to the list of observers of this statistical probe.
| l | the new observation listener. |
| NullPointerException | if `l` is `null`. |
Definition at line 305 of file StatProbe.java.
|
abstract |
Returns the average for this collector.
This returns Double.NaN if the probe was not updated since the last initialization.
Reimplemented in umontreal.ssj.simevents.Accumulate, umontreal.ssj.stat.FunctionOfMultipleMeansTally, umontreal.ssj.stat.HistogramOnly, and umontreal.ssj.stat.Tally.
| void umontreal.ssj.stat.StatProbe.clearObservationListeners | ( | ) |
Removes all observation listeners from the list of observers of this statistical probe.
Definition at line 326 of file StatProbe.java.
| String umontreal.ssj.stat.StatProbe.getName | ( | ) |
Returns the name associated with this probe, or null if no name was specified upon construction.
Definition at line 89 of file StatProbe.java.
|
abstract |
Initializes the statistical collector.
Reimplemented in umontreal.ssj.simevents.Accumulate, umontreal.ssj.stat.FunctionOfMultipleMeansTally, umontreal.ssj.stat.HistogramOnly, umontreal.ssj.stat.Tally, umontreal.ssj.stat.TallyHistogram, and umontreal.ssj.stat.TallyStore.
| boolean umontreal.ssj.stat.StatProbe.isBroadcasting | ( | ) |
Determines if this statistical probe is broadcasting observations to registered observers.
The default is false.
Definition at line 260 of file StatProbe.java.
| boolean umontreal.ssj.stat.StatProbe.isCollecting | ( | ) |
Determines if this statistical probe is collecting values.
The default is true.
Definition at line 282 of file StatProbe.java.
| double umontreal.ssj.stat.StatProbe.max | ( | ) |
Returns the largest value taken by the variable since the last initialization of this probe.
This returns Double.NEGATIVE_INFINITY if the probe was not updated since the last initialization.
Reimplemented in umontreal.ssj.stat.FunctionOfMultipleMeansTally.
Definition at line 111 of file StatProbe.java.
| double umontreal.ssj.stat.StatProbe.min | ( | ) |
Returns the smallest value taken by the variable since the last initialization of this probe.
This returns Double.POSITIVE_INFINITY if the probe was not updated since the last initialization.
Reimplemented in umontreal.ssj.stat.FunctionOfMultipleMeansTally.
Definition at line 100 of file StatProbe.java.
| void umontreal.ssj.stat.StatProbe.notifyListeners | ( | double | x | ) |
Notifies the observation x to all registered observers if broadcasting is ON.
Otherwise, does nothing.
Definition at line 334 of file StatProbe.java.
| void umontreal.ssj.stat.StatProbe.removeObservationListener | ( | ObservationListener | l | ) |
Removes the observation listener l from the list of observers of this statistical probe.
| l | the observation listener to be deleted. |
Definition at line 318 of file StatProbe.java.
|
abstract |
Returns a string containing a report for this statistical collector.
The contents of this report depends on the statistical probe as well as on the parameters set by the user through probe-specific methods.
Reimplemented in umontreal.ssj.simevents.Accumulate, umontreal.ssj.stat.FunctionOfMultipleMeansTally, umontreal.ssj.stat.HistogramOnly, and umontreal.ssj.stat.Tally.
|
static |
Equivalent to report(String,StatProbe[]), except that probes is an Iterable object instead of an array.
Of course, the iterator returned by probes should enumerate the statistical probes to include in the report in a consistent and sensible order.
| globalName | the global name given to the formatted report. |
| probes | the probes to include in the report. |
Definition at line 227 of file StatProbe.java.
|
static |
Formats short reports for each statistical probe in the array probes while aligning the probes’ names.
This method first formats the given global name. It then determines the maximum length
\(\ell\) of the names of probes in the given array. The first line of the report is composed of \(\ell+3\) spaces followed by the string returned by shortReportHeader called on the first probe in probes. Each remaining line corresponds to a statistical probe; it contains the probe’s name followed by the contents returned by shortReport. Note that this method assumes that probes contains no null element.
| globalName | the global name given to the formatted report. |
| probes | the probes to include in the report. |
Definition at line 191 of file StatProbe.java.
| void umontreal.ssj.stat.StatProbe.setBroadcasting | ( | boolean | b | ) |
Instructs the probe to turn its broadcasting ON or OFF.
The default value is OFF. Warning: To avoid useless overhead and performance degradation, broadcasting should never be turned ON when there are no registered observers.
| b | true to turn broadcasting ON, false to turn it OFF |
Definition at line 272 of file StatProbe.java.
| void umontreal.ssj.stat.StatProbe.setCollecting | ( | boolean | b | ) |
Turns ON or OFF the collection of statistical observations.
The default value is ON. When statistical collection is turned OFF, observations added to the probe are passed to the registered observers if broadcasting is turned ON, but are not counted as observations by the probe itself.
| b | true to activate statistical collection, false to deactivate it |
Definition at line 294 of file StatProbe.java.
| void umontreal.ssj.stat.StatProbe.setName | ( | String | name | ) |
Sets the name of this statistical collector to name.
Reimplemented in umontreal.ssj.stat.FunctionOfMultipleMeansTally, and umontreal.ssj.stat.Tally.
Definition at line 79 of file StatProbe.java.
|
abstract |
Formats and returns a short, one-line report about this statistical probe.
This line is composed of whitespace-separated fields which must correspond to the column names given by shortReportHeader(). This report should not contain any end-of-line character, and does not include the name of the probe. Its contents depends on the statistical probe as well as on the parameters set by the user through probe-specific methods.
Reimplemented in umontreal.ssj.simevents.Accumulate, umontreal.ssj.stat.FunctionOfMultipleMeansTally, umontreal.ssj.stat.HistogramOnly, and umontreal.ssj.stat.Tally.
|
abstract |
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 in umontreal.ssj.simevents.Accumulate, umontreal.ssj.stat.FunctionOfMultipleMeansTally, umontreal.ssj.stat.HistogramOnly, and umontreal.ssj.stat.Tally.
| double umontreal.ssj.stat.StatProbe.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 in umontreal.ssj.simevents.Accumulate, umontreal.ssj.stat.FunctionOfMultipleMeansTally, umontreal.ssj.stat.HistogramOnly, and umontreal.ssj.stat.Tally.
Definition at line 123 of file StatProbe.java.