Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext

Class template mean

boost::histogram::accumulators::mean — Calculates mean and variance of sample.

Synopsis

// In header: <boost/histogram/accumulators/mean.hpp>

template<typename ValueType> 
class mean {
public:
  // types
  typedef ValueType          value_type;     
  typedef const value_type & const_reference;

  // construct/copy/destruct
  mean() = default;
  template<typename T> mean(const mean< T > &) noexcept;
  mean(const_reference, const_reference, const_reference) noexcept;

  // public member functions
  void operator()(const_reference) noexcept;
  void operator()(const weight_type< value_type > &, const_reference) noexcept;
  mean & operator+=(const mean &) noexcept;
  mean & operator *=(const_reference) noexcept;
  bool operator==(const mean &) const noexcept;
  bool operator!=(const mean &) const noexcept;
  const_reference count() const noexcept;
  const_reference value() const noexcept;
  value_type variance() const noexcept;
  template<typename Archive> void serialize(Archive &, unsigned);
};

Description

Uses Welfords's incremental algorithm to improve the numerical stability of mean and variance computation.

mean public construct/copy/destruct

  1. mean() = default;
  2. template<typename T> mean(const mean< T > & o) noexcept;
    Allow implicit conversion from mean<T>.
  3. mean(const_reference n, const_reference mean, const_reference variance) noexcept;
    Initialize to external count, mean, and variance.

mean public member functions

  1. void operator()(const_reference x) noexcept;
    Insert sample x.
  2. void operator()(const weight_type< value_type > & w, const_reference x) noexcept;
    Insert sample x with weight w.
  3. mean & operator+=(const mean & rhs) noexcept;
    Add another mean accumulator.
  4. mean & operator *=(const_reference s) noexcept;
    Scale by value.

    This acts as if all samples were scaled by the value.

  5. bool operator==(const mean & rhs) const noexcept;
  6. bool operator!=(const mean & rhs) const noexcept;
  7. const_reference count() const noexcept;
    Return how many samples were accumulated.
  8. const_reference value() const noexcept;
    Return mean value of accumulated samples.

    The result is undefined, if count() < 1.

  9. value_type variance() const noexcept;
    Return variance of accumulated samples.

    The result is undefined, if count() < 2.

  10. template<typename Archive> void serialize(Archive & ar, unsigned version);

PrevUpHomeNext