![]() |
ros2_control - kilted
|
#include <statistics_types.hpp>
Public Types | |
using | StatisticData = libstatistics_collector::moving_average_statistics::StatisticData |
Public Member Functions | |
double | get_average () const |
double | get_max () const |
double | get_min () const |
double | get_standard_deviation () const |
const StatisticData & | get_statistics_const_ptr () const |
StatisticData | get_statistics () const |
const double & | get_current_measurement_const_ptr () const |
double | get_current_measurement () const |
void | reset () |
void | reset_current_measurement () |
virtual void | add_measurement (const double item) |
uint64_t | get_count () 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.
|
inlinevirtual |
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 |
|
inline |
Returns the arithmetic mean of all data recorded. If no observations have been made, returns NaN.
|
inline |
Return the number of samples observed
|
inline |
Get the current measurement value. This is the last value added to the statistics collector.
|
inline |
Returns the maximum value recorded. If size of list is zero, returns NaN.
|
inline |
Returns the minimum value recorded. If size of list is zero, returns NaN.
|
inline |
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
|
inline |
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.
|
inline |
Reset all calculated values. Equivalent to a new window for a moving average.