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.

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.

init

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.

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.