Changeset 200


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

Simplified interface to WeightedAverager?

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/Merge.cc

    r197 r200  
    9999        }
    100100      }
    101       double m = w_av.average();
     101      double m = w_av.mean();
    102102      // calc. U
    103103      double U = -1;
  • trunk/src/WeightedAverager.h

    r197 r200  
    4242
    4343    ///
    44     /// Calculating the average according to: \f$ \frac{\sum
    45     /// w_ix_i}{\sum w_i}\f$ @return average
     44    /// Calculating the weighted mean
    4645    ///
    47     inline double average(void) const {return mean();}
    48 
    49     ///
    50     ///Calculating the mean according to: \f$ \frac{\sum
    51     ///w_ix_i}{\sum w_i} \f$ @return average
     46    /// @return \f$ \frac{\sum w_ix_i}{\sum w_i} \f$
    5247    ///
    5348    inline double mean(void) const { return sum_w() ?
     
    7368
    7469    ///
    75     /// Calculating the squared sum according to: \f$ \sum
    76     /// w_i^2(x_i-m)^2 \f$ @return squared error
     70    /// The variance is calculated as \f$ \frac{\sum w_i^2}{(\sum
     71    /// w_i)^2-\sum w_i^2}\frac{\sum w_i(x_i-m)^2}{\sum w_i \f$
     72    /// @return squared error
     73    ///
     74    /// @return variance of mean
     75    ///
     76    inline double standard_error(void)  const
     77    { return (squared_sum()/((sum_w()*sum_w())-squared_sum())
     78              *squared_error()/sum_w()); }
     79
     80    ///
     81    /// Calculating the squared sum 
     82    ///
     83    /// @return \f$ \sum w_i^2(x_i-m)^2 \f$
    7784    ///
    7885    inline double squared_sum(void) const
     
    8895
    8996    ///
    90     /// \f$ \sum w_i^2 \f$ @return sum of squared weights
    91     ///
    92     inline double sum_ww(void)  const
    93     { return w_.sum_xsqr(); }
    94    
    95     ///
    9697    /// \f$ \sum w_ix_i \f$ @return weighted sum of x
    9798    ///
    9899    inline double sum_wx(void)  const
    99100    { return wx_.sum_x(); }
    100    
     101
     102
     103  private:
     104    inline double sum_ww(void)  const
     105    { return w_.sum_xsqr(); }
    101106    ///
    102107    ///  @return \f$ \sum w_i^2x_i^2 \f$
     
    112117
    113118    ///
    114     /// operator to add a double (with weight 1) to the object
    115     ///
    116     inline WeightedAverager operator+=(double d)
    117     { add(d); return *this; }
    118 
    119     ///
    120119    /// operator to add a WeightedAverager
    121120    ///
    122121    inline WeightedAverager operator+=(WeightedAverager& a)
    123122    { wx_+=a.wx(); w_+=a.w(); wwx_+=a.sum_wwx(); return *this; }
    124 
    125   private:
     123   
    126124    Averager w_;
    127125    Averager wx_;
Note: See TracChangeset for help on using the changeset viewer.