Changeset 97 for trunk/src/Averager.h
 Timestamp:
 Jun 9, 2004, 6:30:41 PM (19 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/src/Averager.h
r95 r97 23 23 24 24 /// 25 /// Constructor taking the first value.25 /// Constructor taking the value of first data point. 26 26 /// 27 27 Averager(double); … … 39 39 40 40 /// 41 /// adding a data point d, with weight w (default is 1)41 /// adding n(default=1) number of data point(s) with value d. 42 42 /// 43 inline void add(const double d,const double w=1)44 {n_+= w; x_+=d*w; xx_+=d*d*w;}43 inline void add(const double d,const long n=1) 44 {n_+=n; x_+=n*d; xx_+=n*d*d;} 45 45 46 46 /// … … 50 50 51 51 /// 52 /// @return s econd moment (mean of squares)52 /// @return sum of squared values \f$ \sum x_i^2 \f$ 53 53 /// 54 54 inline double average_sqr(void) const {return mean_sqr();} 55 55 56 56 /// 57 /// @return average 57 /// @return average \f$ \frac{\sum x_i}{n} \f$ 58 58 /// 59 59 inline double mean(void) const { return n_ ? x_/n_ : 0; } 60 60 61 61 /// 62 /// @return second moment (mean of squares)62 /// @return @return sum of squared values \f$ \sum x_i^2 \f$. 63 63 /// 64 64 inline double mean_sqr(void) const { return n_ ? xx_/n_ : 0; } … … 72 72 /// resets everything to zero 73 73 /// 74 inline void reset(void) { n_= x_=xx_=0;}74 inline void reset(void) { n_=0; x_=xx_=0.0;} 75 75 76 76 /// … … 95 95 96 96 /// 97 ///The variance is calculated using the (n1) correction so the98 ///expectation value is unbiased @return variance of mean97 ///The variance is calculated using the (n1) correction, so the 98 ///expectation value is unbiased @return variance 99 99 /// 100 100 inline double variance(void) const … … 147 147 148 148 private: 149 doublen_;149 long n_; 150 150 double x_, xx_; 151 151 };
Note: See TracChangeset
for help on using the changeset viewer.