#include <chist.h>
Inheritance diagram for cLongHistogram:
cLongHistogram is derived from cEqdHistogramBase, which contains most of the functionality.
The histogram will be set up in the following way:
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 () |
|
Copy constructor.
|
|
Constructor.
|
|
Destructor.
|
|
Collects one value. Internally, the double is converted to long using floor() before everything else. Reimplemented from cDensityEstBase. |
|
Creates and returns an exact copy of this object. See cObject for more details. Reimplemented from cStdDev. |
|
Assignment is not supported by this class: this method throws a cRuntimeError when called.
|
|
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. |
|
Called internally by transform(), this method should determine and set up the histogram range.
Reimplemented from cEqdHistogramBase. |