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

- Class List
- Class Hierarchy
- Class Members

# cDensityEstBase Class Reference
[Statistical data collection]

`#include <cdensity.h>`

Inheritance diagram for cDensityEstBase:

List of all members.

## Detailed Description

Common base class for density estimation classes.

Provides several pure virtual functions, so it is an abstract class, no instances can be created.

For the histogram classes, you need to specify the number of cells and the range. Range can either be set explicitly or you can choose automatic range determination.

Automatic range estimation works in the following way:

1. The first num_firstvals observations are stored.
2. After having collected a given number of samples, the actual histogram is set up. The range (min, max) of the initial values is expanded range_ext_factor times, and the result will become the histogram's range (rangemin, rangemax). Based on the range, the cells are layed out. Then the initial values that have been stored up to this point will be transferred into the new histogram structure and their store is deleted -- this is done by the transform() function.

You may also explicitly specify the lower or upper limit and have the other end of the range estimated automatically. The setRange...() member functions of cDensityEstBase deal with setting up the histogram range. It also provides pure virtual functions transform() etc.

Subsequent observations are placed in the histogram structure. If an observation falls out of the histogram range, the underflow or the overflow cell is incremented.

layout of the histogram:

            underflow-cell   ordinary cells          overflow-cell
           ...----------|----|----|----|----|----|----|--------- ...
                        |                             |
                        |                             |
                    rangemin                       rangemax

## Public Member Functions
Constructors, destructor, assignment.
| cDensityEstBase (const cDensityEstBase &r)
| cDensityEstBase (const char *name=NULL)
virtual | ~cDensityEstBase ()
cDensityEstBase & | operator= (const cDensityEstBase &res)
Redefined cObject member functions.
virtual void | writeContents (std::ostream &os)
virtual void | netPack (cCommBuffer *buffer)
virtual void | netUnpack (cCommBuffer *buffer)
Redefined cStatistic member functions.
virtual void | collect (double val)
virtual void | clearResult ()
virtual void | saveToFile (FILE *) const
virtual void | loadFromFile (FILE *)
Selecting the method of setting up the histogram range.
virtual void | setRange (double lower, double upper)
virtual void | setRangeAuto (int num_firstvals=100, double range_ext_fact=2.0)
virtual void | setRangeAutoLower (double upper, int num_firstvals=100, double range_ext_fact=2.0)
virtual void | setRangeAutoUpper (double lower, int num_firstvals=100, double range_ext_fact=2.0)
virtual void | setNumFirstVals (int num_firstvals)
Transformation.
virtual bool | transformed () const
virtual void | transform ()=0
Accessing histogram cells.
virtual int | cells () const =0
virtual double | basepoint (int k) const =0
virtual double | cell (int k) const =0
virtual double | cellPDF (int k) const
virtual unsigned long | underflowCell () const
virtual unsigned long | overflowCell () const
Density and cumulated density approximation functions.
virtual double | pdf (double x) const =0
virtual double | cdf (double x) const =0
## Protected Member Functions
virtual void | setupRange ()
virtual void | collectTransformed (double val)=0

## Constructor & Destructor Documentation

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

| Copy constructor.

cDensityEstBase::cDensityEstBase | ( | const char * | name = `NULL` | ) | `[explicit]`

| Constructor.

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

| Destructor.

## Member Function Documentation

virtual double cDensityEstBase::basepoint | ( | int | k | ) | const`[pure virtual]`

| Returns the kth cell boundary. Legal values for k are 0 through cells(), that is, there' one more basepoint than the number of cells. Basepoint(0) returns the low end of the first cell, and basepoint(cells()) returns the high end of the last histogram cell. This method is pure virtual, implementation is provided in subclasses. Implemented in cEqdHistogramBase, cKSplit, cPSquare, and cVarHistogram.

virtual double cDensityEstBase::cdf | ( | double | x | ) | const`[pure virtual]`

| Returns the estimated value of the Cumulated Density Function at a given x. This is a pure virtual function, implementation is provided in subclasses implementing concrete histogram types. Implemented in cEqdHistogramBase, cKSplit, cPSquare, and cVarHistogram.

virtual double cDensityEstBase::cell | ( | int | k | ) | const`[pure virtual]`

| Returns the number of observations that fell into the kth histogram cell. Before transformation, this method may return zero. See transform(). This method is pure virtual, implementation is provided in subclasses. Implemented in cEqdHistogramBase, cKSplit, cPSquare, and cVarHistogram.

virtual double cDensityEstBase::cellPDF | ( | int | k | ) | const`[virtual]`

| Returns the estimated value of the Probability Density Function within the kth cell. This method simply divides the number of observations in cell k with the cell size and the number of total observations collected. Note that before transformation, cell() and also this method may return zero. See transform().

virtual int cDensityEstBase::cells | ( |  | ) | const`[pure virtual]`

| Returns the number of histogram cells used. This method is pure virtual, implementation is provided in subclasses. Implemented in cHistogramBase, cKSplit, and cPSquare.

virtual void cDensityEstBase::clearResult | ( |  | ) | `[virtual]`

| Clears the results collected so far. Reimplemented from cStdDev. Reimplemented in cHistogramBase, and cVarHistogram.

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

| Collects one value. Before the histogram was transformed, this method simply adds the value to the table of pre-collected values. When the number of pre-collected samples reaches a limit, the transform() method is called. After transformation, it calls collectTransformed() to update the stored statistics with this value. Reimplemented from cStdDev. Reimplemented in cLongHistogram.

