Go to the documentation of this file.
11 #ifndef TLX_MATH_AGGREGATE_HEADER
12 #define TLX_MATH_AGGREGATE_HEADER
30 template <
typename Type_>
53 double delta = value -
mean_;
73 double avg() const noexcept {
return average(); }
91 double variance(
size_t ddof = 1)
const {
92 if (
count_ <= 1)
return 0.0;
100 double var(
size_t ddof = 1)
const {
142 template <
typename Archive>
160 double delta =
mean_ - other.mean_;
161 return nvar_ + other.nvar_ + (delta * delta) *
175 Type min_ = std::numeric_limits<Type>::max();
178 Type max_ = std::numeric_limits<Type>::lowest();
185 #endif // !TLX_MATH_AGGREGATE_HEADER
static uint32_t min(uint32_t x, uint32_t y)
Aggregate operator+(const Aggregate &a) const noexcept
operator + to combine two Aggregate<>
size_t count_
number of values aggregated
Calculate running aggregate statistics: feed it with values, and it will keep the minimum,...
Aggregate()=default
default constructor
double standard_deviation(size_t ddof=1) const
return the standard deviation of all values aggregated.
double combine_variance(const Aggregate &other) const noexcept
T.
Aggregate & add(const Type &value) noexcept
add a value to the running aggregation
double var(size_t ddof=1) const
return the variance of all values aggregated.
double mean() const noexcept
return the average over all values aggregated
size_t count() const noexcept
return number of values aggregated
const Type total() const
return sum over all values aggregated
const Type & min() const noexcept
return minimum over all values aggregated
const Type sum() const
return sum over all values aggregated
double nvar_
approximate count * variance; stddev = sqrt(nvar / (count-1))
Aggregate & operator+=(const Aggregate &a) noexcept
operator += to combine two Aggregate<>
double avg() const noexcept
return the average over all values aggregated
double combine_means(const Aggregate &a) const noexcept
combine means, check if either count is zero. fix problems with NaN
double average() const noexcept
return the average over all values aggregated
Type span() const noexcept
return maximum - minimum over all values aggregated
double variance(size_t ddof=1) const
return the variance of all values aggregated.
const Type & max() const noexcept
return maximum over all values aggregated
void serialize(Archive &archive)
serialization method for cereal.
double mean_
mean of values
double stdev(size_t ddof=1) const
return the standard deviation of all values aggregated.