AIToolbox
A library that offers tools for AI problem solving.
|
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... | |
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.
using AIToolbox::Statistics::Result = std::tuple<double, double, double, double> |
using AIToolbox::Statistics::Results = std::vector<Result> |
AIToolbox::Statistics::Statistics | ( | size_t | timesteps | ) |
Basic constructor.
timesteps | The number of timesteps to 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:
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.
value | The value to register. |
timestep | The timestep of the value. |