Changeset 101


Ignore:
Timestamp:
Jun 10, 2004, 5:34:39 PM (18 years ago)
Author:
Peter
Message:

more readable code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/WeightedAverager.h

    r96 r101  
    4848    ///w_ix_i}{\sum w_i} \f$ @return average
    4949    ///
    50     inline double mean(void) const { return w_.sum_x() ?
    51                                        wx_.sum_x()/w_.sum_x() : 0; }
     50    inline double mean(void) const { return sum_w() ?
     51                                       sum_wx()/sum_w() : 0; }
    5252 
    5353    ///
     
    6161    ///
    6262    inline double squared_error(void) const
    63     { return (wx_.sum_xsqr()-2*mean()*wwx_+
    64               mean()*mean()*w_.sum_xsqr()) / (w_.sum_x()*w_.sum_x()); }
     63    { return (sum_wwxx()-2*mean()*wwx_+
     64              mean()*mean()*sum_ww()) / (sum_w()*sum_w()); }
    6565
    6666    ///
     
    104104    /// operator to add a WeightedAverager
    105105    ///
    106     inline WeightedAverager operator+=(WeightedAverager a)
     106    inline WeightedAverager operator+=(WeightedAverager& a)
    107107    { wx_+=a.wx(); w_+=a.w(); wwx_+=a.sum_wwx(); return *this; }
    108108
Note: See TracChangeset for help on using the changeset viewer.