OMNeT++ Simulation Library  5.6.1
cLegacyHistogram Class Reference

#include <clegacyhistogram.h>

Description

Implements an equidistant histogram.

DEPRECATED CLASS, use cHistogram instead.

The histogram can operate in two modes. In INTEGERS mode, bin boundaries are whole numbers; in DOUBLES mode, they can be real numbers. The operating mode can be chosen with a constructor argument or with the setMode() method; the default behavior is to choose the mode automatically, by inspecting precollected observations.

By default, the number of bins is chosen automatically, and the histogram range is determined by precollecting a number of observations and extending their range by a range extension factor.

It is possible to explicitly set any of the following values (and the rest will be chosen or computed automatically): number of bins; bin size; number of observations to precollect; range extension factor; range lower bound; range upper bound. See the setNumCells(), setCellSize(), setNumFirstVals(), setRangeAuto(), setRangeAutoUpper(), and setRangeAutoLower() methods (many of them are inherited from cPrecollectionBasedDensityEst and cLegacyHistogramBase).

Especially in INTEGERS mode, if the bins cannot be set up to satisfy all explicitly given constraints (for example, if the explicitly specified range is not an integer multiple of the explicitly specified bin size), an error will be thrown.

Informational defaults for the various configuration values (subject to change without notice in any release): number of values to precollect: 100; range extension factor: 2.0; number of bins: 200 in INTEGERS mode and 30 in DOUBLES mode.

Examples:

Automatic mode:

cLegacyHistogram h("histogram");

Setting up a 50-bin histogram on the range [0.0, 5.0) (bin size = 0.1):

cLegacyHistogram h("histogram", 50, cLegacyHistogram::MODE_DOUBLES);
h.setRange(0,5);

If you only know that the numbers will be nonnegative but the exact range is unknown:

cLegacyHistogram h("histogram");
h.setRangeAutoUpper(0); // sets zero as lower bound
Inheritance diagram for cLegacyHistogram:
cLegacyHistogramBase cPrecollectionBasedDensityEst cAbstractHistogram cStdDev cStatistic cRandom cOwnedObject cNamedObject cObject cDoubleHistogram cLongHistogram

Public Member Functions

Constructors, destructor, assignment.
 cLegacyHistogram (const cLegacyHistogram &r)
 
 cLegacyHistogram (const char *name=nullptr, int numcells=-1, Mode mode=MODE_AUTO, bool weighted=false)
 
cLegacyHistogramoperator= (const cLegacyHistogram &res)
 
Redefined cObject member functions.
virtual void parsimPack (cCommBuffer *buffer) const override
 
virtual void parsimUnpack (cCommBuffer *buffer) override
 
Redefined member functions from cStatistic and its subclasses.
virtual double getBinEdge (int k) const override
 
virtual double getBinValue (int k) const override
 
virtual double getPDF (double x) const override
 
virtual double getCDF (double x) const override
 
virtual double draw () const override
 
virtual void saveToFile (FILE *) const override
 
virtual void loadFromFile (FILE *) override
 
Misc.
virtual void setMode (Mode mode)
 
virtual Mode getMode () const
 
virtual void setCellSize (double d)
 
virtual double getCellSize () const
 
- Public Member Functions inherited from cLegacyHistogramBase
 cLegacyHistogramBase (const cLegacyHistogramBase &r)
 
 cLegacyHistogramBase (const char *name, int numcells, bool weighted=false)
 
virtual ~cLegacyHistogramBase ()
 
cLegacyHistogramBaseoperator= (const cLegacyHistogramBase &res)
 
virtual void clear () override
 
virtual void setUpBins () override
 
virtual int getNumBins () const override
 
virtual void setNumCells (int numcells)
 
- Public Member Functions inherited from cPrecollectionBasedDensityEst
 cPrecollectionBasedDensityEst (const cPrecollectionBasedDensityEst &other)
 
 cPrecollectionBasedDensityEst (const char *name=nullptr, bool weighted=false)
 
virtual ~cPrecollectionBasedDensityEst ()
 
cPrecollectionBasedDensityEstoperator= (const cPrecollectionBasedDensityEst &res)
 
virtual void collect (double value) override
 
virtual void collectWeighted (double value, double weight) override
 
virtual void merge (const cStatistic *other) override
 
virtual void setRange (double lower, double upper)
 
virtual void setRangeAuto (int numPrecollect=100, double rangeExtensionFactor=2.0)
 
virtual void setRangeAutoLower (double upper, int numPrecollect=100, double rangeExtensionFactor=2.0)
 
virtual void setRangeAutoUpper (double lower, int numPrecollect=100, double rangeExtensionFactor=2.0)
 
virtual void setNumPrecollectedValues (int numPrecollect)
 
virtual int getNumPrecollectedValues () const
 
virtual double getRangeExtensionFactor () const
 
virtual bool binsAlreadySetUp () const override
 
virtual int64_t getNumUnderflows () const override
 
virtual int64_t getNumOverflows () const override
 
