SSJ  3.3.1
Stochastic Simulation in Java
Public Member Functions | Protected Attributes | List of all members
TallyHistogram Class Reference

This class extends Tally. More...

Inheritance diagram for TallyHistogram:
[legend]
Collaboration diagram for TallyHistogram:
[legend]

Public Member Functions

 TallyHistogram (double a, double b, int numBins)
 Constructs a TallyHistogram statistical probe. More...
 
 TallyHistogram (String name, double a, double b, int numBins)
 Constructs a new TallyHistogram statistical probe with name name. More...
 
void init (double a, double b, int numBins)
 Initializes this object. More...
 
void init ()
 Initializes all the counters and accumulators, including those of the Tally 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.
 
void add (double x)
 Gives a new observation \(x\) to the statistical probe. More...
 
TallyHistogram trimHistogram ()
 Remove empty bins in the tails (left and right), without changing the bin size. More...
 
TallyHistogram addHistograms (TallyHistogram other)
 Merges this histogram with the other histogram, by adding the bin counts of the two histograms. More...
 
TallyHistogram aggregateBins (int g)
 Merges bins by groups of size \(g\). More...
 
int [] getCounters ()
 Returns the array of bin counters. More...
 
int getNumBins ()
 Returns the number of bins \(s\). More...
 
double getA ()
 Returns the left boundary \(a\) of the interval \([a,b]\). More...
 
double getB ()
 Returns the right boundary \(b\) of the interval \([a,b]\). More...
 
double getH ()
 Returns the width \(h\) of the bins. More...
 
double getProportionInBoundaries ()
 Returns the proportion of the collected observations that lie within the boundaries \([a,b]\) of the histogram; that is, the number that fell within \([a,b]\) divided by the total number that were collected. More...
 
TallyHistogram clone ()
 Clones this object and the array that stores the counters.
 
String toString ()
 Returns the bin counters as a String.
 
- Public Member Functions inherited from Tally
 Tally ()
 Constructs a new unnamed Tally statistical probe.
 
 Tally (String name)
 Constructs a new Tally statistical probe with name name. More...
 
void setName (String name)
 Set the name of this Tally to name. More...
 
void init ()
 
void add (double x)
 Gives a new observation x to the statistical collector. More...
 
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. More...
 
double sum ()
 
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. More...
 
double standardDeviation ()
 Returns the sample standard deviation of the observations since the last initialization. More...
 
void confidenceIntervalNormal (double level, double[] centerAndRadius)
 Computes a confidence interval on the mean. More...
 
void confidenceIntervalStudent (double level, double[] centerAndRadius)
 Computes a confidence interval on the mean. More...
 
String formatCINormal (double level, int d)
 Similar to confidenceIntervalNormal. More...
 
String formatCINormal (double level)
 Equivalent to formatCINormal (level, 3). More...
 
String formatCIStudent (double level, int d)
 Similar to confidenceIntervalStudent. More...
 
String formatCIStudent (double level)
 Equivalent to formatCIStudent (level, 3). More...
 
void confidenceIntervalVarianceChi2 (double level, double[] interval)
 Computes a confidence interval on the variance. More...
 
String formatCIVarianceChi2 (double level, int d)
 Similar to confidenceIntervalVarianceChi2. More...
 
String report ()
 Returns a formatted string that contains a report on this probe. More...
 
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. More...
 
String shortReportHeader ()
 
String shortReport ()
 Formats and returns a short statistical report for this tally. More...
 
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. More...
 
String reportAndCIStudent (double level)
 Same as reportAndCIStudent(level, 3). More...
 
double getConfidenceLevel ()
 Returns the level of confidence for the intervals on the mean displayed in reports. More...
 
void setConfidenceLevel (double level)
 Sets the level of confidence for the intervals on the mean displayed in reports. More...
 
void setConfidenceIntervalNone ()
 Indicates that no confidence interval needs to be printed in reports formatted by report, and shortReport. More...
 
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. More...
 
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. More...
 
void setShowNumberObs (boolean showNumObs)
 Determines if the number of observations must be displayed in reports. More...
 
Tally clone ()
 Clones this object.
 
- Public Member Functions inherited from StatProbe
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. More...
 
double min ()
 Returns the smallest value taken by the variable since the last initialization of this probe. More...
 
double max ()
 Returns the largest value taken by the variable since the last initialization of this probe. More...
 
double sum ()
 Returns the sum cumulated so far for this probe. More...
 
abstract double average ()
 Returns the average for this collector. More...
 
abstract String report ()
 Returns a string containing a report for this statistical collector. More...
 
abstract String shortReport ()
 Formats and returns a short, one-line report about this statistical probe. More...
 
abstract String shortReportHeader ()
 Returns a string containing the name of the values returned in the report strings. More...
 
boolean isBroadcasting ()
 Determines if this statistical probe is broadcasting observations to registered observers. More...
 
void setBroadcasting (boolean b)
 Instructs the probe to turn its broadcasting ON or OFF. More...
 
boolean isCollecting ()
 Determines if this statistical probe is collecting values. More...
 
void setCollecting (boolean b)
 Turns ON or OFF the collection of statistical observations. More...
 
void addObservationListener (ObservationListener l)
 Adds the observation listener l to the list of observers of this statistical probe. More...
 
void removeObservationListener (ObservationListener l)
 Removes the observation listener l from the list of observers of this statistical probe. More...
 
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. More...
 
StatProbe clone () throws CloneNotSupportedException
 

Protected Attributes

int numBins
 
int [] count
 
int leftCount
 
int rightCount
 
double m_h
 
double m_a
 
double m_b
 
- Protected Attributes inherited from Tally
int numObs
 
CIType confidenceInterval = CIType.CI_NONE
 
double level = 0.95
 
int digits = 3
 
- Protected Attributes inherited from StatProbe
String name
 
double maxValue
 
double minValue
 
double sumValue
 
boolean collect = true
 
boolean broadcast = false
 
boolean showNobs = true
 

Additional Inherited Members

- Static Public Member Functions inherited from StatProbe
static String report (String globalName, StatProbe[] probes)
 Formats short reports for each statistical probe in the array probes while aligning the probes’ names. More...
 
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. More...
 

Detailed Description

This class extends Tally.

It does not store individual observations, but in addition to maintaining the counters as in Tally, it also constructs a histogram for the observations. The histogram is over a bounded interval \([a,b]\) and has a fixed number of bins of equal width, both specified by the user. The number of observations falling into each of the bins is kept in an array of counters. This array can be accessed directly by the user. Note that one should never add or remove observations directly on this array of bin counters because this would put the Tally counters in an inconsistent state. Additional variables count the number of observations falling outside the interval \([a,b]\).

Constructor & Destructor Documentation

◆ TallyHistogram() [1/2]

TallyHistogram ( double  a,
double  b,
int  numBins 
)

Constructs a TallyHistogram 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.

Parameters
aleft boundary of interval
bright boundary of interval
numBinsnumber of bins (of equal width)

◆ TallyHistogram() [2/2]

TallyHistogram ( String  name,
double  a,
double  b,
int  numBins 
)

Constructs a new TallyHistogram statistical probe with name name.

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

Member Function Documentation

◆ add()

void add ( double  x)

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

Updates are made as for the parent Tally object. Also increases by 1 the bin counter in which value \(x\) falls. Values that fall outside the interval \([a,b]\) are added to the extra bin counters.

Parameters
xobservation value

◆ addHistograms()

TallyHistogram addHistograms ( TallyHistogram  other)

Merges this histogram with the other histogram, by adding the bin counts of the two histograms.

Parameters
otherthe histogram to add

Returns the merged histogram.

◆ aggregateBins()

TallyHistogram aggregateBins ( int  g)

Merges bins by groups of size \(g\).

If there are \(m\) bins initially, the new number of bins will be \(\lceil m/g\rceil\). The last bin may regroup less than \(g\) original bins if \(m\) is not a multiple of \(g\). In this case the upper bound \(b\) is increased accordingly.

◆ getA()

double getA ( )

Returns the left boundary \(a\) of the interval \([a,b]\).

Returns
left boundary of interval

◆ getB()

double getB ( )

Returns the right boundary \(b\) of the interval \([a,b]\).

Returns
right boundary of interval

◆ getCounters()

int [] getCounters ( )

Returns the array of bin counters.

Each counter contains the number of observations that fell in its corresponding bin.

Returns
the array of bin counters

◆ getH()

double getH ( )

Returns the width \(h\) of the bins.

Returns
the width of the bins

◆ getNumBins()

int getNumBins ( )

Returns the number of bins \(s\).

Returns
the number of bins

◆ getProportionInBoundaries()

double getProportionInBoundaries ( )

Returns the proportion of the collected observations that lie within the boundaries \([a,b]\) of the histogram; that is, the number that fell within \([a,b]\) divided by the total number that were collected.

Returns
the proportion of observations that lie in the histogram.

◆ init()

void init ( double  a,
double  b,
int  numBins 
)

Initializes this object.

Divide the interval \([a,b]\) into

\(s\) bins of equal width and initializes all counters to 0.

Parameters
numBinsnumber of bins
aleft boundary of interval
bright boundary of interval

◆ trimHistogram()

TallyHistogram trimHistogram ( )

Remove empty bins in the tails (left and right), without changing the bin size.

This gives a new TallyHistogram which may have fewer bins.


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