SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
umontreal.ssj.stat.HistogramOnly Class Reference

This class is similar to TallyHistogram, except that it does not maintain the min, max, average, and variance of the observations. More...

Inheritance diagram for umontreal.ssj.stat.HistogramOnly:
umontreal.ssj.stat.TallyHistogram umontreal.ssj.stat.Tally umontreal.ssj.stat.StatProbe

Public Member Functions

 HistogramOnly (double a, double b, int s)
 Constructs a HistogramOnly statistical probe.
 HistogramOnly (String name, double a, double b, int s)
 Constructs a new HistogramOnly statistical probe with name name.
void init ()
 Initializes all the counters and accumulators, including those of the Tally object.
void add (double x)
 Gives a new observation \(x\) to the statistical collectors.
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.
HistogramOnly clone ()
 Clones this object and the array which stores the counters.
String toString ()
 Returns the bin counters as a String.
String report ()
 Returns a formatted string that contains a report on this probe.
String shortReport ()
 Formats and returns a short statistical report for this tally.
String shortReportHeader ()
 Returns a string containing the name of the values returned in the report strings.
Public Member Functions inherited from umontreal.ssj.stat.TallyHistogram
 TallyHistogram (double a, double b, int numBins)
 Constructs a TallyHistogram statistical probe.
 TallyHistogram (String name, double a, double b, int numBins)
 Constructs a new TallyHistogram statistical probe with name name.
void init (double a, double b, int numBins)
 Initializes this object.
void fillFromArray (double[] obs, int numObs)
 Fills this object from the first numObs observations in array obs.
void fillFromArray (double[] obs)
 Fills this object from the entire array obs.
void fillFromTallyStore (TallyStore ts)
 Fills this object from the observations in a TallyStore object.
TallyHistogram trimHistogram ()
 Remove empty bins in the tails (left and right), without changing the bin size.
TallyHistogram addHistograms (TallyHistogram other)
 Merges this histogram with the other histogram, by adding the bin counts of the two histograms.
TallyHistogram aggregateBins (int g)
 Merges bins by groups of size \(g\).
int[] getCounters ()
 Returns the array of bin counters.
int getNumBins ()
 Returns the number of bins \(s\).
double getA ()
 Returns the left boundary \(a\) of the interval \([a,b]\).
double getB ()
 Returns the right boundary \(b\) of the interval \([a,b]\).
double getH ()
 Returns the width \(h\) of the bins.
double getProportionInBoundaries ()
 Returns the proportion of the collected observations that lie within the boundaries.
Public Member Functions inherited from umontreal.ssj.stat.Tally
 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 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 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 (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 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.
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.

Detailed Description

This class is similar to TallyHistogram, except that it does not maintain the min, max, average, and variance of the observations.

Only the counters for the histogram are maintained. Also it does not maintain counters for virtual bins on the left and on the right to count the observations that fall outside \([a,b]\). The methods that are supposed to return these values return an error message instead. The only advantage of not maintaining these counters and values is to increase speed (slightly). We define this class as an extension of TallyHistogram to avoid duplicating code.

Definition at line 17 of file HistogramOnly.java.

Constructor & Destructor Documentation

◆ HistogramOnly() [1/2]

umontreal.ssj.stat.HistogramOnly.HistogramOnly ( double a,
double b,
int s )

Constructs a HistogramOnly statistical probe.

Divide the interval

\([a,b]\) into \(s\) bins of equal width and initializes a counter to 0 for each bin. Whenever an observation falls into a bin, the bin counter is increased by 1. There are two extra bins (and counters) that count the number of observations \(x\) that fall outside the interval \([a,b]\): one for those \(x< a\), and the other for those \(x > b\).

Parameters
aleft boundary of interval
bright boundary of interval
snumber of bins

Definition at line 32 of file HistogramOnly.java.

◆ HistogramOnly() [2/2]

umontreal.ssj.stat.HistogramOnly.HistogramOnly ( String name,
double a,
double b,
int s )

Constructs a new HistogramOnly statistical probe with name name.

Parameters
namethe name of the tally.
aleft boundary of interval
bright boundary of interval
snumber of bins

Definition at line 44 of file HistogramOnly.java.

Member Function Documentation

◆ add()

void umontreal.ssj.stat.HistogramOnly.add ( double x)

Gives a new observation \(x\) to the statistical collectors.

Increases by 1 the bin counter in which value \(x\) falls.

Parameters
xobservation value

Reimplemented from umontreal.ssj.stat.TallyHistogram.

Definition at line 62 of file HistogramOnly.java.

◆ average()

double umontreal.ssj.stat.HistogramOnly.average ( )

Returns the average value of the observations since the last initialization.

Reimplemented from umontreal.ssj.stat.Tally.

Definition at line 75 of file HistogramOnly.java.

◆ clone()

HistogramOnly umontreal.ssj.stat.HistogramOnly.clone ( )

Clones this object and the array which stores the counters.

Reimplemented from umontreal.ssj.stat.TallyHistogram.

Definition at line 89 of file HistogramOnly.java.

◆ init()

void umontreal.ssj.stat.HistogramOnly.init ( )

Initializes all the counters and accumulators, including those of the Tally object.

Reimplemented from umontreal.ssj.stat.TallyHistogram.

Definition at line 50 of file HistogramOnly.java.

◆ report()

String umontreal.ssj.stat.HistogramOnly.report ( )

Returns a formatted string that contains a report on this probe.

Returns
a statistical report formatted as a string

Reimplemented from umontreal.ssj.stat.Tally.

Definition at line 115 of file HistogramOnly.java.

◆ shortReport()

String umontreal.ssj.stat.HistogramOnly.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.

Returns
the string containing the report.

Reimplemented from umontreal.ssj.stat.Tally.

Definition at line 121 of file HistogramOnly.java.

◆ shortReportHeader()

String umontreal.ssj.stat.HistogramOnly.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.

Returns
the header string for the short reports.

Reimplemented from umontreal.ssj.stat.Tally.

Definition at line 127 of file HistogramOnly.java.

◆ sum()

double umontreal.ssj.stat.HistogramOnly.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.

Returns
the sum for this probe

Reimplemented from umontreal.ssj.stat.Tally.

Definition at line 69 of file HistogramOnly.java.

◆ toString()

String umontreal.ssj.stat.HistogramOnly.toString ( )

Returns the bin counters as a String.

Reimplemented from umontreal.ssj.stat.TallyHistogram.

Definition at line 97 of file HistogramOnly.java.

◆ variance()

double umontreal.ssj.stat.HistogramOnly.variance ( )

Returns the sample variance of the observations since the last initialization.

This returns Double.NaN if the tally contains less than two observations.

Returns
the variance of the observations

Reimplemented from umontreal.ssj.stat.Tally.

Definition at line 81 of file HistogramOnly.java.


The documentation for this class was generated from the following file: