SSJ
V. 2.6.

umontreal.iro.lecuyer.stat
Class TallyHistogram

java.lang.Object
  extended by umontreal.iro.lecuyer.stat.StatProbe
      extended by umontreal.iro.lecuyer.stat.Tally
          extended by umontreal.iro.lecuyer.stat.TallyHistogram
All Implemented Interfaces:
Cloneable

public class TallyHistogram
extends Tally

This class is an extension of Tally which gives a more detailed view of the observations statistics. The individual observations are assumed to fall into different bins (boxes) of equal width on an interval. The total number of observations falling into the bins are kept in an array of counters. This is useful, for example, if one wish to build a histogram from the observations. One must access the array of bin counters to compute quantities not supported by the methods in Tally.

Never add or remove observations directly on the array of bin counters because this would put the Tally counters in an inconsistent state.


Constructor Summary
TallyHistogram(double a, double b, int s)
          Constructs a TallyHistogram statistical probe.
TallyHistogram(String name, double a, double b, int s)
          Constructs a new TallyHistogram statistical probe with name name.
 
Method Summary
 void add(double x)
          Gives a new observation x to the statistical collectors.
 TallyHistogram clone()
          Clones this object and the array which stores the counters.
 double getA()
          Returns the left boundary a of interval [a, b].
 double getB()
          Returns the right boundary b of interval [a, b].
 int[] getCounters()
          Returns the bin counters.
 int getNumBins()
          Returns the number of bins s dividing the interval [a, b].
 void init(double a, double b, int s)
          Initializes this object.
 String toString()
          Returns the bin counters as a String.
 
Methods inherited from class umontreal.iro.lecuyer.stat.Tally
average, confidenceIntervalNormal, confidenceIntervalStudent, confidenceIntervalVarianceChi2, formatCINormal, formatCINormal, formatCIStudent, formatCIStudent, formatCIVarianceChi2, getConfidenceLevel, init, numberObs, report, report, reportAndCIStudent, reportAndCIStudent, setConfidenceIntervalNone, setConfidenceIntervalNormal, setConfidenceIntervalStudent, setConfidenceLevel, setShowNumberObs, shortReport, shortReportHeader, standardDeviation, variance
 
Methods inherited from class umontreal.iro.lecuyer.stat.StatProbe
addObservationListener, clearObservationListeners, getName, isBroadcasting, isCollecting, max, min, notifyListeners, removeObservationListener, report, report, setBroadcasting, setCollecting, setName, sum
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TallyHistogram

public TallyHistogram(double a,
                      double b,
                      int s)
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. 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:
a - left boundary of interval
b - right boundary of interval
s - number of bins

TallyHistogram

public TallyHistogram(String name,
                      double a,
                      double b,
                      int s)
Constructs a new TallyHistogram statistical probe with name name.

Parameters:
name - the name of the tally.
a - left boundary of interval
b - right boundary of interval
s - number of bins
Method Detail

init

public void init(double a,
                 double b,
                 int s)
Initializes this object. Divide the interval [a, b] into s bins of equal width and initializes all counters to 0.

Parameters:
s - number of bins
a - left boundary of interval
b - right boundary of interval

add

public void add(double x)
Gives a new observation x to the statistical collectors. Increases by 1 the bin counter in which value x falls. Values that fall outside the interval [a, b] are added in extra bin counter bin[0] if x < a, and in bin[s + 1] if x > b.

Overrides:
add in class Tally
Parameters:
x - observation value

getCounters

public int[] getCounters()
Returns the bin counters. Each counter contains the number of observations that fell in its corresponding bin. The counters bin[i], i = 1, 2,…, s contain the number of observations that fell in each subinterval of [a, b]. Values that fell outside the interval [a, b] were added in extra bin counter bin[0] if x < a, and in bin[s + 1] if x > b. There are thus s + 2 counters.

Returns:
the array of counters

getNumBins

public int getNumBins()
Returns the number of bins s dividing the interval [a, b]. Does not count the two extra bins for the values of x < a or x > b.

Returns:
the number of bins

getA

public double getA()
Returns the left boundary a of interval [a, b].

Returns:
left boundary of interval

getB

public double getB()
Returns the right boundary b of interval [a, b].

Returns:
right boundary of interval

clone

public TallyHistogram clone()
Clones this object and the array which stores the counters.

Overrides:
clone in class Tally

toString

public String toString()
Returns the bin counters as a String.

Overrides:
toString in class Object

SSJ
V. 2.6.

To submit a bug or ask questions, send an e-mail to Pierre L'Ecuyer.