Changeset 730 for trunk/yat

Ignore:
Timestamp:
Jan 6, 2007, 12:02:21 PM (16 years ago)
Message:

fixes #167 and #160

Location:
trunk/yat/regression
Files:
4 edited

Unmodified
Removed
• trunk/yat/regression/Linear.cc

 r729 alpha_ = ap_.y_averager().mean(); beta_ = ap_.covariance() / ap_.x_averager().variance(); beta_ = ap_.sum_xy_centered() / ap_.x_averager().sum_xx_centered(); // calculating deviation between data and model
• trunk/yat/regression/LinearWeighted.cc

 r729 #include "yat/utility/vector.h" #include namespace theplu { namespace yat { LinearWeighted::LinearWeighted(void) : OneDimensionalWeighted(), alpha_(0), alpha_var_(0), beta_(0), beta_var_(0), m_x_(0), s2_(0) beta_var_(0) { } double LinearWeighted::alpha_var(void) const { return sqrt(alpha_var_); return alpha_var_; } double LinearWeighted::beta_var(void) const { return sqrt(beta_var_); return beta_var_; } const utility::vector& w) { assert(x.size()==y.size()); assert(x.size()==w.size()); // AveragerPairWeighted requires 2 weights but works only on the // product wx*wy, so we can send in w and a dummie to get what we ap_.add_values(x,y,utility::vector(x.size(),1),w); // estimating the noise level. see attached document for motivation // of the expression. s2_= (syy()-sxy()*sxy()/sxx())/(w.sum()-2*(w*w)/w.sum()) ; alpha_ = m_y(); beta_ = sxy()/sxx(); alpha_var_ = ap_.y_averager().standard_error() * ap_.y_averager().standard_error(); beta_var_ = s2_/sxx(); m_x_=m_x(); chisq_=0; for (size_t i=0; i
• trunk/yat/regression/LinearWeighted.h

 r729 #include "OneDimensionalWeighted.h" #include namespace theplu { namespace yat { virtual ~LinearWeighted(void); /// /// @return the parameter \f$\alpha \f$ /// /** \f$alpha \f$ is estimated as \f$\frac{\sum w_iy_i}{\sum w_i} \f$ @return the parameter \f$\alpha \f$ */ double alpha(void) const; /// /// @return standard deviation of parameter \f$\alpha \f$ /// /** Variance is estimated as \f$\frac{s^2}{\sum w_i} \f$ @see s2() @return variance of parameter \f$\alpha \f$ */ double alpha_var(void) const; /// /// @return the parameter \f$\beta \f$ /// /** \f$beta \f$ is estimated as \f$\frac{\sum w_i(y_i-m_y)(x_i-m_x)}{\sum w_i(x_i-m_x)^2} \f$ @return the parameter \f$\beta \f$ */ double beta(void) const; /// /// @return standard deviation of parameter \f$\beta \f$ /// /** Variance is estimated as \f$\frac{s^2}{\sum w_i(x_i-m_x)^2} \f$ @see s2() @return variance of parameter \f$\beta \f$ */ double beta_var(void) const; /// \f$y =\alpha + \beta (x - m) \f$ /// double predict(const double x) const { return alpha_ + beta_ * (x-m_x_); } /// /// estimated squared deviation from predicted value for a new /// data point in @a x with weight @a w /// double prediction_error2(const double x, const double w=1) const; double predict(const double x) const; /** double beta_; double beta_var_; double m_x_; // average of x values double r2_; // coefficient of determination double s2_; double mse_; };
• trunk/yat/regression/NaiveWeighted.cc

 r729 double NaiveWeighted::standard_error2(const double x) const { return chisq_/((ap_.y_averager().n()-1)*ap_.sum_w()); return chisq_/( (ap_.y_averager().n()-1)*ap_.y_averager().sum_w() ); }
Note: See TracChangeset for help on using the changeset viewer.