# Changeset 620 for trunk/c++_tools/statistics/Averager.h

Ignore:
Timestamp:
Sep 4, 2006, 5:16:57 PM (16 years ago)
Message:

Fixed problems with Averager that sometimes appeared as failures in averager_test when optimization is turned on

File:
1 edited

Unmodified
Removed
• ## trunk/c++_tools/statistics/Averager.h

 r616 /// Default constructor /// inline Averager(void) : n_(0), x_(0), xx_(0) {} Averager(void); /// /// number of samples \a n. /// inline Averager(const double x,const double xx,const long n) : n_(n), x_(x), xx_(xx) {} Averager(double x, double xx, u_long n); /// /// Copy constructor /// inline Averager(const Averager& a) : n_(a.n_), x_(a.x_), xx_(a.xx_) {} Averager(const Averager& a); /// /// Adding \a n (default=1) number of data point(s) with value \a d. /// inline void add(const double d,const long n=1) { n_+=n; x_+=n*d; xx_+=n*d*d;} inline void add(double d, u_long n=1) { n_+=n; x_+=n*d; xx_+=n*d*d;} /// /// template void  add_values(const T& v, const long n=1); void  add_values(const T& v, u_long n=1); /// /// @return Number of data points /// inline unsigned long  n(void) const { return n_; } inline u_long n(void) const { return n_; } /// /// @return Standard deviation around \a m, root of the variance(m). /// inline double std(const double m) const { return sqrt(variance(m)); } inline double std(double m) const { return sqrt(variance(m)); } /// /// @return Variance when the mean is known to be \a m. /// inline double variance(const double m) const inline double variance(double m) const { return n_ ? (xx_ - 2*m*x_ + m*m*n()) /n_ : 0; } private: unsigned long n_; u_long  n_; double  x_, xx_; }; // Template implementations template void  Averager::add_values(const T& v, const long n) void  Averager::add_values(const T& v, u_long n) { for (size_t i=0; i
Note: See TracChangeset for help on using the changeset viewer.