OMNeT++ Simulation Library  6.0.3
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  std::string str() const;
41  };
42 
43  private:
44  void copy(const cAbstractHistogram& other) {}
45 
46  public:
47  // internal, for use in sim_std.msg; note: each call overwrites the previous value!
48  const Bin& internalGetBinInfo(int k) const;
49 
50  public:
53 
57  cAbstractHistogram(const cAbstractHistogram& other) = default;
58 
62  explicit cAbstractHistogram(const char *name=nullptr, bool weighted=false) : cStdDev(name, weighted) {}
63 
67  virtual ~cAbstractHistogram() {}
68 
73  if (this == &res)
74  return *this;
75  cStdDev::operator=(res);
76  copy(res);
77  return *this;
78  }
79 
80  virtual cAbstractHistogram *dup() const override {throw cRuntimeError(this, E_CANTDUP);}
82 
88  virtual bool binsAlreadySetUp() const = 0;
89 
95  virtual void setUpBins() = 0;
96 
101  virtual std::vector<double> getBinEdges() const;
102 
107  virtual std::vector<double> getBinValues() const;
108 
112  virtual int getNumBins() const = 0;
113 
121  virtual double getBinEdge(int k) const = 0;
122 
127  virtual double getBinValue(int k) const = 0;
128 
134  virtual double getBinPDF(int k) const;
135 
141  virtual int64_t getNumUnderflows() const = 0;
142 
148  virtual int64_t getNumOverflows() const = 0;
149 
155  virtual double getUnderflowSumWeights() const = 0;
156 
162  virtual double getOverflowSumWeights() const = 0;
163 
167  virtual int64_t getNumNegInfs() const = 0;
168 
172  virtual int64_t getNumPosInfs() const = 0;
173 
177  virtual double getNegInfSumWeights() const = 0;
178 
182  virtual double getPosInfSumWeights() const = 0;
183 
188  virtual Bin getBinInfo(int k) const;
190 
193 
197  virtual double getPDF(double x) const;
198 
202  virtual double getCDF(double x) const;
203 
207  virtual double draw() const override;
209 };
210 
211 } // namespace omnetpp
212 
213 
214 #endif
215 
216 
217 
omnetpp::cAbstractHistogram::operator=
cAbstractHistogram & operator=(const cAbstractHistogram &res)
Definition: cabstracthistogram.h:72
omnetpp::cAbstractHistogram::Bin
Information about a histogram bin. This struct is not used internally by the histogram classes,...
Definition: cabstracthistogram.h:33
omnetpp::cAbstractHistogram::cAbstractHistogram
cAbstractHistogram(const char *name=nullptr, bool weighted=false)
Definition: cabstracthistogram.h:62
omnetpp::cAbstractHistogram::~cAbstractHistogram
virtual ~cAbstractHistogram()
Definition: cabstracthistogram.h:67
omnetpp::cAbstractHistogram::dup
virtual cAbstractHistogram * dup() const override
Definition: cabstracthistogram.h:80
omnetpp::cAbstractHistogram
Interface and base class for histogram-like density estimation classes.
Definition: cabstracthistogram.h:26
omnetpp::cStdDev
Statistics class to collect min, max, mean, and standard deviation.
Definition: cstddev.h:29
omnetpp::cRuntimeError
Thrown when the simulation kernel or other components detect a runtime error.
Definition: cexception.h:286
omnetpp::cStdDev::operator=
cStdDev & operator=(const cStdDev &res)