Utilities
Utilities header only library
utils::Statistics< Type > Class Template Reference

Calculates statistical evaluation on a data set. More...

Public Member Functions

 Statistics ()
 Creates new instance with default capacity of the data set.
 
 Statistics (size_t initial_capacity)
 Creates new instance with specific capacity of the data set.
 
 Statistics (const std::vector< Type > &data_vector)
 Creates new instance with initialized data set.
 
bool IsEmpty () const
 Checks if there are no data records.
 
void Clear ()
 Removes all stored data.
 
void Add (const Type value)
 Stores a data record in the data set.
 
size_t Count () const
 Returns number of stored data records.
 
Type Sum () const
 Returns a sum of all elements in the data set.
 
Type Average () const
 Returns average value of the data set.
 
Type Min () const
 Returns minimal value of the data set.
 
Type Max () const
 Returns maximal value of the data set.
 
Type StandardDeviation () const
 Returns standard deviation of the data set.
 
std::string ToString () const
 Prints all statistical values to the string and returns it.
 

Detailed Description

template<typename Type>
class utils::Statistics< Type >

Calculates statistical evaluation on a data set.

Example usage:

utils::StatAnalyser<float> stat;
for (size_t i=0; i<MAX_ITERATIONS; ++i)
{
float val = CalculateSomeValue();
stat.Add(val);
}
std::cout << "Average value: " << stat.Average() << std::endl;