Go to the first, previous, next, last section, table of contents.
SYNOPSIS
#include <CNCL/Histogram.h>
TYPE
CN_HISTOGRAM
BASE CLASSES
CNStatistics
DERIVED CLASSES
None
RELATED CLASSES
None
DESCRIPTION
CNHistogram
contains functions to reduce input data to a histogram.
It provides two main output formats:
Either you can create an easy readable array or you can write the results of
the evaluation to a file in a format that can further be processed by
'gnuplot'.
Constructors
CNHistogram();
-
Not yet implemented
CNHistogram(CNParam *);
-
Not yet implemented
CNHistogram(char *aName, double l_border, double u_border,
-
short int num, double normalization = 0.0,
-
char* aDescription = NIL);
-
-
Initializes
CNHistogram
.
-
The arguments are:
-
aName: Name of the histogram
-
l_border: Lower border for evaluation
-
u_border: Upper border for evaluation
-
num: Number of bins
-
normalization: The total number of entries in the histogram is
normalized to this value. The default value '0' means, that no
normalization is performed.
In addition to the member functions required by CNCL, CNHistogram
provides:
void put( double );
-
Input function of the histogram. The input value is sampled into the
histogram.
double mean() const;
-
Returns the mean value of the input sequence.
double variance() const;
-
Returns the variance of the input sequence.
long trials() const;
-
Returns the number of values sampled in the histogram.
double min() const;
-
Returns the minimum input value.
double max() const;
-
Returns the maximum input value.
boolean end() const;
-
Always returns
FALSE
as an histogram evaluation never reaches an
end.
void reset();
-
Not yet implemented, but required by base class CNStatistics. (Might be
implemented later if necessary).
Phase status() const;
-
Returns the state of evaluation. Since evaluation never reaches an end,
status only returns INITIALIZE (no value in histogram) or ITERATE.
void set_norm(double);
-
Sets normalization to new value. Does not change any internal data. Only
the representation of the output is changed. It is therefore possible to
change normalization several times during evaluation of a histogram.
void print_header (ostream &, char * = "") const;
-
Writes header of histogram including statistic informations into the
specified output stream. All lines are prefixed with the string given in
the (optional) second parameter.
void print_histo(ostream &) const;
-
Writes the histogram data into the specified output stream in a human
readable format.
void print_file(char*);
-
Creates output file and uses print_header and print_histo to fill
it.
void plot_histo(ostream &, int = 0);
-
Writes the histogram data and the header into the specified output
stream to be used as input values for gnuplot to draw the
histogram. The header is written with
print_header
prefixed with
the string "# " and therefore ignored by gnuplot.
The (optional) second parameter specifies the drawing style: default 0
means that all vertical lines are drawn to the value of the next step
(Step-histogram) a value != 0 means that all vertical lines are drawn
down to the x-axis (Box-histogram). Those output lines, that differ in
both drawing styles are either beginning with `# ' (Step-style) or with
a blank ` '(Box-style). Thus the drawing style can easily be converted
with a text editor by changing those lines appropriately. As only points
are written, the plot command in `gnuplot' has to given with the
specification with lines
.
void plot_file(char*, int);
-
Creates output file and uses plot_histo to fill it. The second
parameter specifies the drawing style used by plot_histo.
In addition the following operators are defined:
ostream &operator << (ostream &strm, const CNHistogram &obj);
-
Defines operator << to provide output of CNHistogram-objects to
ostream. The member functions print_header and print_histo are called
for 'obj'.
ostream &operator << (ostream &strm, const CNHistogram *obj);
-
Same functionality as above.
Also defined is a static member functions, that can very easily be used
to sample data from a file into a histogram
static CNHistogram * CNHistogram::fill_histo_from_file(char * infile, double lower_bound, double upper_bound, short int number_of_bins, double normalisation, short int use_data_column);
-
Data is read from file 'infile' and values from column 'use_data_column'
are sampled into the histogram newly created and returned by the
function. The other parameters correspond to those described above.
This function is used e.g. by the test program
tHistogram
.
Go to the first, previous, next, last section, table of contents.