Main Page   Modules   Class Hierarchy   Compound List   File List   Compound Members  

cdensity.h

00001 //==========================================================================
00002 //   CDENSITY.H - header for
00003 //                             OMNeT++
00004 //            Discrete System Simulation in C++
00005 //
00006 //
00007 //  Declaration of the following classes:
00008 //    cDensityEstBase : common base class for density estimation classes
00009 //
00010 //==========================================================================
00011 
00012 /*--------------------------------------------------------------*
00013   Copyright (C) 1992-2003 Andras Varga
00014 
00015   This file is distributed WITHOUT ANY WARRANTY. See the file
00016   `license' for details on this and other legal matters.
00017 *--------------------------------------------------------------*/
00018 
00019 #ifndef __CDENSITY_H
00020 #define __CDENSITY_H
00021 
00022 #include "cstat.h"
00023 
00024 //==========================================================================
00025 
00069 class SIM_API cDensityEstBase : public cStdDev
00070 {
00071   public:
00072     // to range_mode:
00073     enum { RANGE_INVALID,   // --> needs to be set
00074            RANGE_FIXED,     // --> fixed range (lower,upper)
00075            RANGE_AUTO,
00076            RANGE_AUTOLOWER, // --> will be determined from firstvals[],
00077            RANGE_AUTOUPPER, //        using min and/or max and range_ext_fact
00078            RANGE_NOTSET     // --> not set, but it's OK (cVarHistogram only)
00079          };
00080 
00081   protected:
00082     double rangemin,rangemax;   // range for distribution density collection
00083     long num_firstvals;         // number of "pre-collected" samples
00084                                 // before transform() is performed.
00085     unsigned long cell_under;
00086     unsigned long cell_over;    // for counting observations that fall out of range
00087 
00088     double range_ext_factor;    // the range of histogram is: [min_samples,max_samples] made
00089                                 // range_ext_factor times larger
00090     int range_mode;             // one of RANGE_xxx constants
00091 
00092     bool transfd;
00093     double *firstvals;         // pointer to array of "pre-collected" samples
00094 
00095   protected:
00096     static void plotline (ostream& os, char* pref, double xval,
00097                           double count, double a);
00098 
00099   public:
00102 
00106     cDensityEstBase(const cDensityEstBase& r) : cStdDev(r)
00107             {setName(r.name());firstvals=NULL;operator=(r);}
00108 
00112     explicit cDensityEstBase(const char *name=NULL);
00113 
00117     virtual ~cDensityEstBase();
00118 
00122     cDensityEstBase& operator=(const cDensityEstBase& res);
00124 
00127 
00128     /* No dup() because this is an abstract class. */
00129 
00134     virtual void writeContents(ostream& os);
00135 
00141     virtual int netPack();
00142 
00148     virtual int netUnpack();
00150 
00153 
00161     virtual void collect(double val);
00162 
00166     virtual void clearResult();
00167 
00174     virtual double random() const = 0;  // FIXME: redundant!!!
00175 
00179     virtual void saveToFile(FILE *) const;
00180 
00184     virtual void loadFromFile(FILE *);
00186 
00189 
00194     virtual void setRange(double lower, double upper);
00195 
00207     virtual void setRangeAuto(int num_firstvals, double range_ext_fact);
00208 
00215     virtual void setRangeAutoLower(double upper, int num_firstvals, double range_ext_fact);
00216 
00223     virtual void setRangeAutoUpper(double lower, int num_firstvals, double range_ext_fact);
00224 
00229     virtual void setNumFirstVals(int num_firstvals);
00231 
00232   protected:
00239     virtual void setupRange();
00240 
00247     virtual void collectTransformed(double val) = 0;
00248 
00249   public:
00250 
00253 
00257     virtual bool transformed() const   {return transfd;}
00258 
00265     virtual void transform() = 0;
00267 
00270 
00275     virtual int cells() const = 0;
00276 
00284     virtual double basepoint(int k) const = 0;
00285 
00291     virtual double cell(int k) const = 0;
00292 
00300     virtual double cellPDF(int k) const;
00301 
00306     virtual unsigned long underflowCell() const {return cell_under;}
00307 
00312     virtual unsigned long overflowCell() const {return cell_over;}
00314 
00317 
00323     virtual double pdf(double x) const = 0;
00324 
00330     virtual double cdf(double x) const = 0;
00332 };
00333 
00334 #endif
00335 
00336 
00337 

Generated at Mon Jun 16 23:37:31 2003 for OMNeT++ by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001