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 weighted_mean

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

Synopsis

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

template<typename RealType> 
class weighted_mean {
public:
  // construct/copy/destruct
  weighted_mean() = default;
  weighted_mean(const RealType &, const RealType &, const RealType &, 
                const RealType &);

  // public member functions
  void operator()(const RealType &);
  void operator()(const weight_type< RealType > &, const RealType &);
  template<typename T> weighted_mean & operator+=(const weighted_mean< T > &);
  weighted_mean & operator *=(const RealType &);
  template<typename T> 
    bool operator==(const weighted_mean< T > &) const noexcept;
  template<typename T> bool operator!=(const T &) const noexcept;
  const RealType & sum_of_weights() const noexcept;
  const RealType & sum_of_weights_squared() const noexcept;
  const RealType & value() const noexcept;
  RealType variance() const;
  template<typename Archive> void serialize(Archive &, unsigned);
};

Description

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

weighted_mean public construct/copy/destruct

  1. weighted_mean() = default;
  2. weighted_mean(const RealType & wsum, const RealType & wsum2, 
                  const RealType & mean, const RealType & variance);

weighted_mean public member functions

  1. void operator()(const RealType & x);
  2. void operator()(const weight_type< RealType > & w, const RealType & x);
  3. template<typename T> 
      weighted_mean & operator+=(const weighted_mean< T > & rhs);
  4. weighted_mean & operator *=(const RealType & s);
  5. template<typename T> 
      bool operator==(const weighted_mean< T > & rhs) const noexcept;
  6. template<typename T> bool operator!=(const T & rhs) const noexcept;
  7. const RealType & sum_of_weights() const noexcept;
  8. const RealType & sum_of_weights_squared() const noexcept;
  9. const RealType & value() const noexcept;
  10. RealType variance() const;
  11. template<typename Archive> void serialize(Archive & ar, unsigned);

PrevUpHomeNext