libstatistics_collector
master
Lightweight aggregation utilities to collect statistics and measure message metrics.
|
#include <moving_average.hpp>
Public Member Functions | |
MovingAverageStatistics ()=default | |
~MovingAverageStatistics ()=default | |
double | Average () const RCPPUTILS_TSA_REQUIRES(mutex_) |
double | Max () const RCPPUTILS_TSA_REQUIRES(mutex_) |
double | Min () const RCPPUTILS_TSA_REQUIRES(mutex_) |
double | StandardDeviation () const RCPPUTILS_TSA_REQUIRES(mutex_) |
StatisticData | GetStatistics () const |
void | Reset () |
virtual void | AddMeasurement (const double item) |
uint64_t | GetCount () const |
A class for calculating moving average statistics. This operates in constant memory and constant time. Note: reset() must be called manually in order to start a new measurement window.
The statistics calculated are average, maximum, minimum, and standard deviation (population). All are calculated online without storing the observation data. Specifically, the average is a running sum and the variance is obtained by Welford's online algorithm (reference: https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Welford%27s_online_algorithm) for standard deviation.
When statistics are not available, e.g. no observations have been made, NaNs are returned.
|
default |
|
default |
double libstatistics_collector::moving_average_statistics::MovingAverageStatistics::Average | ( | ) | const |
Returns the arithmetic mean of all data recorded. If no observations have been made, returns NaN.
double libstatistics_collector::moving_average_statistics::MovingAverageStatistics::Max | ( | ) | const |
Returns the maximum value recorded. If size of list is zero, returns NaN.
double libstatistics_collector::moving_average_statistics::MovingAverageStatistics::Min | ( | ) | const |
Returns the minimum value recorded. If size of list is zero, returns NaN.
double libstatistics_collector::moving_average_statistics::MovingAverageStatistics::StandardDeviation | ( | ) | const |
Returns the standard deviation (population) of all data recorded. If size of list is zero, returns NaN.
Variance is obtained by Welford's online algorithm, see https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Welford%27s_online_algorithm
StatisticData libstatistics_collector::moving_average_statistics::MovingAverageStatistics::GetStatistics | ( | ) | const |
Return a StatisticData object, containing average, minimum, maximum, standard deviation (population), and sample count. For the case of no observations, the average, min, max, and standard deviation are NaN.
void libstatistics_collector::moving_average_statistics::MovingAverageStatistics::Reset | ( | ) |
Reset all calculated values. Equivalent to a new window for a moving average.
|
virtual |
Observe a sample for the given window. The input item is used to calculate statistics. Note: any input values of NaN will be discarded and not added as a measurement.
item | The item that was observed |
uint64_t libstatistics_collector::moving_average_statistics::MovingAverageStatistics::GetCount | ( | ) | const |
Return the number of samples observed