libmcts
A Monte Carlo Tree Search Library
avg_backpropagation_strategy.hpp
1 #ifndef AVG_BACKPROPAGATION_H
2 #define AVG_BACKPROPAGATION_H
3 
4 #include "running_stats.hpp"
5 #include "ibackpropagation_strategy.hpp"
6 
7 namespace mcts {
8 
9 // ----------------------------------------------------------------------
12 // ----------------------------------------------------------------------
14 public:
15  AvgBackpropagationStrategy() : stats() {}
16 
17  virtual void on_backpropagate(const double &value) { stats.push(value); }
18 
19  virtual double ev() const { return stats.mean(); }
20 
21  virtual double std_deviation() const { return stats.standard_deviation(); }
22 
23  virtual double variance() const { return stats.variance(); }
24 
25  virtual int nb_samples() const { return stats.num_data_values(); }
26 
28  return new AvgBackpropagationStrategy();
29  }
30 
31 private:
32  RunningStats stats;
33 };
34 }
35 
36 #endif
adds the backpropagated value to a running stats object that calculates the ev, mean and variance.
virtual double variance() const
gets the current variance
virtual double std_deviation() const
gets the current standard deviation
virtual IBackpropagationStrategy * create()
creates a new object of the same type and with the same constructor as the current object.
virtual void on_backpropagate(const double &value)
saves an value according to some metric.
virtual int nb_samples() const
gets the number of samples that are saved in the strat.
A backpropagation strategy is used in each node. when a terminal node is simulated,...
virtual double ev() const
gets the current expected value
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