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-2001 Andras Varga
00014   Technical University of Budapest, Dept. of Telecommunications,
00015   Stoczek u.2, H-1111 Budapest, Hungary.
00016 
00017   This file is distributed WITHOUT ANY WARRANTY. See the file
00018   `license' for details on this and other legal matters.
00019 *--------------------------------------------------------------*/
00020 
00021 #ifndef __CDENSITY_H
00022 #define __CDENSITY_H
00023 
00024 #include <iostream.h>
00025 #include "cstat.h"
00026 
00027 //==========================================================================
00028 
00072 class SIM_API cDensityEstBase : public cStdDev
00073 {
00074   public:
00075     // to range_mode:
00076     enum { RANGE_INVALID,   // --> needs to be set
00077            RANGE_FIXED,     // --> fixed range (lower,upper)
00078            RANGE_AUTO,
00079            RANGE_AUTOLOWER, // --> will be determined from firstvals[],
00080            RANGE_AUTOUPPER, //        using min and/or max and range_ext_fact
00081            RANGE_NOTSET     // --> not set, but it's OK (cVarHistogram only)
00082          };
00083 
00084   protected:
00085     double rangemin,rangemax;   // range for distribution density collection
00086     long num_firstvals;         // number of "pre-collected" samples
00087                                 // before transform() is performed.
00088     unsigned long cell_under,
00089                   cell_over;    // counting samples fall out of range
00090 
00091     double range_ext_factor;    // the range of histogram is: [min_samples,max_samples] made
00092                                 // range_ext_factor times larger
00093     int range_mode;             // one of RANGE_xxx constants
00094 
00095     bool transfd;
00096     double *firstvals;         // pointer to array of "pre-collected" samples
00097 
00098   protected:
00099     static void plotline (ostream& os, char* pref, double xval,
00100                           double count, double a);
00101 
00102   public:
00105 
00109     cDensityEstBase(const cDensityEstBase& r) : cStdDev(r)
00110             {setName(r.name());firstvals=NULL;operator=(r);}
00111 
00115     explicit cDensityEstBase(const char *name=NULL);
00116 
00120     virtual ~cDensityEstBase();
00121 
00125     cDensityEstBase& operator=(const cDensityEstBase& res);
00127 
00130 
00134     virtual const char *className() const {return "cDensityEstBase";}
00135 
00136     /* No dup() because this is an abstract class. */
00137 
00142     virtual void writeContents(ostream& os);
00143 
00148     virtual const char *inspectorFactoryName() const {return "cDensityEstBaseIFC";}
00149 
00155     virtual int netPack();
00156 
00162     virtual int netUnpack();
00164 
00167 
00175     virtual void collect(double val);
00176 
00180     virtual void clearResult();
00181 
00188     virtual double random() const = 0;  // FIXME: redundant!!!
00189 
00193     virtual void saveToFile(FILE *) const;
00194 
00198     virtual void loadFromFile(FILE *);
00200 
00203 
00208     virtual void setRange(double lower, double upper);
00209 
00221     virtual void setRangeAuto(int num_firstvals, double range_ext_fact);
00222 
00229     virtual void setRangeAutoLower(double upper, int num_firstvals, double range_ext_fact);
00230 
00237     virtual void setRangeAutoUpper(double lower, int num_firstvals, double range_ext_fact);
00238 
00243     virtual void setNumFirstVals(int num_firstvals);
00245 
00246   protected:
00253     virtual void setupRange();
00254 
00261     virtual void collectTransformed(double val) = 0;
00262 
00263   public:
00264 
00267 
00271     virtual bool transformed() const   {return transfd;}
00272 
00279     virtual void transform() = 0;
00281 
00284 
00289     virtual int cells() const = 0;
00290 
00298     virtual double basepoint(int k) const = 0;
00299 
00305     virtual double cell(int k) const = 0;
00306 
00314     virtual double cellPDF(int k) const;
00315 
00320     virtual unsigned long underflowCell() const {return cell_under;}
00321 
00326     virtual unsigned long overflowCell() const {return cell_over;}
00328 
00331 
00337     virtual double pdf(double x) const = 0;
00338 
00344     virtual double cdf(double x) const = 0;
00346 };
00347 
00348 #endif
00349 
00350 
00351 

Generated at Sat May 4 15:45:48 2002 for OMNeT++ by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001