OMNeT++ Simulation Library  6.0.3
cpsquare.h
1 //==========================================================================
2 // CPSQUARE.H - part of
3 // OMNeT++/OMNEST
4 // Discrete System Simulation in C++
5 //
6 //==========================================================================
7 
8 /*--------------------------------------------------------------*
9  Copyright (C) 1992-2017 Andras Varga
10  Copyright (C) 2006-2017 OpenSim Ltd.
11 
12  This file is distributed WITHOUT ANY WARRANTY. See the file
13  `license' for details on this and other legal matters.
14 *--------------------------------------------------------------*/
15 
16 // Author: Andras Varga, based on code of Babak Fakhamzadeh, TU Delft, Mar-Jun 1996;
17 
18 #ifndef __OMNETPP_CPSQUARE_H
19 #define __OMNETPP_CPSQUARE_H
20 
21 #include "cabstracthistogram.h"
22 
23 namespace omnetpp {
24 
25 
35 class SIM_API cPSquare : public cAbstractHistogram
36 {
37  protected:
38  int numBins; // number of bins
39  long numObs = 0; // number of observations
40  int *n = nullptr; // array of positions
41  double *q = nullptr; // array of heights
42 
43  long numNegInfs = 0, numPosInfs = 0;
44 
45  protected:
46  void copy(const cPSquare& other);
47  void ensureStrictlyIncreasingEdges();
48 
49  public:
52 
56  cPSquare(const cPSquare& r);
57 
61  explicit cPSquare(const char *name=nullptr, int bins=10);
62 
66  virtual ~cPSquare();
67 
71  cPSquare& operator=(const cPSquare& res);
73 
76 
81  virtual cPSquare *dup() const override {return new cPSquare(*this);}
82 
88  virtual void parsimPack(cCommBuffer *buffer) const override;
89 
95  virtual void parsimUnpack(cCommBuffer *buffer) override;
97 
98  public:
105  virtual bool binsAlreadySetUp() const override {return true;}
106 
111  virtual void setUpBins() override {}
112 
116  virtual void collect(double value) override;
117  using cStatistic::collect;
118 
123  virtual void collectWeighted(double value, double weight) override;
125 
129  virtual int getNumBins() const override;
130 
136  virtual double getBinEdge(int k) const override;
137 
141  virtual double getBinValue(int k) const override;
142 
148  virtual int64_t getNumUnderflows() const override {return numNegInfs;}
149 
155  virtual int64_t getNumOverflows() const override {return numPosInfs;}
156 
161  virtual double getUnderflowSumWeights() const override {return numNegInfs;}
162 
167  virtual double getOverflowSumWeights() const override {return numPosInfs;}
168 
172  virtual int64_t getNumNegInfs() const override {return numNegInfs;}
173 
177  virtual int64_t getNumPosInfs() const override {return numPosInfs;}
178 
184  virtual double getNegInfSumWeights() const override {return numNegInfs;}
185 
191  virtual double getPosInfSumWeights() const override {return numPosInfs;}
192 
196  virtual double draw() const override;
197 
201  virtual void merge(const cStatistic *other) override;
202 
206  virtual void clear() override;
207 
211  virtual void saveToFile(FILE *) const override;
212 
216  virtual void loadFromFile(FILE *) override;
218 };
219 
220 } // namespace omnetpp
221 
222 
223 #endif
224 
omnetpp::cPSquare::setUpBins
virtual void setUpBins() override
Definition: cpsquare.h:111
omnetpp::cStatistic::collectWeighted
virtual void collectWeighted(double value, double weight)
omnetpp::cPSquare
Implements the P2 algorithm, which calculates quantile values without storing the observations....
Definition: cpsquare.h:35
omnetpp::cPSquare::getNumNegInfs
virtual int64_t getNumNegInfs() const override
Definition: cpsquare.h:172
omnetpp::cPSquare::getNegInfSumWeights
virtual double getNegInfSumWeights() const override
Definition: cpsquare.h:184
omnetpp::cPSquare::getNumOverflows
virtual int64_t getNumOverflows() const override
Definition: cpsquare.h:155
omnetpp::cPSquare::binsAlreadySetUp
virtual bool binsAlreadySetUp() const override
Definition: cpsquare.h:105
omnetpp::cStatistic::collect
virtual void collect(double value)=0
omnetpp::cPSquare::dup
virtual cPSquare * dup() const override
Definition: cpsquare.h:81
omnetpp::cPSquare::getNumUnderflows
virtual int64_t getNumUnderflows() const override
Definition: cpsquare.h:148
omnetpp::cAbstractHistogram
Interface and base class for histogram-like density estimation classes.
Definition: cabstracthistogram.h:26
omnetpp::cPSquare::getNumPosInfs
virtual int64_t getNumPosInfs() const override
Definition: cpsquare.h:177
omnetpp::cPSquare::getPosInfSumWeights
virtual double getPosInfSumWeights() const override
Definition: cpsquare.h:191
omnetpp::cStatistic
cStatistic is an abstract class for computing statistical properties of a random variable.
Definition: cstatistic.h:34
omnetpp::cPSquare::getUnderflowSumWeights
virtual double getUnderflowSumWeights() const override
Definition: cpsquare.h:161
omnetpp::cCommBuffer
Buffer for the communications layer of parallel simulation.
Definition: ccommbuffer.h:41
omnetpp::cPSquare::getOverflowSumWeights
virtual double getOverflowSumWeights() const override
Definition: cpsquare.h:167