Modigliani  2.0
A stochastic simulator for axons, neurons, and networks
histogram.h
1 
23 #ifndef MODIGLIANI_MODIGLIANI_BASE_HISTOGRAM_H_
24 #define MODIGLIANI_MODIGLIANI_BASE_HISTOGRAM_H_
25 
26 #include <vector>
27 #include <cmath>
28 
29 #include "modigliani_base/main.h"
30 #include "modigliani_base/types.h"
31 #include "modigliani_base/obj.h"
32 #include "modigliani_base/error.h"
33 
34 namespace modigliani_base {
38  typedef std::vector < Size > HistogramBins;
39 
44  class Histogram:public Obj {
45  public:
52  Histogram(Real minVal = 0, Real maxVal = 1, Size numberOfBins = 10);
53 
54  Histogram(const Histogram & original) = delete;
55 
56  const Histogram & operator=(const Histogram & right) = delete;
57 
61  virtual ~Histogram();
62 
66  void Reset();
67 
75  void BinValue(Real value);
76 
81  void Show(bool showHeader = false) const;
82 
87  std::vector < Real > PDF() const;
88 
93  Real ShannonEntropy() const;
94 
101  friend std::ostream & operator<<(std::ostream & str,
102  const Histogram & self);
103 
108 
112  Real numBins;
113 
114  protected:
115  Real min;
116  Real max;
117  Real binWidth;
118  Real numDataPoints;
119  Size numOutliers;
120  };
121 } // namespace modigliani_base
122 #endif // MODIGLIANI_MODIGLIANI_BASE_HISTOGRAM_H_
Real numBins
Number of bins.
Definition: histogram.h:112
void BinValue(Real value)
Insert the value in the appropriate bin.
Definition: histogram.cc:47
void Reset()
Reset the histogram class to object creation values.
Definition: histogram.cc:41
friend std::ostream & operator<<(std::ostream &str, const Histogram &self)
Prints the histogram.
Definition: histogram.cc:85
virtual ~Histogram()
Destructor.
Definition: histogram.cc:38
void Show(bool showHeader=false) const
Prints the histogram to stdout.
Definition: histogram.cc:74
Histogram(Real minVal=0, Real maxVal=1, Size numberOfBins=10)
Creates a Histogram.
Definition: histogram.cc:25
Real ShannonEntropy() const
Return Shannon entropy.
Definition: histogram.cc:63
HistogramBins bins
brief Histogram bins
Definition: histogram.h:107
std::vector< Size > HistogramBins
Histogram bins, implemented as a vector.
Definition: histogram.h:38
Histogram class.
Definition: histogram.h:44
std::vector< Real > PDF() const
Returns the probability density functions.
Definition: histogram.cc:55
Master class for all objects.
Definition: obj.h:102