AIToolbox
A library that offers tools for AI problem solving.
Statistics.hpp
Go to the documentation of this file.
1 #ifndef AI_TOOLBOX_STATISTICS_HEADER_FILE
2 #define AI_TOOLBOX_STATISTICS_HEADER_FILE
3 
4 #include <vector>
5 #include <iosfwd>
6 
7 namespace AIToolbox {
27  class Statistics {
28  public:
29  // mean, cum mean, std, cum std
30  using Result = std::tuple<double, double, double, double>;
31  using Results = std::vector<Result>;
32 
38  Statistics(size_t timesteps);
39 
56  void record(double value, size_t timestep);
57 
74  Results process() const;
75 
76  private:
77  // Count, sum, sum squared, squared sum
78  using Point = std::tuple<unsigned, double, double, double>;
79 
80  std::vector<Point> data_;
81  size_t prevTimestep_;
82  double currentCumulativeValue_;
83  };
84 
103  std::ostream& operator<<(std::ostream& os, const Statistics & rh);
104 }
105 
106 #endif
AIToolbox::Statistics::process
Results process() const
This function computes mean and standard deviation for all timesteps.
AIToolbox::operator<<
std::ostream & operator<<(std::ostream &os, const Statistics &rh)
This function writes the output of the Statistics to the stream.
AIToolbox::Statistics
This class registers sets of data and computes statistics about it.
Definition: Statistics.hpp:27
AIToolbox::Statistics::Results
std::vector< Result > Results
Definition: Statistics.hpp:31
AIToolbox
Definition: Experience.hpp:6
AIToolbox::Statistics::Result
std::tuple< double, double, double, double > Result
Definition: Statistics.hpp:30
AIToolbox::Statistics::record
void record(double value, size_t timestep)
This function records a new datapoint for the specified timestep.
AIToolbox::Statistics::Statistics
Statistics(size_t timesteps)
Basic constructor.