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