AIToolbox
A library that offers tools for AI problem solving.
AIToolbox::Statistics Class Reference

This class registers sets of data and computes statistics about it. More...

#include <AIToolbox/Tools/Statistics.hpp>

Public Types

using Result = std::tuple< double, double, double, double >
 
using Results = std::vector< Result >
 

Public Member Functions

 Statistics (size_t timesteps)
 Basic constructor. More...
 
void record (double value, size_t timestep)
 This function records a new datapoint for the specified timestep. More...
 
Results process () const
 This function computes mean and standard deviation for all timesteps. More...
 

Detailed Description

This class registers sets of data and computes statistics about it.

This class is used to record multiple sets of data in order to create mean and standard deviation statistics from them in an efficient manner.

This can be used for example to easily compute statistics on reward/regret.

This class only performs basic bookkeeping during the recording of the data, as processing standard deviation requires all datapoints to be available.

For each timestep, this class only stores a summary of the number of points recorded there, their sum and the sum of their products. This class is not going to remember every single datapoint passed to it.

This class must know in advance the number of timesteps to consider, in order to pre-allocate the data vector for maximum performance.

Member Typedef Documentation

◆ Result

using AIToolbox::Statistics::Result = std::tuple<double, double, double, double>

◆ Results

using AIToolbox::Statistics::Results = std::vector<Result>

Constructor & Destructor Documentation

◆ Statistics()

AIToolbox::Statistics::Statistics ( size_t  timesteps)

Basic constructor.

Parameters
timestepsThe number of timesteps to process.

Member Function Documentation

◆ process()

Results AIToolbox::Statistics::process ( ) const

This function computes mean and standard deviation for all timesteps.

The return value of this function is a vector of tuples of the same size as the number of timesteps that the Statistics was constructed with.

Each tuple contains 4 double values.

In order, they are:

  • The mean computed of all recorded values for the timestep.
  • The cumulative mean computed from all recorded values for the timestep.
  • The biased standard deviation of the recorded values (computed as sqrt from the unbiased variance)
  • The biased standard deviation of the cumulative mean (computed as sqrt from the unbiased variance)
Returns
The mean and standard deviation (immediate and cumulative) for the recorded data.

◆ record()

void AIToolbox::Statistics::record ( double  value,
size_t  timestep 
)

This function records a new datapoint for the specified timestep.

This function stores the input in a way that allows to obtain both mean and standard deviation from the data later.

This function assumes that records are passed in order, for each run. If a new record has a timestep less than or equal to the previously passed timestep, it's going to assume that the new record refers to a new experiment run. This is important to compute the cumulative std statistic correctly, but does not otherwise affect the other ones.

Parameters
valueThe value to register.
timestepThe timestep of the value.

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