- Main Page
- Modules
- Classes
- Files
- Directories
- Related Pages

- Class List
- Class Hierarchy
- Class Members

# cLongHistogram Class Reference
[Statistical data collection]

`#include <chist.h>`

Inheritance diagram for cLongHistogram:

List of all members.

## Detailed Description

Equidistant histogram for integers.

cLongHistogram is derived from cEqdHistogramBase, which contains most of the functionality.

The histogram will be set up in the following way:

- the cell size is - by definition - always integer.
- currently, cell boundaries are at halves (for example 9.5, 10.5); this may change in further releases.
- the number of cells is exactly num_cells, if specified using setNumCells() or as an argument to the constructor;
- if the number of cells is not specified, there will be one cell for every integer in the histogram range, but maximum 10,000 cells. Above 10,000, a >1 integer cell size will be chosen so that num_cells gets below 10,000.
- the histogram range can be specified explicitly (via setRange()), or can be determined automatically, after collecting a number of initial observations (setRangeAuto(), setRangeAutoUpper(), setRangeAutoLower()).
- the number of inition observations to collect for range determination can be set via setNumFirstVals().
- if both num_cells and a histogram range (explicit or auto) was specified, the histogram range will be inflated to be an integer multiple of num_cells (so that cell size can be integer).

Examples:

This histogram will determine the range from the first few observations, then it will try to keep maintain 1 cell for each integer value in the range. If there would be more than 10,000 cells that way, it will make 2 or 3 or 4 etc. wide cells to reduce the number of cells below 10,000.

     cLongHistogram hist("hist");

The following histogram will maintain one cell for every integer 0,1,...500.

     cLongHistogram hist("hist");
     hist.setRange(0,500);

The next one will set up 100 cells, and the range will be auto-determined from the first few observations. If the range is <100 wide, every cell will be 1 wide; with the range width in 100..200, cells will be 2 wide, etc.

     cLongHistogram hist("hist");
     hist.setNumCells(100);

If you know that the numbers will be nonnegative, but you don't know their ranges, you can use the following (which will set up 20 cells, with the range 0..20, or 0..40, or 0..60 etc, depending on the range of the initial observations):

     cLongHistogram hist("hist");
     hist.setRangeAutoUpper(0);
     hist.setNumCells(20);

## Public Member Functions
Constructors, destructor, assignment.
| cLongHistogram (const cLongHistogram &r)
| cLongHistogram (const char *name=NULL, int numcells=-1)
virtual | ~cLongHistogram ()
cLongHistogram & | operator= (const cLongHistogram &)
Redefined cObject member functions.
virtual cPolymorphic * | dup () const
Redefined member functions from cStatistic and its subclasses.
virtual void | collect (double val)
virtual double | random () const
## Protected Member Functions
virtual void | setupRange ()

## Constructor & Destructor Documentation

cLongHistogram::cLongHistogram | ( | const cLongHistogram & | r | ) | `[inline]`

| Copy constructor.

cLongHistogram::cLongHistogram | ( | const char * | name = `NULL`,
|  | int | numcells = `-1`
| ) | `[explicit]`

| Constructor.

virtual cLongHistogram::~cLongHistogram | ( |  | ) | `[virtual]`

| Destructor.

## Member Function Documentation

virtual void cLongHistogram::collect | ( | double | val | ) | `[virtual]`

| Collects one value. Internally, the double is converted to long using floor() before everything else. Reimplemented from cDensityEstBase.

virtual cPolymorphic* cLongHistogram::dup | ( |  | ) | const`[inline, virtual]`

| Creates and returns an exact copy of this object. See cObject for more details. Reimplemented from cStdDev.

cLongHistogram& cLongHistogram::operator= | ( | const cLongHistogram & |  | ) | `[inline]`

| Assignment is not supported by this class: this method throws a cRuntimeError when called.

virtual double cLongHistogram::random | ( |  | ) | const`[virtual]`

| Returns a random number based on the distribution collected. If no values have been collected, it returns 0; when in initial collection phase, it returns one of the stored observations; after the histogram has been set up, a random integer is returned. Reimplemented from cStdDev.

virtual void cLongHistogram::setupRange | ( |  | ) | `[protected, virtual]`

| Called internally by transform(), this method should determine and set up the histogram range. Reimplemented from cEqdHistogramBase.

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

- chist.h