OMNeT++ Simulation Library  5.6.1
cabstracthistogram.h
1 //==========================================================================
2 // CABSTRACTHISTOGRAM.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 #ifndef __OMNETPP_CABSTRACTHISTOGRAM_H
17 #define __OMNETPP_CABSTRACTHISTOGRAM_H
18 
19 #include "cstddev.h"
20 
21 namespace omnetpp {
22 
26 class SIM_API cAbstractHistogram : public cStdDev
27 {
28  public:
33  struct Bin
34  {
35  double lower; // lower bin bound (inclusive)
36  double upper; // lower bin bound (exclusive)
37  double value; // count or sum of weights (or its estimate)
38  double relativeFreq; // value / total
39  Bin() {lower=upper=value=relativeFreq=0;}
40  };
41 
42  private:
43  void copy(const cAbstractHistogram& other) {}
44 
45  public:
46  // internal, for use in sim_std.msg; note: each call overwrites the previous value!
47  const Bin& internalGetBinInfo(int k) const;
48 
49  public:
52 
56  cAbstractHistogram(const cAbstractHistogram& other) : cStdDev(other) {}
57 
61  explicit cAbstractHistogram(const char *name=nullptr, bool weighted=false) : cStdDev(name, weighted) {}
62 
66  virtual ~cAbstractHistogram() {};
67 
72  if (this == &res)
73  return *this;
74  cStdDev::operator=(res);
75  copy(res);
76  return *this;
77  }
78 
79  virtual cAbstractHistogram *dup() const override {throw cRuntimeError(this, E_CANTDUP);}
81 
87  virtual bool binsAlreadySetUp() const = 0;
88 
94  virtual void setUpBins() = 0;
95 
99  virtual int getNumBins() const = 0;
100 
108  virtual double getBinEdge(int k) const = 0;
109 
114  virtual double getBinValue(int k) const = 0;
115 
121  virtual double getBinPDF(int k) const;
122 
128  virtual int64_t getNumUnderflows() const = 0;
129 
135  virtual int64_t getNumOverflows() const = 0;
136 
142  virtual double getUnderflowSumWeights() const = 0;
143 
149  virtual double getOverflowSumWeights() const = 0;
150 
154  virtual int64_t getNumNegInfs() const = 0;
155 
159  virtual int64_t getNumPosInfs() const = 0;
160 
164  virtual double getNegInfSumWeights() const = 0;
165 
169  virtual double getPosInfSumWeights() const = 0;
170 
175  virtual Bin getBinInfo(int k) const;
177 
180 
184  virtual double getPDF(double x) const;
185 
189  virtual double getCDF(double x) const;
190 
194  virtual double draw() const override;
196 
199 
203  _OPPDEPRECATED virtual bool isTransformed() const final {return binsAlreadySetUp();}
204 
208  _OPPDEPRECATED virtual void transform() final {setUpBins();}
209 
213  _OPPDEPRECATED virtual int getNumCells() const final {return getNumBins();}
214 
218  _OPPDEPRECATED virtual double getBasepoint(int k) const final {return getBinEdge(k);}
219 
223  _OPPDEPRECATED virtual double getCellValue(int k) const final {return getBinValue(k);}
224 
228  _OPPDEPRECATED virtual double getCellPDF(int k) const final {return getBinPDF(k);}
229 
233  _OPPDEPRECATED virtual int64_t getUnderflowCell() const final {return getNumUnderflows();}
234 
238  _OPPDEPRECATED virtual int64_t getOverflowCell() const final {return getNumOverflows();}
239 
243  _OPPDEPRECATED virtual Bin getCellInfo(int k) const final {return getBinInfo(k);}
245 };
246 
250 _OPPDEPRECATED typedef cAbstractHistogram cDensityEstBase;
251 
252 } // namespace omnetpp
253 
254 
255 #endif
256 
257 
258 
virtual _OPPDEPRECATED int64_t getUnderflowCell() const final
Definition: cabstracthistogram.h:233
virtual _OPPDEPRECATED int getNumCells() const final
Definition: cabstracthistogram.h:213
Thrown when the simulation kernel or other components detect a runtime error.
Definition: cexception.h:283
Interface and base class for histogram-like density estimation classes.
Definition: cabstracthistogram.h:26
virtual ~cAbstractHistogram()
Definition: cabstracthistogram.h:66
cAbstractHistogram(const cAbstractHistogram &other)
Definition: cabstracthistogram.h:56
cAbstractHistogram(const char *name=nullptr, bool weighted=false)
Definition: cabstracthistogram.h:61
cStdDev & operator=(const cStdDev &res)
virtual cAbstractHistogram * dup() const override
Definition: cabstracthistogram.h:79
virtual _OPPDEPRECATED double getBasepoint(int k) const final
Definition: cabstracthistogram.h:218
virtual _OPPDEPRECATED Bin getCellInfo(int k) const final
Definition: cabstracthistogram.h:243
virtual _OPPDEPRECATED int64_t getOverflowCell() const final
Definition: cabstracthistogram.h:238
virtual _OPPDEPRECATED double getCellValue(int k) const final
Definition: cabstracthistogram.h:223
virtual _OPPDEPRECATED double getCellPDF(int k) const final
Definition: cabstracthistogram.h:228
virtual _OPPDEPRECATED void transform() final
Definition: cabstracthistogram.h:208
Definition: cabstracthistogram.h:21
cAbstractHistogram & operator=(const cAbstractHistogram &res)
Definition: cabstracthistogram.h:71
Statistics class to collect min, max, mean, and standard deviation.
Definition: cstddev.h:29
Information about a histogram bin. This struct is not used internally by the histogram classes...
Definition: cabstracthistogram.h:33
virtual _OPPDEPRECATED bool isTransformed() const final
Definition: cabstracthistogram.h:203