virtual void cDensityEstBase::collectTransformed | ( | double | val | ) | `[protected, pure virtual]`

| Called internally by collect(), this method collects a value after the histogram has been transformed. Updating the underflow/overflow cells must be handled within this function. This is a pure virtual function; it must be redefined in subclasses. Implemented in cEqdHistogramBase, cKSplit, cPSquare, and cVarHistogram.

virtual void cDensityEstBase::loadFromFile | ( | FILE * |  | ) | `[virtual]`

| Reads the object data from a file, in the format written out by saveToFile(). Reimplemented from cStdDev. Reimplemented in cHistogramBase, cEqdHistogramBase, cKSplit, cPSquare, and cVarHistogram.

virtual void cDensityEstBase::netPack | ( | cCommBuffer * | buffer | ) | `[virtual]`

| Serializes the object into a PVM or MPI send buffer. Used by the simulation kernel for parallel execution. See cObject for more details. Reimplemented from cStdDev. Reimplemented in cHistogramBase, cEqdHistogramBase, cKSplit, cPSquare, and cVarHistogram.

virtual void cDensityEstBase::netUnpack | ( | cCommBuffer * | buffer | ) | `[virtual]`

| Deserializes the object from a PVM or MPI receive buffer Used by the simulation kernel for parallel execution. See cObject for more details. Reimplemented from cStdDev. Reimplemented in cHistogramBase, cEqdHistogramBase, cKSplit, cPSquare, and cVarHistogram.

cDensityEstBase& cDensityEstBase::operator= | ( | const cDensityEstBase & | res | ) |

| Assignment operator. The name member doesn't get copied; see cObject's operator=() for more details.

virtual unsigned long cDensityEstBase::overflowCell | ( |  | ) | const`[inline, virtual]`

| Returns number of observations that, being too large, fell out of the histogram range.

virtual double cDensityEstBase::pdf | ( | double | x | ) | const`[pure virtual]`

| Returns the estimated value of the Probability Density Function at a given x. This is a pure virtual function, implementation is provided in subclasses implementing concrete histogram types. Implemented in cEqdHistogramBase, cKSplit, cPSquare, and cVarHistogram.

virtual void cDensityEstBase::saveToFile | ( | FILE * |  | ) | const`[virtual]`

| Writes the contents of the object into a text file. Reimplemented from cStdDev. Reimplemented in cHistogramBase, cEqdHistogramBase, cKSplit, cPSquare, and cVarHistogram.

virtual void cDensityEstBase::setNumFirstVals | ( | int | num_firstvals | ) | `[virtual]`

| Sets the number of values to be pre-collected before transformation takes place. See transform(). Reimplemented in cPSquare.

virtual void cDensityEstBase::setRange | ( | double | lower,
|  | double | upper
| ) | `[virtual]`

| Sets the histogram range explicitly to [lower, upper]. When this method is used, setNumFirstVals() is not needed. Reimplemented in cPSquare.

virtual void cDensityEstBase::setRangeAuto | ( | int | num_firstvals = `100`,
|  | double | range_ext_fact = `2.0`
| ) | `[virtual]`

| Selects a histogram range setup method where the range will be determined entirely from a set of pre-collected values. When called, the histogram range will be determined from the first num_firstvals values, extending their range symmetrically by range_ext_fact. For example, after a call to setRangeAuto(100, 1.3), the histogram will be set up after pre-collecting 100 values, the range being the range of the 100 pre-collected values extended 1.3 times symmetrically. Reimplemented in cPSquare.

virtual void cDensityEstBase::setRangeAutoLower | ( | double | upper,
|  | int | num_firstvals = `100`,
|  | double | range_ext_fact = `2.0`
| ) | `[virtual]`

| Selects a histogram range setup method where the upper bound of the range is fixed and the lower bound is determined from a set of pre-collected values. The lower bound is calculated by extending the range (minimum of observations, upper) range_ext_fact times. Reimplemented in cPSquare.

virtual void cDensityEstBase::setRangeAutoUpper | ( | double | lower,
|  | int | num_firstvals = `100`,
|  | double | range_ext_fact = `2.0`
| ) | `[virtual]`

| Selects a histogram range setup method where the lower bound of the range is fixed and the upper bound is determined from a set of pre-collected values. The upper bound is calculated by extending the range (lower, maximum of observations) range_ext_fact times. Reimplemented in cPSquare.

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

| Called internally by transform(), this method should determine and set up the histogram range, based on the pre-collected data and the range setup method selected by calls to the setRange(), setRangeAuto(), setRangeAutoLower(), setRangeAutoUpper() methods. Reimplemented in cEqdHistogramBase, cLongHistogram, and cDoubleHistogram.

virtual void cDensityEstBase::transform | ( |  | ) | `[pure virtual]`

| Transforms the table of pre-collected values into an internal histogram structure. This is a pure virtual function. Implementations of transform() are expected to call setupRange(), and set the transfd flag when transformation was successfully done. Implemented in cHistogramBase, cKSplit, cPSquare, and cVarHistogram.

virtual bool cDensityEstBase::transformed | ( |  | ) | const`[inline, virtual]`

| Returns whether the object is transformed. See transform().

virtual unsigned long cDensityEstBase::underflowCell | ( |  | ) | const`[inline, virtual]`

| Returns number of observations that, being too small, fell out of the histogram range.

virtual void cDensityEstBase::writeContents | ( | std::ostream & | os | ) | `[virtual]`

| Writes textual information about this object to the stream. See cObject for more details. Reimplemented from cStdDev. Reimplemented in cKSplit, and cPSquare.

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

- cdensity.h