Common base class for density estimation classes. More...
#include <cdensityestbase.h>
Classes  
struct  Cell 
Information about a cell. More...  
Public Types  
enum  
Public Member Functions  
Constructors, destructor, assignment.  
cDensityEstBase (const cDensityEstBase &other)  
cDensityEstBase (const char *name=NULL)  
virtual  ~cDensityEstBase () 
cDensityEstBase &  operator= (const cDensityEstBase &res) 
Redefined cObject member functions.  
virtual std::string  detailedInfo () const 
virtual void  parsimPack (cCommBuffer *buffer) 
virtual void  parsimUnpack (cCommBuffer *buffer) 
Redefined cStatistic member functions.  
virtual void  collect (double value) 
virtual void  collect (SimTime value) 
virtual void  merge (const cStatistic *other) 
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) 
virtual int  getNumFirstVals () const 
virtual double  getRangeExtensionFactor () const 
Transformation.  
virtual bool  isTransformed () const 
virtual void  transform ()=0 
Accessing histogram cells.  
virtual int  getNumCells () const =0 
virtual double  getBasepoint (int k) const =0 
virtual double  getCellValue (int k) const =0 
virtual double  getCellPDF (int k) const 
virtual unsigned long  getUnderflowCell () const 
virtual unsigned long  getOverflowCell () const 
virtual Cell  getCellInfo (int k) const 
Density and cumulated density approximation functions.  
virtual double  getPDF (double x) const =0 
virtual double  getCDF (double x) const =0 
Protected Member Functions  
virtual void  setupRange () 
virtual void  collectTransformed (double value)=0 
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:
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:
underflowcell ordinary cells overflowcell
... ...
 
 
rangemin rangemax
virtual void cDensityEstBase::collect  (  double  value  )  [virtual] 
Collects one value.
Before the histogram was transformed, this method simply adds the value to the table of precollected values. When the number of precollected observations 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.
Referenced by cLongHistogram::collect().
virtual void cDensityEstBase::collectTransformed  (  double  value  )  [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 cHistogram, cKSplit, cPSquare, and cVarHistogram.
virtual double cDensityEstBase::getBasepoint  (  int  k  )  const [pure virtual] 
Returns the kth cell boundary.
Legal values for k are 0 through getNumCells(), that is, there' one more basepoint than the number of cells. Basepoint(0) returns the low end of the first cell, and getBasepoint(getNumCells()) returns the high end of the last histogram cell. This method is pure virtual, implementation is provided in subclasses.
Implemented in cHistogram, cKSplit, cPSquare, and cVarHistogram.
virtual double cDensityEstBase::getCDF  (  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 cHistogram, cKSplit, cPSquare, and cVarHistogram.
virtual double cDensityEstBase::getCellPDF  (  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, getCellValue() and also this method may return zero. See transform().
virtual double cDensityEstBase::getCellValue  (  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 cHistogram, cKSplit, cPSquare, and cVarHistogram.
virtual int cDensityEstBase::getNumCells  (  )  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 int cDensityEstBase::getNumFirstVals  (  )  const [inline, virtual] 
Returns the number of values to be precollected before transformation takes place.
See transform().
virtual double cDensityEstBase::getPDF  (  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 cHistogram, cKSplit, cPSquare, and cVarHistogram.
virtual double cDensityEstBase::getRangeExtensionFactor  (  )  const [inline, virtual] 
Returns the range extension factor, used with histogram range setup.
See setRangeAuto() and transform().
virtual bool cDensityEstBase::isTransformed  (  )  const [inline, virtual] 
Returns whether the object is transformed.
See transform().
virtual void cDensityEstBase::merge  (  const cStatistic *  other  )  [virtual] 
Updates this object with data coming from another statistics object  as if this object had collected observations fed into the other object as well.
Throws an error if the other object is not a cDensityEstBase.
Reimplemented from cStdDev.
cDensityEstBase& cDensityEstBase::operator=  (  const cDensityEstBase &  res  ) 
Assignment operator.
The name member is not copied; see cNamedObject's operator=() for more details.
virtual void cDensityEstBase::parsimPack  (  cCommBuffer *  buffer  )  [virtual] 
Serializes the object into an MPI send buffer.
Used by the simulation kernel for parallel execution. See cObject for more details.
Reimplemented from cStdDev.
Reimplemented in cHistogramBase, cHistogram, cKSplit, cPSquare, and cVarHistogram.
virtual void cDensityEstBase::parsimUnpack  (  cCommBuffer *  buffer  )  [virtual] 
Deserializes the object from an MPI receive buffer Used by the simulation kernel for parallel execution.
See cObject for more details.
Reimplemented from cStdDev.
Reimplemented in cHistogramBase, cHistogram, cKSplit, cPSquare, and cVarHistogram.
virtual void cDensityEstBase::setNumFirstVals  (  int  num_firstvals  )  [virtual] 
Sets the number of values to be precollected 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 precollected 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 precollecting 100 values, the range being the range of the 100 precollected 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 precollected 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 precollected values.
The upper bound is calculated by extending the range (lower, maximum of observations) range_ext_fact times.
Reimplemented in cPSquare.
virtual void cDensityEstBase::transform  (  )  [pure virtual] 
Transforms the table of precollected 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.