The

`Histogram`

class accepts a stream of data and accumulates a histogram. The `XHistogram`

class uses a `Histogram`

to collect the data and an `XGraph`

to display it.`Histogram`

class accumulates data in a histogram. Its constructor is as follows:Histogram(double width = 1.0, int maxBins = HISTO_MAX_BINS);The default maximum number of bins is 1000. The bin centers will be at integer multiples of the specified bin width. The total width of the histogram depends on the data; however, there will always be a bin that includes the first point.

void add(double x);Add the point

*x*

to the histogram.int numCounts() const;Return the number of counts, the mean, and the variance of the data in the histogram.

double mean() const;

double variance() const;

int getData(int binno, int& count, double& binCenter);Get counts and bin centers by bin number, where 0 indicates the smallest bin. Return

`TRUE`

if this is a valid bin. Thus the entire histogram data can be retrieved by stepping from 0 to the first failure.`XHistogram`

object has a private `XGraph`

member and a private `Histogram`

member. The functionsint numCounts() const;simply pass through to the

double mean() const;

double variance();

`Histogram`

object, andvoid addPoint(float y);adds a point to the histogram and does other bookkeeping. There are two remaining methods:

void initialize(Block* parent, double binWidth,This method initializes the graph and histogram object.

const char* options, const char* title,

const char* saveFile, int maxBins = HISTO_MAX_BINS

*parent*

is the parent `Block`

, used for error messages. *binWidth*

and *maxBins*

initialize the `Histogram`

object. *options*

is a string that is included in the command line to the `xgraph`

program; other options, including `-bar -nl -brw`

value*,*

are passed as well. *title*

is the graph title, and *saveFile,*

if non-null, gives a file in which the histogram data is saved (this data is the histogram counts, not the data that was input with `addPoint).`

void terminate();This method completes the histogram, flushes out the temporary files, and executes

`xgraph`

.