libmcts
A Monte Carlo Tree Search Library
Public Member Functions | Friends | List of all members
mcts::RunningStats Class Reference

Computes variance, mean and standart deviation. http://www.johndcook.com/standard_deviation.html http://www.johndcook.com/skewness_kurtosis.html. More...

#include <running_stats.hpp>

Public Member Functions

void clear ()
 
void push (const double &x)
 add a new value to the object More...
 
long long num_data_values () const
 number of samples from which mean etc are calculated More...
 
double mean () const
 
double variance () const
 
double standard_deviation () const
 
double skewness () const
 
double kurtosis () const
 
RunningStatsoperator+= (const RunningStats &rhs)
 

Friends

RunningStats operator+ (const RunningStats a, const RunningStats b)
 

Detailed Description

Computes variance, mean and standart deviation. http://www.johndcook.com/standard_deviation.html http://www.johndcook.com/skewness_kurtosis.html.

Definition at line 12 of file running_stats.hpp.

Member Function Documentation

◆ num_data_values()

long long mcts::RunningStats::num_data_values ( ) const

number of samples from which mean etc are calculated

Returns
number of samples

Definition at line 30 of file running_stats.cpp.

30 { return n; }

Referenced by mcts::AvgBackpropagationStrategy::nb_samples().

◆ push()

void mcts::RunningStats::push ( const double &  x)

add a new value to the object

Parameters
xnumeric input value

Definition at line 14 of file running_stats.cpp.

14  {
15  double delta, delta_n, delta_n2, term1;
16 
17  long long n1 = n;
18  n++;
19  delta = x - M1;
20  delta_n = delta / n;
21  delta_n2 = delta_n * delta_n;
22  term1 = delta * delta_n * n1;
23  M1 += delta_n;
24  M4 += term1 * delta_n2 * (n * n - 3 * n + 3) + 6 * delta_n2 * M2 -
25  4 * delta_n * M3;
26  M3 += term1 * delta_n * (n - 2) - 3 * delta_n * M2;
27  M2 += term1;
28 }

Referenced by mcts::AvgBackpropagationStrategy::on_backpropagate().


The documentation for this class was generated from the following files: