Main Page   Modules   Class Hierarchy   Compound List   File List   Compound Members  

cDensityEstBase Class Reference

#include <cdensity.h>

Inheritance diagram for cDensityEstBase::

cStdDev cStatistic cObject cHistogramBase cKSplit cPSquare cEqdHistogramBase cVarHistogram cDoubleHistogram cLongHistogram List of all members.

Public Methods

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 (ostream &os)
virtual int netPack ()
virtual int netUnpack ()
Redefined cStatistic member functions.
virtual void collect (double val)
virtual void clearResult ()
virtual double random () const=0
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, double range_ext_fact)
virtual void setRangeAutoLower (double upper, int num_firstvals, double range_ext_fact)
virtual void setRangeAutoUpper (double lower, int num_firstvals, double range_ext_fact)
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 Methods

virtual void setupRange ()
virtual void collectTransformed (double val)=0

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
 


Constructor & Destructor Documentation

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

Copy constructor.

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

Constructor.

cDensityEstBase::~cDensityEstBase ( ) [virtual]
 

Destructor.


Member Function Documentation

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.

Reimplemented in cEqdHistogramBase, cKSplit, cPSquare, and cVarHistogram.

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.

Reimplemented in cEqdHistogramBase, cKSplit, cPSquare, and cVarHistogram.

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.

Reimplemented in cEqdHistogramBase, cKSplit, cPSquare, and cVarHistogram.

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().

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

Returns the number of histogram cells used. This method is pure virtual, implementation is provided in subclasses.

Reimplemented in cHistogramBase, cKSplit, and cPSquare.

void cDensityEstBase::clearResult ( ) [virtual]
 

Clears the results collected so far.

Reimplemented from cStdDev.

Reimplemented in cHistogramBase, and cVarHistogram.

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.

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.

Reimplemented in cEqdHistogramBase, cKSplit, cPSquare, and cVarHistogram.

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.

int cDensityEstBase::netPack ( ) [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, cLongHistogram, cDoubleHistogram, cKSplit, cPSquare, and cVarHistogram.

int cDensityEstBase::netUnpack ( ) [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, cLongHistogram, cDoubleHistogram, 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.

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

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

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.

Reimplemented in cEqdHistogramBase, cKSplit, cPSquare, and cVarHistogram.

double cDensityEstBase::random ( ) const [pure virtual]
 

Generates a random number based on the collected data. Uses the random number generator set by setGenK().

This is a pure virtual function; it must be redefined in subclasses.

Reimplemented from cStdDev.

Reimplemented in cLongHistogram, cDoubleHistogram, cKSplit, cPSquare, and cVarHistogram.

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.

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.

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.

void cDensityEstBase::setRangeAuto ( int num_firstvals,
double range_ext_fact ) [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.

void cDensityEstBase::setRangeAutoLower ( double upper,
int num_firstvals,
double range_ext_fact ) [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.

FIXME: details!

Reimplemented in cPSquare.

void cDensityEstBase::setRangeAutoUpper ( double lower,
int num_firstvals,
double range_ext_fact ) [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.

FIXME: details!

Reimplemented in cPSquare.

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, and cLongHistogram.

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.

Reimplemented in cHistogramBase, cKSplit, cPSquare, and cVarHistogram.

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

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

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

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

void cDensityEstBase::writeContents ( 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:
Generated at Mon Jun 16 23:37:32 2003 for OMNeT++ by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001