OMNeT++ Simulation Library  6.0.3
cStatistic Class Referenceabstract

#include <cstatistic.h>

Description

cStatistic is an abstract class for computing statistical properties of a random variable.

This class inherits from cRandom, because instances are able to generate random variates from the estimated distribution.

Inheritance diagram for cStatistic:
cRandom cOwnedObject cNamedObject cObject cStdDev cAbstractHistogram cHistogram cPrecollectionBasedDensityEst cPSquare cKSplit

Public Member Functions

Constructors, destructor, assignment.
 cStatistic (const cStatistic &r)
 
 cStatistic (const char *name=nullptr)
 
virtual ~cStatistic ()
 
cStatisticoperator= (const cStatistic &res)
 
Redefined cObject member functions.
virtual void parsimPack (cCommBuffer *buffer) const override
 
virtual void parsimUnpack (cCommBuffer *buffer) override
 
Collecting values.
virtual bool isWeighted () const =0
 
virtual void collect (double value)=0
 
virtual void collect (SimTime value)
 
virtual void collectWeighted (double value, double weight)
 
virtual void collectWeighted (SimTime value, double weight)
 
virtual void collectWeighted (double value, SimTime weight)
 
virtual void collectWeighted (SimTime value, SimTime weight)
 
virtual void merge (const cStatistic *other)=0
 
virtual void clear ()=0
 
Statistics of collected data.
virtual int64_t getCount () const =0
 
virtual double getSum () const =0
 
virtual double getSqrSum () const =0
 
virtual double getMin () const =0
 
virtual double getMax () const =0
 
virtual double getMean () const =0
 
virtual double getStddev () const =0
 
virtual double getVariance () const =0
 
Weighted statistics.
virtual double getSumWeights () const =0
 
virtual double getWeightedSum () const =0
 
virtual double getSqrSumWeights () const =0
 
virtual double getWeightedSqrSum () const =0
 
Writing to text file, reading from text file, recording to scalar file.
virtual void saveToFile (FILE *) const =0
 
virtual void loadFromFile (FILE *)=0
 
virtual void record ()
 
virtual void recordWithUnit (const char *unit)
 
virtual void recordAs (const char *name, const char *unit=nullptr)
 
- 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
 
virtual double draw () const =0
 
- 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
 
- 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)=default
 
virtual ~cObject ()
 
virtual const char * getClassName () const
 
bool isName (const char *s) const
 
virtual const char * getFullName () const
 
virtual std::string getFullPath () const
 
virtual std::string getClassAndFullName () const
 
virtual std::string getClassAndFullPath () const
 
const cObjectgetThisPtr () const
 
virtual std::string str () const
 
virtual std::ostream & printOn (std::ostream &os) const
 
virtual cObjectdup () const
 
virtual bool isSoftOwner () const
 
virtual void forEachChild (cVisitor *v)
 
cObjectfindObject (const char *name, bool deep=true)
 
virtual cClassDescriptorgetDescriptor () const
 
void copyNotSupported () const
 

Additional Inherited Members

- Static Public Member Functions inherited from cOwnedObject
static long getTotalObjectCount ()
 
static long getLiveObjectCount ()
 
static void resetObjectCounters ()
 
static cSoftOwnergetOwningContext ()
 
- Protected Member Functions inherited from cObject
virtual void take (cOwnedObject *obj)
 
virtual void drop (cOwnedObject *obj)
 
void dropAndDelete (cOwnedObject *obj)
 

Constructor & Destructor Documentation

◆ cStatistic() [1/2]

cStatistic ( const cStatistic r)

Copy constructor.

◆ cStatistic() [2/2]

cStatistic ( const char *  name = nullptr)
explicit

Constructor, creates an object with the given name

◆ ~cStatistic()

virtual ~cStatistic ( )
inlinevirtual

Destructor.

Member Function Documentation

◆ operator=()

cStatistic& operator= ( const cStatistic res)

Assignment operator. It is present since descendants may refer to it. The name member is not copied; see cNamedObject::operator=() for 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 cOwnedObject.

Reimplemented in cKSplit, cHistogram, cPrecollectionBasedDensityEst, cStdDev, and cPSquare.

◆ 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 cOwnedObject.

Reimplemented in cKSplit, cHistogram, cPrecollectionBasedDensityEst, cStdDev, and cPSquare.

◆ isWeighted()

virtual bool isWeighted ( ) const
pure virtual

Returns true if this object collects weighted statistics.

Implemented in cStdDev.

◆ collect() [1/2]

virtual void collect ( double  value)
pure virtual

Collects one value.

Implemented in cHistogram, cPrecollectionBasedDensityEst, cPSquare, and cStdDev.

◆ collect() [2/2]

virtual void collect ( SimTime  value)
inlinevirtual

Convenience method, delegates to collect(double).

References cStatistic::collect(), and SimTime::dbl().

Referenced by cStatistic::collect().

◆ collectWeighted() [1/4]

virtual void collectWeighted ( double  value,
double  weight 
)
virtual

Collects one value with a given weight.

Reimplemented in cHistogram, cPrecollectionBasedDensityEst, cPSquare, and cStdDev.

