libmcts
A Monte Carlo Tree Search Library
running_stats.hpp
1 #ifndef RUNNING_STATS_H
2 #define RUNNING_STATS_H
3 
4 #include <cmath>
5 namespace mcts {
6 
7 // ----------------------------------------------------------------------
11 // ----------------------------------------------------------------------
12 class RunningStats {
13 public:
14  RunningStats();
15  void clear();
16 
17  // ----------------------------------------------------------------------
21  // ----------------------------------------------------------------------
22  void push(const double &x);
23 
24  // ----------------------------------------------------------------------
28  // ----------------------------------------------------------------------
29  long long num_data_values() const;
30  double mean() const;
31  double variance() const;
32  double standard_deviation() const;
33  double skewness() const;
34  double kurtosis() const;
35 
36  friend RunningStats operator+(const RunningStats a, const RunningStats b);
37  RunningStats &operator+=(const RunningStats &rhs);
38 
39 private:
40  long long n;
41  double M1, M2, M3, M4;
42 };
43 }
44 
45 #endif
void push(const double &x)
add a new value to the object
Computes variance, mean and standart deviation. http://www.johndcook.com/standard_deviation....
long long num_data_values() const
number of samples from which mean etc are calculated