Changeset 200

Ignore:
Timestamp:
Nov 1, 2004, 3:59:33 PM (19 years ago)
Message:

Simplified interface to WeightedAverager?

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
 r197 /// /// Calculating the average according to: \f$\frac{\sum /// w_ix_i}{\sum w_i}\f$ @return average /// Calculating the weighted mean /// inline double average(void) const {return mean();} /// ///Calculating the mean according to: \f$\frac{\sum ///w_ix_i}{\sum w_i} \f$ @return average /// @return \f$\frac{\sum w_ix_i}{\sum w_i} \f$ /// inline double mean(void) const { return sum_w() ? /// /// Calculating the squared sum according to: \f$\sum /// w_i^2(x_i-m)^2 \f$ @return squared error /// The variance is calculated as \f$\frac{\sum w_i^2}{(\sum /// w_i)^2-\sum w_i^2}\frac{\sum w_i(x_i-m)^2}{\sum w_i \f$ /// @return squared error /// /// @return variance of mean /// inline double standard_error(void)  const { return (squared_sum()/((sum_w()*sum_w())-squared_sum()) *squared_error()/sum_w()); } /// /// Calculating the squared sum /// /// @return \f$\sum w_i^2(x_i-m)^2 \f$ /// inline double squared_sum(void) const /// /// \f$\sum w_i^2 \f$ @return sum of squared weights /// inline double sum_ww(void)  const { return w_.sum_xsqr(); } /// /// \f$\sum w_ix_i \f$ @return weighted sum of x /// inline double sum_wx(void)  const { return wx_.sum_x(); } private: inline double sum_ww(void)  const { return w_.sum_xsqr(); } /// ///  @return \f$\sum w_i^2x_i^2 \f$ /// /// operator to add a double (with weight 1) to the object /// inline WeightedAverager operator+=(double d) { add(d); return *this; } /// /// operator to add a WeightedAverager /// inline WeightedAverager operator+=(WeightedAverager& a) { wx_+=a.wx(); w_+=a.w(); wwx_+=a.sum_wwx(); return *this; } private: Averager w_; Averager wx_;