# Changeset 483

Ignore:
Timestamp:
Jan 3, 2006, 11:23:42 AM (17 years ago)
Message:

Went through averager class. Changed function to be sum_xx and
sum_xx_centered to be in line with the rest of averagers. Also added
different kinds of the variance estimators e.g. when the mean is
known.

Location:
trunk/lib/statistics
Files:
5 edited

Unmodified
Removed
• ## trunk/lib/statistics/Averager.h

 r433 /// /// @return Mean of squared values \f$\frac{1}{n}\sum x_i^2 \f$. /// inline double mean_sqr(void) const { return n_ ? xx_/n_ : 0; } /// /// @return Number of data points /// /// /// Resets everything to zero /// @return Standard error, i.e. standard deviation of the mean /// \f$\sqrt{variance()/n} \f$ /// inline void reset(void) { n_=0; x_=xx_=0.0;} inline double standard_error(void) const { return sqrt(variance()/n_); } /// /// /// @return Standard error, i.e. standard deviation of the mean /// \f$\sqrt{variance()/n} \f$ /// The standard deviation is defined as the square root of the /// variance. /// inline double standard_error(void) const { return sqrt(variance()/n_); } /// @return Standard deviation around \a m, root of the variance(m). /// inline double std(const double m) const { return sqrt(variance(m)); } /// /// @return The sum of squares /// inline double sum_xsqr(void) const { return xx_; } inline double sum_xx(void) const { return xx_; } /// /// @return \f$\sum_i (x_i-m)^2\f$ /// inline double sum_xsqr_centered(void) const { return xx_-x_*x_/n_; } inline double sum_xx_centered(void) const { return xx_-x_*x_/n_; } /// /// \f$\frac{1}{n}\sum (x_i-m)^2 \f$. /// /// @return Variance when the mean is known to be \a m. /// inline double variance(const double m) const { return n_ ? (xx_ - 2*m*x_ + m*m) /n_ : 0; } /// /// The variance is calculated as \f$\frac{1}{N}\sum_i /// (x_i-m)^2\f$, where \f$m\f$ is the mean. /// /// @return estimation of variance /// inline double variance(void) const { return n_ ? sum_xx_centered()/n_ : 0; } /// /// mean. /// /// @return The variance /// @return unbiased estimation of variance /// inline double variance(void) const { return (n_>1) ? sum_xsqr_centered()/(n_-1) : 0; } inline double variance_unbiased(void) const { return (n_>1) ? sum_xx_centered()/(n_-1) : 0; } /// /// Resets everything to zero /// inline void reset(void) { n_=0; x_=xx_=0.0;} ///
• ## trunk/lib/statistics/AveragerPair.h

 r475 /// number of pair of values \a n /// inline AveragerPair(const double x, const double xx, const double y, const double yy, const double xy, const unsigned long n) : x_(Averager(x,xx,n)), y_(Averager(y,yy,n)), xy_(xy) {} //inline AveragerPair(const double x, const double xx, const double y, //                    const double yy, const double xy, const unsigned long n) //  : x_(Averager(x,xx,n)), y_(Averager(y,yy,n)), xy_(xy) {} /// /// \frac{1}{N} \sum (x-y)^2 \f\$ /// inline double msd() const {return x_.mean_sqr()+y_.mean_sqr()-2*mean_xy();} // Peter, fix this //    inline double msd() const {return x_.mean_sqr()+y_.mean_sqr()-2*mean_xy();} ///
• ## trunk/lib/statistics/AveragerWeighted.h

 r476 inline double sum_ww(void)  const { return w_.sum_xsqr(); } { return w_.sum_xx(); } /// /// inline double sum_wwxx(void)  const { return wx_.sum_xsqr(); } { return wx_.sum_xx(); } ///
• ## trunk/lib/statistics/Linear.cc

 r430 // estimating the noise level, i.e. the conditional variance of y // given x, Var(y|x). double Q = (ap_.y_averager().sum_xsqr_centered() - ap_.sum_xy_centered() * ap_.sum_xy_centered()/ap_.x_averager().sum_xsqr_centered() ) ; double Q = (ap_.y_averager().sum_xx_centered() - ap_.sum_xy_centered() * ap_.sum_xy_centered()/ap_.x_averager().sum_xx_centered() ) ; s2_ = Q/(x.size()-2); r2_= 1; alpha_var_ = s2_ / x.size(); beta_var_ = s2_ / ap_.x_averager().sum_xsqr_centered(); beta_var_ = s2_ / ap_.x_averager().sum_xx_centered(); m_x_ = ap_.x_averager().mean(); }
• ## trunk/lib/statistics/tScore.cc

 r475 } double diff = positive.mean() - negative.mean(); double s=sqrt((positive.sum_xsqr()+negative.sum_xsqr()) double s=sqrt((positive.sum_xx()+negative.sum_xx()) /(positive.n()+negative.n()-2)); t_=diff/s/(1.0/positive.n()+1.0/negative.n());
Note: See TracChangeset for help on using the changeset viewer.