Changeset 97


Ignore:
Timestamp:
Jun 9, 2004, 6:30:41 PM (18 years ago)
Author:
Peter
Message:

removed the weights

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/Averager.cc

    r95 r97  
    4747    double  var=(variance()*NM*NM+N.variance()*M*M);
    4848
    49     *this=Averager(Rn ,Rn*x ,var*Rn*(Rn-1)+x*x*Rn);
     49    *this=Averager(Rn*x ,var*Rn*(Rn-1)+x*x*Rn, Rn);
    5050    return *this;
    5151  }
     
    5959      double x=mean()/NM;
    6060      double var=(variance()+N.variance()*x*x)/(NM*NM);
    61       *this=Averager(Rn ,Rn*x ,var*Rn*(Rn-1)+x*x*Rn);
     61      *this=Averager(Rn*x ,var*Rn*(Rn-1)+x*x*Rn, Rn);
    6262    }
    6363    else
  • trunk/src/Averager.h

    r95 r97  
    2323   
    2424    ///
    25     /// Constructor taking the first value.
     25    /// Constructor taking the value of first data point.
    2626    ///
    2727    Averager(double);
     
    3939   
    4040    ///
    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.
    4242    ///
    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;}
    4545
    4646    ///
     
    5050
    5151    ///
    52     /// @return second moment (mean of squares)
     52    /// @return sum of squared values \f$ \sum x_i^2 \f$
    5353    ///
    5454    inline double average_sqr(void) const {return mean_sqr();}
    5555 
    5656    ///
    57     /// @return average
     57    /// @return average \f$ \frac{\sum x_i}{n} \f$
    5858    ///
    5959    inline double mean(void) const { return n_ ? x_/n_ : 0; }
    6060 
    6161    ///
    62     /// @return second moment (mean of squares)
     62    /// @return @return sum of squared values \f$ \sum x_i^2 \f$.
    6363    ///
    6464    inline double mean_sqr(void) const { return n_ ? xx_/n_ : 0; }
     
    7272    /// resets everything to zero
    7373    ///
    74     inline void reset(void) { n_=x_=xx_=0;}
     74    inline void reset(void) { n_=0; x_=xx_=0.0;}
    7575
    7676    ///
     
    9595
    9696    ///
    97     ///The variance is calculated using the (n-1) correction so the
    98     ///expectation value is unbiased @return variance of mean
     97    ///The variance is calculated using the (n-1) correction, so the
     98    ///expectation value is unbiased @return variance
    9999    ///
    100100    inline double variance(void) const
     
    147147
    148148  private:
    149     double  n_;
     149    long  n_;
    150150    double  x_, xx_;
    151151  };
Note: See TracChangeset for help on using the changeset viewer.