OMNeT++ Simulation Library  5.4.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  }
79 
85  virtual bool binsAlreadySetUp() const = 0;
86 
91  virtual void setUpBins() = 0;
92 
96  virtual int getNumBins() const = 0;
97 
105  virtual double getBinEdge(int k) const = 0;
106 
111  virtual double getBinValue(int k) const = 0;
112 
118  virtual double getBinPDF(int k) const;
119 
124  virtual int64_t getNumUnderflows() const = 0;
125 
130  virtual int64_t getNumOverflows() const = 0;
131 
135  virtual double getUnderflowSumWeights() const = 0;
136 
140  virtual double getOverflowSumWeights() const = 0;
141 
146  virtual Bin getBinInfo(int k) const;
148 
151 
155  virtual double getPDF(double x) const;
156 
160  virtual double getCDF(double x) const;
161 
165  virtual double draw() const override;
167 
170 
174  _OPPDEPRECATED virtual bool isTransformed() const final {return binsAlreadySetUp();}
175 
179  _OPPDEPRECATED virtual void transform() final {setUpBins();}
180 
184  _OPPDEPRECATED virtual int getNumCells() const final {return getNumBins();}
185 
189  _OPPDEPRECATED virtual double getBasepoint(int k) const final {return getBinEdge(k);}
190 
194  _OPPDEPRECATED virtual double getCellValue(int k) const final {return getBinValue(k);}
195 
199  _OPPDEPRECATED virtual double getCellPDF(int k) const final {return getBinPDF(k);}
200 
204  _OPPDEPRECATED virtual int64_t getUnderflowCell() const final {return getNumUnderflows();}
205 
209  _OPPDEPRECATED virtual int64_t getOverflowCell() const final {return getNumOverflows();}
210 
214  _OPPDEPRECATED virtual Bin getCellInfo(int k) const final {return getBinInfo(k);}
216 };
217 
221 _OPPDEPRECATED typedef cAbstractHistogram cDensityEstBase;
222 
223 } // namespace omnetpp
224 
225 
226 #endif
227 
228 
229 
virtual _OPPDEPRECATED int64_t getUnderflowCell() const final
Definition: cabstracthistogram.h:204
virtual _OPPDEPRECATED int getNumCells() const final
Definition: cabstracthistogram.h:184
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 _OPPDEPRECATED double getBasepoint(int k) const final
Definition: cabstracthistogram.h:189
virtual _OPPDEPRECATED Bin getCellInfo(int k) const final
Definition: cabstracthistogram.h:214
virtual _OPPDEPRECATED int64_t getOverflowCell() const final
Definition: cabstracthistogram.h:209
virtual _OPPDEPRECATED double getCellValue(int k) const final
Definition: cabstracthistogram.h:194
virtual _OPPDEPRECATED double getCellPDF(int k) const final
Definition: cabstracthistogram.h:199
virtual _OPPDEPRECATED void transform() final
Definition: cabstracthistogram.h:179
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:174