...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
boost::histogram::accumulators::mean — Calculates mean and variance of sample.
// In header: <boost/histogram/accumulators/mean.hpp> template<typename RealType> class mean { public: // construct/copy/destruct mean() = default; mean(const RealType &, const RealType &, const RealType &) noexcept; // public member functions void operator()(const RealType &) noexcept; void operator()(const weight_type< RealType > &, const RealType &) noexcept; template<typename T> mean & operator+=(const mean< T > &) noexcept; mean & operator *=(const RealType &) noexcept; template<typename T> bool operator==(const mean< T > &) const noexcept; template<typename T> bool operator!=(const mean< T > &) const noexcept; const RealType & count() const noexcept; const RealType & value() const noexcept; RealType variance() const noexcept; template<typename Archive> void serialize(Archive &, unsigned); };
Uses Welfords's incremental algorithm to improve the numerical stability of mean and variance computation.
mean
public member functionsvoid operator()(const RealType & x) noexcept;
void operator()(const weight_type< RealType > & w, const RealType & x) noexcept;
template<typename T> mean & operator+=(const mean< T > & rhs) noexcept;
mean & operator *=(const RealType & s) noexcept;
template<typename T> bool operator==(const mean< T > & rhs) const noexcept;
template<typename T> bool operator!=(const mean< T > & rhs) const noexcept;
const RealType & count() const noexcept;
const RealType & value() const noexcept;
RealType variance() const noexcept;
template<typename Archive> void serialize(Archive & ar, unsigned version);