virtual double getUnderflowSumWeights () const override
 
virtual double getOverflowSumWeights () const override
 
virtual int64_t getNumNegInfs () const override
 
virtual int64_t getNumPosInfs () const override
 
virtual double getNegInfSumWeights () const override
 
virtual double getPosInfSumWeights () const override
 
- Public Member Functions inherited from cAbstractHistogram
 cAbstractHistogram (const cAbstractHistogram &other)
 
 cAbstractHistogram (const char *name=nullptr, bool weighted=false)
 
virtual ~cAbstractHistogram ()
 
cAbstractHistogramoperator= (const cAbstractHistogram &res)
 
virtual cAbstractHistogramdup () const override
 
virtual double getBinPDF (int k) const
 
virtual Bin getBinInfo (int k) const
 
virtual _OPPDEPRECATED bool isTransformed () const final
 
virtual _OPPDEPRECATED void transform () final
 
virtual _OPPDEPRECATED int getNumCells () const final
 
virtual _OPPDEPRECATED double getBasepoint (int k) const final
 
virtual _OPPDEPRECATED double getCellValue (int k) const final
 
virtual _OPPDEPRECATED double getCellPDF (int k) const final
 
virtual _OPPDEPRECATED int64_t getUnderflowCell () const final
 
virtual _OPPDEPRECATED int64_t getOverflowCell () const final
 
virtual _OPPDEPRECATED Bin getCellInfo (int k) const final
 
- Public Member Functions inherited from cStdDev
 cStdDev (const cStdDev &r)
 
 cStdDev (const char *name=nullptr, bool weighted=false)
 
virtual ~cStdDev ()
 
cStdDevoperator= (const cStdDev &res)
 
virtual std::string str () const override
 
virtual bool isWeighted () const override
 
virtual int64_t getCount () const override
 
virtual double getSum () const override
 
virtual double getSqrSum () const override
 
virtual double getMin () const override
 
virtual double getMax () const override
 
virtual double getMean () const override
 
virtual double getStddev () const override
 
virtual double getVariance () const override
 
virtual double getSumWeights () const override
 
virtual double getWeightedSum () const override
 
virtual double getSqrSumWeights () const override
 
virtual double getWeightedSqrSum () const override
 
- Public Member Functions inherited from cStatistic
 cStatistic (const cStatistic &r)
 
 cStatistic (const char *name=nullptr)
 
virtual ~cStatistic ()
 
cStatisticoperator= (const cStatistic &res)
 
virtual void collect (SimTime value)
 
virtual void collectWeighted (SimTime value, double weight)
 
virtual void collectWeighted (double value, SimTime weight)
 
virtual void collectWeighted (SimTime value, SimTime weight)
 
virtual void record ()
 
virtual void recordWithUnit (const char *unit)
 
virtual void recordAs (const char *name, const char *unit=nullptr)
 
virtual _OPPDEPRECATED double getWeights () const final
 
virtual _OPPDEPRECATED void collect2 (double value, double weight) final
 
virtual _OPPDEPRECATED void collect2 (SimTime value, double weight) final
 
virtual _OPPDEPRECATED void collect2 (double value, SimTime weight) final
 
virtual _OPPDEPRECATED void collect2 (SimTime value, SimTime weight) final
 
virtual _OPPDEPRECATED double random () const final
 
virtual _OPPDEPRECATED void clearResult () final
 
- Public Member Functions inherited from cRandom
 cRandom (cRNG *rng)
 
 cRandom (const char *name=nullptr, cRNG *rng=nullptr)
 
virtual ~cRandom ()
 
virtual void setRNG (cRNG *rng)
 
cRNGgetRNG () const
 
- Public Member Functions inherited from cOwnedObject
 cOwnedObject ()
 
 cOwnedObject (const char *name, bool namepooling=true)
 
 cOwnedObject (const cOwnedObject &obj)
 
virtual ~cOwnedObject ()
 
cOwnedObjectoperator= (const cOwnedObject &o)
 
virtual cObjectgetOwner () const override
 
virtual bool isOwnedObject () const override
 
virtual bool isSoftOwner () const
 
- Public Member Functions inherited from cNamedObject
 cNamedObject ()
 
 cNamedObject (const char *name, bool namepooling=true)
 
 cNamedObject (const cNamedObject &obj)
 
virtual ~cNamedObject ()
 
cNamedObjectoperator= (const cNamedObject &o)
 
virtual void setName (const char *s)
 
virtual const char * getName () const override
 
virtual void setNamePooling (bool b)
 
virtual bool getNamePooling ()
 
- Public Member Functions inherited from cObject
 cObject ()
 
 cObject (const cObject &other)
 
virtual ~cObject ()
 
virtual const char * getClassName () const
 
bool isName (const char *s) const
 
virtual const char * getFullName () const
 
virtual std::string getFullPath () const
 
const cObjectgetThisPtr () const
 
virtual _OPPDEPRECATED std::string info () const
 
virtual _OPPDEPRECATED std::string detailedInfo () const
 
virtual void forEachChild (cVisitor *v)
 
cObjectfindObject (const char *name, bool deep=true)
 
void copyNotSupported () const
 

Protected Member Functions

virtual void collectIntoHistogram (double value) override
 
virtual void collectWeightedIntoHistogram (double value, double weight) override
 
virtual void setupRange () override
 
- Protected Member Functions inherited from cObject
virtual void take (cOwnedObject *obj)
 
virtual void drop (cOwnedObject *obj)
 
void dropAndDelete (cOwnedObject *obj)
 

Additional Inherited Members

- Public Types inherited from cPrecollectionBasedDensityEst
enum  RangeMode
 Constants for histogram range_mode. More...
 
- Static Public Member Functions inherited from cOwnedObject
static long getTotalObjectCount ()
 
static long getLiveObjectCount ()
 
static void resetObjectCounters ()
 
static cDefaultListgetDefaultOwner ()
 

Constructor & Destructor Documentation

◆ cLegacyHistogram() [1/2]

cLegacyHistogram ( const cLegacyHistogram r)
inline

Copy constructor.

◆ cLegacyHistogram() [2/2]

cLegacyHistogram ( const char *  name = nullptr,
int  numcells = -1,
Mode  mode = MODE_AUTO,
bool  weighted = false 
)
explicit

Constructor.

Member Function Documentation

◆ operator=()

cLegacyHistogram& operator= ( const cLegacyHistogram res)

Assignment operator. The name member is not copied; see cNamedObject's operator=() for more details.

◆ parsimPack()

virtual void parsimPack ( cCommBuffer buffer) const
overridevirtual

Serializes the object into an MPI send buffer. Used by the simulation kernel for parallel execution. See cObject for more details.

Reimplemented from cLegacyHistogramBase.

◆ parsimUnpack()

virtual void parsimUnpack ( cCommBuffer buffer)
overridevirtual

Deserializes the object from an MPI receive buffer Used by the simulation kernel for parallel execution. See cObject for more details.

Reimplemented from cLegacyHistogramBase.

◆ collectIntoHistogram()

virtual void collectIntoHistogram ( double  value)
overrideprotectedvirtual

Called internally by collect(), this method collects a value after histogram bins have been set up.

Implements cPrecollectionBasedDensityEst.

◆ collectWeightedIntoHistogram()

virtual void collectWeightedIntoHistogram ( double  value,
double  weight 
)
overrideprotectedvirtual

Called internally by collect2(), this method collects a value after histogram bins have been set up.

Implements cPrecollectionBasedDensityEst.

◆ setupRange()

virtual void setupRange ( )
overrideprotectedvirtual

Called internally by setUpBins(), this method should determine and set up the histogram range. It also calculates the bin size.

Reimplemented from cPrecollectionBasedDensityEst.

◆ getBinEdge()

virtual double getBinEdge ( int  k) const
overridevirtual

Returns the kth bin boundary.

Implements cAbstractHistogram.

◆ getBinValue()

virtual double getBinValue ( int  k) const
overridevirtual

Returns the number of observations that fell into the kth histogram bin.

Implements cAbstractHistogram.

◆ getPDF()

virtual double getPDF ( double  x) const
overridevirtual

Returns the value of the Probability Density Function at a given x.

Reimplemented from cAbstractHistogram.

◆ getCDF()

virtual double getCDF ( double  x) const
overridevirtual

Returns the value of the Cumulated Density Function at a given x.

Reimplemented from cAbstractHistogram.

◆ draw()

virtual double draw ( ) const
overridevirtual

Returns a random number based on the distribution collected. If no values have been collected, it returns 0; when in initial collection phase, it returns one of the stored observations; after the histogram has been set up, a random integer or double is returned, depending on mode.

Reimplemented from cAbstractHistogram.

◆ saveToFile()

virtual void saveToFile ( FILE *  ) const
overridevirtual

Writes the contents of the object into a text file.

Reimplemented from cLegacyHistogramBase.

◆ loadFromFile()

virtual void loadFromFile ( FILE *  )
overridevirtual

Reads the object data from a file, in the format written out by saveToFile().

Reimplemented from cLegacyHistogramBase.

◆ setMode()

virtual void setMode ( Mode  mode)
virtual

Sets the histogram mode: MODE_AUTO, MODE_INTEGERS or MODE_DOUBLES. Cannot be called when the bins have been set up already.

◆ getMode()

virtual Mode getMode ( ) const
inlinevirtual

Returns the histogram mode, which is MODE_AUTO, MODE_INTEGERS or MODE_DOUBLES.

◆ setCellSize()

virtual void setCellSize ( double  d)
virtual

Sets the bin size. Cannot be called when the bins have been set up already.

◆ getCellSize()

virtual double getCellSize ( ) const
inlinevirtual

Returns the bin size, or 0 when unknow (i.e. the bins have not been set up yet, and setCellSize() has not been called).


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