template class utils::Statistics¶
Overview¶
Calculates statistical evaluation on a data set. More…
#include <Statistics.h> template <typename Type> class Statistics { public: // construction Statistics(); Statistics(size_t initial_capacity); Statistics(const std::vector<Type>& data_vector); // methods bool IsEmpty() const; void Clear(); void Add(const Type value); size_t Count() const; Type Sum() const; Type Average() const; Type Min() const; Type Max() const; std::string ToString() const; };
Detailed Documentation¶
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;
Construction¶
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.
Methods¶
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.
std::string ToString() const
Prints all statistical values to the string and returns it.