11#ifndef TLX_MATH_AGGREGATE_HEADER
12#define TLX_MATH_AGGREGATE_HEADER
30template <
typename Type_>
53 double delta = value -
mean_;
92 if (
count_ <= 1)
return 0.0;
100 double var(
size_t ddof = 1)
const {
128 std::min(
min_, a.min_), std::max(
max_, a.max_));
142 template <
typename Archive>
160 double delta =
mean_ - other.mean_;
161 return nvar_ + other.nvar_ + (delta * delta) *
Aggregate & operator+=(const Aggregate &a) noexcept
operator += to combine two Aggregate<>
const Type & min() const noexcept
return minimum over all values aggregated
double standard_deviation(size_t ddof=1) const
return the standard deviation of all values aggregated.
void serialize(Archive &archive)
serialization method for cereal.
Type span() const noexcept
return maximum - minimum over all values aggregated
size_t count_
number of values aggregated
const Type sum() const
return sum over all values aggregated
double avg() const noexcept
return the average over all values aggregated
const Type & max() const noexcept
return maximum over all values aggregated
Aggregate(size_t count, const double &mean, const double &nvar, const Type &min, const Type &max) noexcept
initializing constructor
double mean_
mean of values
double stdev(size_t ddof=1) const
return the standard deviation of all values aggregated.
double combine_means(const Aggregate &a) const noexcept
combine means, check if either count is zero. fix problems with NaN
const Type total() const
return sum over all values aggregated
double variance(size_t ddof=1) const
return the variance of all values aggregated.
Aggregate operator+(const Aggregate &a) const noexcept
operator + to combine two Aggregate<>
double combine_variance(const Aggregate &other) const noexcept
T.
double average() const noexcept
return the average over all values aggregated
Aggregate()=default
default constructor
Aggregate & add(const Type &value) noexcept
add a value to the running aggregation
double nvar_
approximate count * variance; stddev = sqrt(nvar / (count-1))
size_t count() const noexcept
return number of values aggregated
double mean() const noexcept
return the average over all values aggregated
double var(size_t ddof=1) const
return the variance of all values aggregated.