◆ collectWeighted() [2/4]

virtual void collectWeighted ( SimTime  value,
double  weight 
)
inlinevirtual

Convenience method, delegates to collectWeighted(double, double).

References cStatistic::collectWeighted(), and SimTime::dbl().

Referenced by cStatistic::collectWeighted().

◆ collectWeighted() [3/4]

virtual void collectWeighted ( double  value,
SimTime  weight 
)
inlinevirtual

Convenience method, delegates to collectWeighted(double, double).

References cStatistic::collectWeighted(), and SimTime::dbl().

Referenced by cStatistic::collectWeighted().

◆ collectWeighted() [4/4]

virtual void collectWeighted ( SimTime  value,
SimTime  weight 
)
inlinevirtual

Convenience method, delegates to collectWeighted(double, double).

References cStatistic::collectWeighted(), and SimTime::dbl().

Referenced by cStatistic::collectWeighted().

◆ merge()

virtual void merge ( const cStatistic other)
pure virtual

Updates this object with data coming from another statistics object. The result is as if this object had collected all the observations fed into the other object as well.

Implemented in cKSplit, cHistogram, cPSquare, cPrecollectionBasedDensityEst, and cStdDev.

◆ clear()

virtual void clear ( )
pure virtual

This function should be redefined in derived classes to clear the results collected so far.

Implemented in cKSplit, cStdDev, cPSquare, cHistogram, and cPrecollectionBasedDensityEst.

◆ getCount()

virtual int64_t getCount ( ) const
pure virtual

Returns the number of the observations, regardless of their weights.

Implemented in cStdDev.

◆ getSum()

virtual double getSum ( ) const
pure virtual

Returns the sum of the values. Not available for weighted statistics.

See also
getWeightedSum()

Implemented in cStdDev.

◆ getSqrSum()

virtual double getSqrSum ( ) const
pure virtual

Returns the sum of the squared values. Not available for weighted statistics.

See also
getWeightedSqrSum()

Implemented in cStdDev.

◆ getMin()

virtual double getMin ( ) const
pure virtual

Returns the minimum of the values.

Implemented in cStdDev.

◆ getMax()

virtual double getMax ( ) const
pure virtual

Returns the maximum of the values.

Implemented in cStdDev.

◆ getMean()

virtual double getMean ( ) const
pure virtual

Returns the mean of the (weighted) observations.

Implemented in cStdDev.

◆ getStddev()

virtual double getStddev ( ) const
pure virtual

Returns the standard deviation of the (weighted) observations.

Implemented in cStdDev.

◆ getVariance()

virtual double getVariance ( ) const
pure virtual

Returns the variance of the (weighted) observations.

Implemented in cStdDev.

◆ getSumWeights()

virtual double getSumWeights ( ) const
pure virtual

Returns the sum of weights.

Implemented in cStdDev.

◆ getWeightedSum()

virtual double getWeightedSum ( ) const
pure virtual

Returns the sum of weight*value products.

Implemented in cStdDev.

◆ getSqrSumWeights()

virtual double getSqrSumWeights ( ) const
pure virtual

Returns the sum of squared weights.

Implemented in cStdDev.

◆ getWeightedSqrSum()

virtual double getWeightedSqrSum ( ) const
pure virtual

Returns the sum of weight*value*value products.

Implemented in cStdDev.

◆ saveToFile()

virtual void saveToFile ( FILE *  ) const
pure virtual

Writes the contents of the object into a text file. This method is pure virtual, implementation is provided in subclasses.

Implemented in cHistogram, cKSplit, cStdDev, cPSquare, and cPrecollectionBasedDensityEst.

◆ loadFromFile()

virtual void loadFromFile ( FILE *  )
pure virtual

Reads the object data from a file written out by saveToFile(). This method is pure virtual, implementation is provided in subclasses.

Implemented in cHistogram, cKSplit, cStdDev, cPSquare, and cPrecollectionBasedDensityEst.

◆ record()

virtual void record ( )
inlinevirtual

Records the statistics into the scalar result file. (Recorded data includes the number of observations, mean, standard deviation, min, max, potential histogram data, etc.) The name of the recorded statistic will be the object name (see getFullName()).

Note that this operation may have side effect: if this object is a histogram, the method may invoke the setUpBins() on the histogram object, to force it set up histogram bins before recording.

◆ recordWithUnit()

virtual void recordWithUnit ( const char *  unit)
inlinevirtual

Records the statistics into the scalar result file, with the given unit (e.g. "s", "m/s", etc). The name of the recorded statistic will be the object name (see getName()).

Note that this operation may have side effect: if this object is a histogram, the method may invoke the setUpBins() on the histogram object, to force it set up histogram bins before recording.

◆ recordAs()

virtual void recordAs ( const char *  name,
const char *  unit = nullptr 
)
virtual

Records the statistics into the scalar result file, with the given name, and optionally, the given unit (e.g. "s", "m/s", etc).

Note that this operation may have side effect: if this object is a histogram, the method may invoke the setUpBins() on the histogram object, to force it set up histogram bins before recording.


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