Changeset 718 for trunk/yat/regression
- Timestamp:
- Dec 26, 2006, 10:56:26 AM (17 years ago)
- Location:
- trunk/yat/regression
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/yat/regression/Linear.cc
r713 r718 41 41 { 42 42 } 43 43 44 double Linear::alpha(void) const 45 { 46 return alpha_; 47 } 48 49 double Linear::alpha_err(void) const 50 { 51 return sqrt(alpha_var_); 52 } 53 54 double Linear::beta(void) const 55 { 56 return beta_; 57 } 58 59 double Linear::beta_err(void) const 60 { 61 return sqrt(beta_var_); 62 } 44 63 45 64 double Linear::chisq(void) const … … 47 66 return chisq_; 48 67 } 49 50 68 51 69 void Linear::fit(const utility::vector& x, const utility::vector& y) … … 73 91 } 74 92 93 double Linear::r2(void) const 94 { 95 return r2_; 96 } 97 75 98 double Linear::standard_error(const double x) const 76 99 { -
trunk/yat/regression/Linear.h
r713 r718 62 62 @return the parameter \f$ \alpha \f$ 63 63 */ 64 inline double alpha(void) const { return alpha_; }64 double alpha(void) const; 65 65 66 66 /** … … 70 70 @return standard deviation of parameter \f$ \alpha \f$ 71 71 */ 72 inline double alpha_err(void) const { return sqrt(alpha_var_); }72 double alpha_err(void) const; 73 73 74 74 /** … … 78 78 @return the parameter \f$ \beta \f$ 79 79 */ 80 inline double beta(void) const { return beta_; }80 double beta(void) const; 81 81 82 82 /** … … 86 86 @return standard deviation of parameter \f$ \beta \f$ 87 87 */ 88 inline double beta_err(void) const { return sqrt(beta_var_); } 89 90 88 double beta_err(void) const; 89 91 90 /** 92 91 @brief Mean Squared Error … … 109 108 double predict(const double x) const; 110 109 110 /// 111 /// Function returning the coefficient of determination, 112 /// i.e. fraction of variance explained by the linear model. 113 /// 114 double r2(void) const; 115 111 116 /** 112 117 The error of the model is estimated as \f$ \sqrt{ … … 117 122 double standard_error(const double x) const; 118 123 119 ///120 /// Function returning the coefficient of determination,121 /// i.e. fraction of variance explained by the linear model.122 ///123 inline double r2(void) const { return r2_; }124 124 125 125 private: -
trunk/yat/regression/LinearWeighted.cc
r703 r718 42 42 } 43 43 44 double LinearWeighted::alpha(void) const 45 { 46 return alpha_; 47 } 48 49 double LinearWeighted::alpha_err(void) const 50 { 51 return sqrt(alpha_var_); 52 } 53 54 double LinearWeighted::beta(void) const 55 { 56 return beta_; 57 } 58 59 double LinearWeighted::beta_err(void) const 60 { 61 return sqrt(beta_var_); 62 } 63 44 64 void LinearWeighted::fit(const utility::vector& x, 45 65 const utility::vector& y, … … 64 84 } 65 85 86 double LinearWeighted::m_x(void) const 87 { 88 return ap_.x_averager().mean(); 89 } 90 91 double LinearWeighted::m_y(void) const 92 { 93 return ap_.y_averager().mean(); 94 } 95 96 double LinearWeighted::mse(void) const 97 { 98 return mse_; 99 } 100 101 double LinearWeighted::prediction_error(const double x, const double w) const 102 { 103 return sqrt(alpha_var_ + beta_var_*(x-m_x_)*(x-m_x_)+s2(w)); 104 } 105 106 double LinearWeighted::s2(double w) const 107 { 108 return s2_/w; 109 } 110 111 double LinearWeighted::standard_error(const double x) const 112 { 113 return sqrt(alpha_var_ + beta_var_*(x-m_x_)*(x-m_x_) ); 114 } 115 116 double LinearWeighted::sxx(void) const 117 { 118 return ap_.x_averager().sum_xx_centered(); 119 } 120 121 double LinearWeighted::sxy(void) const 122 { 123 return ap_.sum_xy_centered(); 124 } 125 126 double LinearWeighted::syy(void) const 127 { 128 return ap_.y_averager().sum_xx_centered(); 129 } 130 66 131 }}} // of namespaces regression, yat, and theplu -
trunk/yat/regression/LinearWeighted.h
r703 r718 58 58 /// @return the parameter \f$ \alpha \f$ 59 59 /// 60 inline double alpha(void) const { return alpha_; }60 double alpha(void) const; 61 61 62 62 /// 63 63 /// @return standard deviation of parameter \f$ \alpha \f$ 64 64 /// 65 inline double alpha_err(void) const { return sqrt(alpha_var_); }65 double alpha_err(void) const; 66 66 67 67 /// 68 68 /// @return the parameter \f$ \beta \f$ 69 69 /// 70 inline double beta(void) const { return beta_; }70 double beta(void) const; 71 71 72 72 /// 73 73 /// @return standard deviation of parameter \f$ \beta \f$ 74 74 /// 75 inline double beta_err(void) const { return sqrt(beta_var_); }75 double beta_err(void) const; 76 76 77 77 /** … … 90 90 /// @brief Mean Squared Error 91 91 /// 92 inline double mse(void) const { return mse_; }92 double mse(void) const; 93 93 94 94 /// … … 102 102 /// in @a x with weight @a w 103 103 /// 104 inline double prediction_error(const double x, const double w=1) const 105 { return sqrt(alpha_var_ + beta_var_*(x-m_x_)*(x-m_x_)+s2(w)); } 104 double prediction_error(const double x, const double w=1) const; 105 106 /** 107 Noise level for points with weight @a w. 108 */ 109 double s2(double w=1) const; 106 110 107 111 /** … … 109 113 Var(\beta)*(x-m)} \f$. 110 114 */ 111 inline double standard_error(const double x) const 112 { return sqrt(alpha_var_ + beta_var_*(x-m_x_)*(x-m_x_) ); } 113 114 /** 115 Noise level for points with weight @a w. 116 */ 117 inline double s2(double w=1) const { return s2_/w; } 115 double standard_error(const double x) const; 118 116 119 117 private: … … 123 121 LinearWeighted(const LinearWeighted&); 124 122 125 inline double m_x(void) const {return ap_.x_averager().mean(); }126 inline double m_y(void) const {return ap_.y_averager().mean(); }127 inline double sxx(void) const {return ap_.x_averager().sum_xx_centered(); }128 inline double syy(void) const {return ap_.y_averager().sum_xx_centered(); }129 inline double sxy(void) const {return ap_.sum_xy_centered(); }123 double m_x(void) const; 124 double m_y(void) const; 125 double sxx(void) const; 126 double syy(void) const; 127 double sxy(void) const; 130 128 131 129 double alpha_; -
trunk/yat/regression/Local.cc
r703 r718 42 42 Local::~Local(void) 43 43 { 44 } 45 46 void Local::add(const double x, const double y) 47 { 48 data_.push_back(std::make_pair(x,y)); 44 49 } 45 50 … … 114 119 } 115 120 121 const utility::vector& Local::x(void) const 122 { 123 return x_; 124 } 125 126 const utility::vector& Local::y_predicted(void) const 127 { 128 return y_predicted_; 129 } 130 131 const utility::vector& Local::y_err(void) const 132 { 133 return y_err_; 134 } 135 116 136 std::ostream& operator<<(std::ostream& os, const Local& r) 117 137 { -
trunk/yat/regression/Local.h
r703 r718 64 64 /// adding a data point 65 65 /// 66 inline void add(const double x, const double y) 67 { data_.push_back(std::make_pair(x,y)); } 66 void add(const double x, const double y); 68 67 69 ///70 /// Function returning predicted values71 ///72 inline const utility::vector& y_predicted(void) const73 { return y_predicted_; }74 75 ///76 /// Function returning error of predictions77 ///78 inline const utility::vector& y_err(void) const { return y_err_; }79 80 68 /// 81 69 /// @param nof_points Number of points used in each fit … … 87 75 /// @return x-values where fitting was performed. 88 76 /// 89 inline const utility::vector& x(void) const { return x_; } 77 const utility::vector& x(void) const; 78 79 /// 80 /// Function returning predicted values 81 /// 82 const utility::vector& y_predicted(void) const; 83 84 /// 85 /// Function returning error of predictions 86 /// 87 const utility::vector& y_err(void) const; 90 88 91 89 private: -
trunk/yat/regression/MultiDimensional.cc
r713 r718 68 68 69 69 70 double MultiDimensional::predict(const utility::vector& x) const 71 { 72 return fit_parameters_ * x; 73 } 74 75 70 76 double MultiDimensional::prediction_error(const utility::vector& x) const 71 77 { -
trunk/yat/regression/MultiDimensional.h
r713 r718 70 70 /// @return value in @a x according to fitted model 71 71 /// 72 inline double predict(const utility::vector& x) const 73 { return fit_parameters_ * x; } 72 double predict(const utility::vector& x) const; 74 73 75 74 /// -
trunk/yat/regression/MultiDimensionalWeighted.cc
r703 r718 60 60 } 61 61 62 double MultiDimensionalWeighted::predict(const utility::vector& x) const 63 { 64 return fit_parameters_ * x; 65 } 66 62 67 double MultiDimensionalWeighted::prediction_error(const utility::vector& x, 63 68 const double w) const -
trunk/yat/regression/MultiDimensionalWeighted.h
r703 r718 60 60 /// @return value in @a x according to fitted model 61 61 /// 62 inline double predict(const utility::vector& x) const 63 { return fit_parameters_ * x; } 62 double predict(const utility::vector& x) const; 64 63 65 64 /// -
trunk/yat/regression/NaiveWeighted.cc
r703 r718 52 52 } 53 53 54 double NaiveWeighted::predict(const double x) const 55 { 56 return ap_.y_averager().mean(); 57 } 58 59 double NaiveWeighted::mse(void) const 60 { 61 return ap_.y_averager().std(); 62 } 63 64 double NaiveWeighted::standard_error(const double x) const 65 { 66 return ap_.y_averager().standard_error(); 67 } 68 54 69 }}} // of namespaces regression, yat, and theplu -
trunk/yat/regression/NaiveWeighted.h
r703 r718 71 71 /// weighted average. 72 72 /// 73 inline double predict(const double x) const 74 { return ap_.y_averager().mean(); } 73 double predict(const double x) const; 75 74 76 75 /// … … 79 78 /// @see AveragerWeighted 80 79 /// 81 inline double mse(void) const { return ap_.y_averager().std(); }80 double mse(void) const; 82 81 83 82 /// 84 83 /// @return estimation of error of model value in @a x 85 84 /// 86 inline double standard_error(const double x) const 87 { return ap_.y_averager().standard_error(); } 85 double standard_error(const double x) const; 88 86 89 87 private: -
trunk/yat/regression/OneDimensional.cc
r713 r718 62 62 } 63 63 64 65 double OneDimensional::r_squared(void) const 66 { 67 return chisq()/variance(); 68 } 69 70 double OneDimensional::variance(void) const 71 { 72 return ap_.y_averager().variance(); 73 } 74 64 75 }}} // of namespaces regression, yat, and theplu -
trunk/yat/regression/OneDimensional.h
r713 r718 113 113 fraction of the variance explained by the regression model. 114 114 */ 115 inline double r_squared(void) const { return chisq()/variance(); }115 double r_squared(void) const; 116 116 117 117 /** … … 127 127 /// Variance of y 128 128 /// 129 inline double variance(void) const { return ap_.y_averager().variance(); }129 double variance(void) const; 130 130 131 131 /// -
trunk/yat/regression/PolynomialWeighted.cc
r703 r718 54 54 } 55 55 56 double PolynomialWeighted::mse(void) const 57 { 58 return mse_; 59 } 60 56 61 double PolynomialWeighted::predict(const double x) const 57 62 { -
trunk/yat/regression/PolynomialWeighted.h
r703 r718 68 68 69 69 /// 70 /// @todo71 70 /// @brief Mean Squared Error 72 71 /// 73 inline double mse(void) const { return mse_; }72 double mse(void) const; 74 73 75 74 ///
Note: See TracChangeset
for help on using the changeset viewer.