Changeset 639 for trunk/c++_tools/statistics/LinearWeighted.h
- Timestamp:
- Sep 6, 2006, 2:18:46 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/c++_tools/statistics/LinearWeighted.h
r616 r639 57 57 inline double beta_err(void) const { return sqrt(beta_var_); } 58 58 59 / //60 ///This function computes the best-fit linear regression61 ///coefficients \f$ (\alpha, \beta)\f$ of the model \f$ y =62 ///\alpha + \beta (x-m_x) \f$ from vectors \a x and \a y, by63 ///minimizing \f$ \sum{w_i(y_i - \alpha - \beta (x-m_x))^2} \f$,64 ///where \f$ m_x \f$ is the weighted average. By construction \f$65 ///\alpha \f$ and \f$ \beta \f$ are independent.66 ///59 /** 60 This function computes the best-fit linear regression 61 coefficients \f$ (\alpha, \beta)\f$ of the model \f$ y = 62 \alpha + \beta (x-m_x) \f$ from vectors \a x and \a y, by 63 minimizing \f$ \sum{w_i(y_i - \alpha - \beta (x-m_x))^2} \f$, 64 where \f$ m_x \f$ is the weighted average. By construction \f$ 65 \alpha \f$ and \f$ \beta \f$ are independent. 66 **/ 67 67 void fit(const utility::vector& x, const utility::vector& y, 68 68 const utility::vector& w); 69 69 70 70 /// 71 /// Function predicting value using the linear model: \f$ y = 72 /// \alpha + \beta (x - m) 71 /// Function predicting value using the linear model: 72 /// \f$ y =\alpha + \beta (x - m) \f$ 73 /// 73 74 double predict(const double x) const { return alpha_ + beta_ * (x-m_x_); } 74 75 … … 80 81 { return sqrt(alpha_var_ + beta_var_*(x-m_x_)*(x-m_x_)+s2_/w); } 81 82 82 / //83 /// estimated error @a y_err \f$ y_err= \sqrt{ Var(\alpha) +84 /// Var(\beta)*(x-m)^2 }.85 ///83 /** 84 estimated error \f$ y_{err} = \sqrt{ Var(\alpha) + 85 Var(\beta)*(x-m)} \f$. 86 **/ 86 87 inline double standard_error(const double x) const 87 88 { return sqrt(alpha_var_ + beta_var_*(x-m_x_)*(x-m_x_) ); }
Note: See TracChangeset
for help on using the changeset viewer.