Modigliani  2.0
A stochastic simulator for axons, neurons, and networks
sequential_statistics.h
1 
24 #ifndef MODIGLIANI_MODIGLIANI_BASE_SEQUENTIAL_STATISTICS_H_
25 #define MODIGLIANI_MODIGLIANI_BASE_SEQUENTIAL_STATISTICS_H_
26 
27 #include <cmath>
28 #include <climits>
29 #include <cfloat>
30 
31 #include "modigliani_base/types.h"
32 #include "modigliani_base/obj.h"
33 
34 namespace modigliani_base {
38  class Sequential_statistics:public Obj {
39  public:
44 
45  Sequential_statistics(const Sequential_statistics & original) = delete;
46 
47  const Sequential_statistics & operator=(const Sequential_statistics &
48  right) = delete;
49 
53  virtual ~Sequential_statistics();
54 
58  void Reset();
59 
64  void Add(Real val);
65 
70  Size counter() const {
71  return (counter_);
72  }
73 
78  Real average() const {
79  return (average_);
80  }
81 
86  Real val_square_average() const {
87  return (val_square_average_);
88  }
89 
94  Real variance() const {
95  return (variance_);
96  }
97 
102  Real min() const {
103  return (min_);
104  }
105 
110  Real max() const {
111  return (max_);
112  }
113 
120  friend std::ostream & operator<<(std::ostream & str,
121  const Sequential_statistics & self);
122 
123  private:
132  Real UpdateAverage(Real avg, Real val, Size n) const;
133 
134  Size counter_;
135  Real average_;
136  Real val_square_average_;
137  Real variance_;
138  Real min_;
139  Real max_;
140  };
141 } // namespace modigliani_base
142 #endif // MODIGLIANI_MODIGLIANI_BASE_SEQUENTIAL_STATISTICS_H_
Sequential_statistics()
Create a Sequential_statistics.
Definition: sequential_statistics.cc:27
Real average() const
Returns the average.
Definition: sequential_statistics.h:78
Real variance() const
Returns the variance.
Definition: sequential_statistics.h:94
void Reset()
Resets all values.
Definition: sequential_statistics.cc:34
Real max() const
Returns the maximum value.
Definition: sequential_statistics.h:110
Real val_square_average() const
Returns the sqaure average.
Definition: sequential_statistics.h:86
friend std::ostream & operator<<(std::ostream &str, const Sequential_statistics &self)
Prints statistics.
Definition: sequential_statistics.cc:56
void Add(Real val)
Adds a value and update all statistics.
Definition: sequential_statistics.cc:43
Size counter() const
Returns number of samples.
Definition: sequential_statistics.h:70
virtual ~Sequential_statistics()
Desctructor.
Definition: sequential_statistics.cc:31
Real min() const
Returns the minimum value.
Definition: sequential_statistics.h:102
Sequential_statistics class.
Definition: sequential_statistics.h:38
Master class for all objects.
Definition: obj.h:102