Thrill
0.1
|
Calculate running aggregate statistics: feed it with values, and it will keep the minimum, the maximum, the average, the value number, and the standard deviation is values.
Definition at line 31 of file aggregate.hpp.
#include <aggregate.hpp>
Public Types | |
using | Type = Type_ |
Public Member Functions | |
Aggregate ()=default | |
default constructor More... | |
Aggregate (size_t count, const double &mean, const double &nvar, const Type &min, const Type &max) noexcept | |
initializing constructor More... | |
Aggregate & | add (const Type &value) noexcept |
add a value to the running aggregation More... | |
double | average () const noexcept |
return the average over all values aggregated More... | |
double | avg () const noexcept |
return the average over all values aggregated More... | |
size_t | count () const noexcept |
return number of values aggregated More... | |
const Type & | max () const noexcept |
return maximum over all values aggregated More... | |
double | mean () const noexcept |
return the average over all values aggregated More... | |
const Type & | min () const noexcept |
return minimum over all values aggregated More... | |
Aggregate | operator+ (const Aggregate &a) const noexcept |
operator + to combine two Aggregate<> More... | |
Aggregate & | operator+= (const Aggregate &a) noexcept |
operator += to combine two Aggregate<> More... | |
template<typename Archive > | |
void | serialize (Archive &archive) |
serialization method for cereal. More... | |
Type | span () const noexcept |
return maximum - minimum over all values aggregated More... | |
double | standard_deviation (size_t ddof=1) const |
double | stdev (size_t ddof=1) const |
const Type | sum () const |
return sum over all values aggregated More... | |
const Type | total () const |
return sum over all values aggregated More... | |
double | var (size_t ddof=1) const |
double | variance (size_t ddof=1) const |
Private Member Functions | |
double | combine_means (const Aggregate &a) const noexcept |
combine means, check if either count is zero. fix problems with NaN More... | |
double | combine_variance (const Aggregate &other) const noexcept |
Private Attributes | |
size_t | count_ = 0 |
number of values aggregated More... | |
Type | max_ = std::numeric_limits<Type>::lowest() |
maximum value More... | |
double | mean_ = 0.0 |
mean of values More... | |
Type | min_ = std::numeric_limits<Type>::max() |
minimum value More... | |
double | nvar_ = 0.0 |
approximate count * variance; stddev = sqrt(nvar / (count-1)) More... | |
using Type = Type_ |
Definition at line 34 of file aggregate.hpp.
|
default |
default constructor
Referenced by Aggregate< Type_ >::operator+().
|
inlinenoexcept |
initializing constructor
Definition at line 40 of file aggregate.hpp.
add a value to the running aggregation
Definition at line 46 of file aggregate.hpp.
References Aggregate< Type_ >::count_, examples::select::delta, max(), Aggregate< Type_ >::max_, Aggregate< Type_ >::mean_, min(), Aggregate< Type_ >::min_, Aggregate< Type_ >::nvar_, and gen_data::value.
|
inlinenoexcept |
return the average over all values aggregated
Definition at line 70 of file aggregate.hpp.
References Aggregate< Type_ >::mean_.
Referenced by Aggregate< Type_ >::avg(), and Aggregate< Type_ >::mean().
|
inlinenoexcept |
return the average over all values aggregated
Definition at line 73 of file aggregate.hpp.
References Aggregate< Type_ >::average().
|
inlineprivatenoexcept |
combine means, check if either count is zero. fix problems with NaN
Definition at line 149 of file aggregate.hpp.
References Aggregate< Type_ >::count_, and Aggregate< Type_ >::mean_.
Referenced by Aggregate< Type_ >::operator+(), and Aggregate< Type_ >::operator+=().
|
inlineprivatenoexcept |
T. Chan et al 1979, "Updating Formulae and a Pairwise Algorithm for Computing Sample Variances"
Definition at line 159 of file aggregate.hpp.
References Aggregate< Type_ >::count_, examples::select::delta, Aggregate< Type_ >::mean_, and Aggregate< Type_ >::nvar_.
Referenced by Aggregate< Type_ >::operator+(), and Aggregate< Type_ >::operator+=().
|
inlinenoexcept |
return number of values aggregated
Definition at line 60 of file aggregate.hpp.
References Aggregate< Type_ >::count_.
|
inlinenoexcept |
return maximum over all values aggregated
Definition at line 82 of file aggregate.hpp.
References Aggregate< Type_ >::max_.
|
inlinenoexcept |
return the average over all values aggregated
Definition at line 76 of file aggregate.hpp.
References Aggregate< Type_ >::average().
|
inlinenoexcept |
return minimum over all values aggregated
Definition at line 79 of file aggregate.hpp.
References Aggregate< Type_ >::min_.
operator + to combine two Aggregate<>
Definition at line 119 of file aggregate.hpp.
References Aggregate< Type_ >::Aggregate(), Aggregate< Type_ >::combine_means(), Aggregate< Type_ >::combine_variance(), Aggregate< Type_ >::count_, max(), Aggregate< Type_ >::max_, min(), and Aggregate< Type_ >::min_.
operator += to combine two Aggregate<>
Definition at line 132 of file aggregate.hpp.
References Aggregate< Type_ >::combine_means(), Aggregate< Type_ >::combine_variance(), Aggregate< Type_ >::count_, max(), Aggregate< Type_ >::max_, Aggregate< Type_ >::mean_, min(), Aggregate< Type_ >::min_, and Aggregate< Type_ >::nvar_.
|
inline |
serialization method for cereal.
Definition at line 143 of file aggregate.hpp.
References Aggregate< Type_ >::count_, Aggregate< Type_ >::max_, Aggregate< Type_ >::mean_, Aggregate< Type_ >::min_, and Aggregate< Type_ >::nvar_.
|
inlinenoexcept |
return maximum - minimum over all values aggregated
Definition at line 85 of file aggregate.hpp.
References Aggregate< Type_ >::max_, and Aggregate< Type_ >::min_.
|
inline |
return the standard deviation of all values aggregated. ddof = delta degrees of freedom Set to 0 if you have the entire distribution Set to 1 if you have a sample (to correct for bias)
Definition at line 108 of file aggregate.hpp.
References Aggregate< Type_ >::variance().
Referenced by Aggregate< Type_ >::stdev().
|
inline |
return the standard deviation of all values aggregated. ddof = delta degrees of freedom Set to 0 if you have the entire distribution Set to 1 if you have a sample (to correct for bias)
Definition at line 116 of file aggregate.hpp.
References Aggregate< Type_ >::standard_deviation().
|
inline |
return sum over all values aggregated
Definition at line 64 of file aggregate.hpp.
References Aggregate< Type_ >::count_, and Aggregate< Type_ >::mean_.
Referenced by Aggregate< Type_ >::total().
|
inline |
return sum over all values aggregated
Definition at line 67 of file aggregate.hpp.
References Aggregate< Type_ >::sum().
|
inline |
return the variance of all values aggregated. ddof = delta degrees of freedom Set to 0 if you have the entire distribution Set to 1 if you have a sample (to correct for bias)
Definition at line 100 of file aggregate.hpp.
References Aggregate< Type_ >::variance().
|
inline |
return the variance of all values aggregated. ddof = delta degrees of freedom Set to 0 if you have the entire distribution Set to 1 if you have a sample (to correct for bias)
Definition at line 91 of file aggregate.hpp.
References Aggregate< Type_ >::count_, and Aggregate< Type_ >::nvar_.
Referenced by Aggregate< Type_ >::standard_deviation(), and Aggregate< Type_ >::var().
|
private |
number of values aggregated
Definition at line 166 of file aggregate.hpp.
Referenced by Aggregate< Type_ >::add(), Aggregate< Type_ >::combine_means(), Aggregate< Type_ >::combine_variance(), Aggregate< Type_ >::count(), Aggregate< Type_ >::operator+(), Aggregate< Type_ >::operator+=(), Aggregate< Type_ >::serialize(), Aggregate< Type_ >::sum(), and Aggregate< Type_ >::variance().
maximum value
Definition at line 178 of file aggregate.hpp.
Referenced by Aggregate< Type_ >::add(), Aggregate< Type_ >::max(), Aggregate< Type_ >::operator+(), Aggregate< Type_ >::operator+=(), Aggregate< Type_ >::serialize(), and Aggregate< Type_ >::span().
|
private |
mean of values
Definition at line 169 of file aggregate.hpp.
Referenced by Aggregate< Type_ >::add(), Aggregate< Type_ >::average(), Aggregate< Type_ >::combine_means(), Aggregate< Type_ >::combine_variance(), Aggregate< Type_ >::operator+=(), Aggregate< Type_ >::serialize(), and Aggregate< Type_ >::sum().
minimum value
Definition at line 175 of file aggregate.hpp.
Referenced by Aggregate< Type_ >::add(), Aggregate< Type_ >::min(), Aggregate< Type_ >::operator+(), Aggregate< Type_ >::operator+=(), Aggregate< Type_ >::serialize(), and Aggregate< Type_ >::span().
|
private |
approximate count * variance; stddev = sqrt(nvar / (count-1))
Definition at line 172 of file aggregate.hpp.
Referenced by Aggregate< Type_ >::add(), Aggregate< Type_ >::combine_variance(), Aggregate< Type_ >::operator+=(), Aggregate< Type_ >::serialize(), and Aggregate< Type_ >::variance().