tlx
Loading...
Searching...
No Matches
Aggregate< Type_ > Class Template Reference

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. More...

#include <aggregate.hpp>

Public Types

using Type

Public Member Functions

 Aggregate ()=default
 default constructor
 Aggregate (size_t count, const double &mean, const double &nvar, const Type &min, const Type &max) noexcept
 initializing constructor
Aggregateadd (const Type &value) noexcept
 add a value to the running aggregation
size_t count () const noexcept
 return number of values aggregated
const Type sum () const
 return sum over all values aggregated
const Type total () const
 return sum over all values aggregated
double average () const noexcept
 return the average over all values aggregated
double avg () const noexcept
 return the average over all values aggregated
double mean () const noexcept
 return the average over all values aggregated
const Typemin () const noexcept
 return minimum over all values aggregated
const Typemax () const noexcept
 return maximum 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.
double var (size_t ddof=1) const
 return the variance of all values aggregated.
double standard_deviation (size_t ddof=1) const
 return the standard deviation of all values aggregated.
double stdev (size_t ddof=1) const
 return the standard deviation of all values aggregated.
Aggregate operator+ (const Aggregate &a) const noexcept
 operator + to combine two Aggregate<>
Aggregateoperator+= (const Aggregate &a) noexcept
 operator += to combine two Aggregate<>
template<typename Archive>
void serialize (Archive &archive)
 serialization method for cereal.

Private Member Functions

double combine_means (const Aggregate &a) const noexcept
 combine means, check if either count is zero. fix problems with NaN
double combine_variance (const Aggregate &other) const noexcept
 T.

Private Attributes

size_t count_
 number of values aggregated
double mean_
 mean of values
double nvar_
 approximate count * variance; stddev = sqrt(nvar / (count-1))
Type min_
 minimum value
Type max_
 maximum value

Detailed Description

template<typename Type_>
class tlx::Aggregate< Type_ >

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.

Member Typedef Documentation

◆ Type

template<typename Type_>
using Type

Definition at line 34 of file aggregate.hpp.

Constructor & Destructor Documentation

◆ Aggregate() [1/2]

template<typename Type_>
Aggregate ( )
default

default constructor

◆ Aggregate() [2/2]

template<typename Type_>
Aggregate ( size_t count,
const double & mean,
const double & nvar,
const Type & min,
const Type & max )
inlinenoexcept

initializing constructor

Definition at line 40 of file aggregate.hpp.

Member Function Documentation

◆ add()

template<typename Type_>
Aggregate & add ( const Type & value)
inlinenoexcept

add a value to the running aggregation

Definition at line 46 of file aggregate.hpp.

◆ average()

template<typename Type_>
double average ( ) const
inlinenoexcept

return the average over all values aggregated

Definition at line 70 of file aggregate.hpp.

◆ avg()

template<typename Type_>
double avg ( ) const
inlinenoexcept

return the average over all values aggregated

Definition at line 73 of file aggregate.hpp.

◆ combine_means()

template<typename Type_>
double combine_means ( const Aggregate< Type_ > & a) const
inlineprivatenoexcept

combine means, check if either count is zero. fix problems with NaN

Definition at line 149 of file aggregate.hpp.

◆ combine_variance()

template<typename Type_>
double combine_variance ( const Aggregate< Type_ > & other) const
inlineprivatenoexcept

T.

Chan et al 1979, "Updating Formulae and a Pairwise Algorithm for Computing Sample Variances"

Definition at line 159 of file aggregate.hpp.

◆ count()

template<typename Type_>
size_t count ( ) const
inlinenoexcept

return number of values aggregated

Definition at line 60 of file aggregate.hpp.

◆ max()

template<typename Type_>
const Type & max ( ) const
inlinenoexcept

return maximum over all values aggregated

Definition at line 82 of file aggregate.hpp.

◆ mean()

template<typename Type_>
double mean ( ) const
inlinenoexcept

return the average over all values aggregated

Definition at line 76 of file aggregate.hpp.

◆ min()

template<typename Type_>
const Type & min ( ) const
inlinenoexcept

return minimum over all values aggregated

Definition at line 79 of file aggregate.hpp.

◆ operator+()

template<typename Type_>
Aggregate operator+ ( const Aggregate< Type_ > & a) const
inlinenoexcept

operator + to combine two Aggregate<>

Definition at line 119 of file aggregate.hpp.

◆ operator+=()

template<typename Type_>
Aggregate & operator+= ( const Aggregate< Type_ > & a)
inlinenoexcept

operator += to combine two Aggregate<>

Definition at line 132 of file aggregate.hpp.

◆ serialize()

template<typename Type_>
template<typename Archive>
void serialize ( Archive & archive)
inline

serialization method for cereal.

Definition at line 143 of file aggregate.hpp.

◆ span()

template<typename Type_>
Type span ( ) const
inlinenoexcept

return maximum - minimum over all values aggregated

Definition at line 85 of file aggregate.hpp.

◆ standard_deviation()

template<typename Type_>
double standard_deviation ( size_t ddof = 1) const
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.

◆ stdev()

template<typename Type_>
double stdev ( size_t ddof = 1) const
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.

◆ sum()

template<typename Type_>
const Type sum ( ) const
inline

return sum over all values aggregated

Definition at line 64 of file aggregate.hpp.

◆ total()

template<typename Type_>
const Type total ( ) const
inline

return sum over all values aggregated

Definition at line 67 of file aggregate.hpp.

◆ var()

template<typename Type_>
double var ( size_t ddof = 1) const
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.

◆ variance()

template<typename Type_>
double variance ( size_t ddof = 1) const
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.

Member Data Documentation

◆ count_

template<typename Type_>
size_t count_
private

number of values aggregated

Definition at line 166 of file aggregate.hpp.

◆ max_

template<typename Type_>
Type max_
private

maximum value

Definition at line 178 of file aggregate.hpp.

◆ mean_

template<typename Type_>
double mean_
private

mean of values

Definition at line 169 of file aggregate.hpp.

◆ min_

template<typename Type_>
Type min_
private

minimum value

Definition at line 175 of file aggregate.hpp.

◆ nvar_

template<typename Type_>
double nvar_
private

approximate count * variance; stddev = sqrt(nvar / (count-1))

Definition at line 172 of file aggregate.hpp.


The documentation for this class was generated from the following file: