Changeset 727 for trunk/yat/regression
- Timestamp:
- Jan 4, 2007, 4:06:14 PM (17 years ago)
- Location:
- trunk/yat/regression
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/yat/regression/Linear.cc
r726 r727 97 97 } 98 98 99 double Linear::standard_error (const double x) const99 double Linear::standard_error2(const double x) const 100 100 { 101 return sqrt(alpha_var_+beta_var_*(x-ap_.x_averager().mean())*102 (x-ap_.x_averager().mean()));101 return alpha_var_+beta_var_*(x-ap_.x_averager().mean())* 102 (x-ap_.x_averager().mean()); 103 103 } 104 104 -
trunk/yat/regression/Linear.h
r726 r727 113 113 114 114 /** 115 The error of the model is estimated as \f$ \sqrt{116 \textrm{alpha\_err}^2+\textrm{beta\_err}^2*(x-m_x)*(x-m_x) }\f$115 The error of the model is estimated as \f$ 116 \textrm{alpha\_err}^2+\textrm{beta\_err}^2*(x-m_x)*(x-m_x)\f$ 117 117 118 118 @return estimated error of model in @a x 119 119 */ 120 double standard_error (const double x) const;120 double standard_error2(const double x) const; 121 121 122 122 -
trunk/yat/regression/MultiDimensional.cc
r726 r727 80 80 81 81 82 double MultiDimensional::prediction_error(const utility::vector& x) const 82 double MultiDimensional::prediction_error2(const utility::vector& x) const 83 { 84 return standard_error2(x)+chisquare_; 85 } 86 87 88 double MultiDimensional::standard_error2(const utility::vector& x) const 83 89 { 84 90 double s2 = 0; … … 88 94 s2 += 2*covariance_(i,j)*x(i)*x(j); 89 95 } 90 return sqrt(s2+chisquare_); 91 } 92 93 94 double MultiDimensional::standard_error(const utility::vector& x) const 95 { 96 double s2 = 0; 97 for (size_t i=0; i<x.size(); ++i){ 98 s2 += covariance_(i,i)*x(i)*x(i); 99 for (size_t j=i+1; j<x.size(); ++j) 100 s2 += 2*covariance_(i,j)*x(i)*x(j); 101 } 102 return sqrt(s2); 96 return s2; 103 97 } 104 98 -
trunk/yat/regression/MultiDimensional.h
r726 r727 78 78 79 79 /// 80 /// @return expected prediction error for a new data point in @a x 80 /// @return expected squared prediction error for a new data point 81 /// in @a x 81 82 /// 82 double prediction_error (const utility::vector& x) const;83 double prediction_error2(const utility::vector& x) const; 83 84 84 85 /// 85 /// @return error of model value in @a x86 /// @return squared error of model value in @a x 86 87 /// 87 double standard_error (const utility::vector& x) const;88 double standard_error2(const utility::vector& x) const; 88 89 89 90 private: -
trunk/yat/regression/Naive.cc
r726 r727 66 66 67 67 68 double Naive::standard_error (const double x) const68 double Naive::standard_error2(const double x) const 69 69 { 70 return ap_.y_averager().standard_error();70 return chisq()/ap_.n()/(ap_.n()-1); 71 71 } 72 72 -
trunk/yat/regression/Naive.h
r726 r727 79 79 /// @see statistics::Averager 80 80 /// 81 double standard_error (const double x) const;81 double standard_error2(const double x) const; 82 82 83 83 private: -
trunk/yat/regression/OneDimensional.cc
r718 r727 37 37 38 38 39 double OneDimensional::prediction_error (const double x) const39 double OneDimensional::prediction_error2(const double x) const 40 40 { 41 return sqrt(chisq()+pow(standard_error(x),2));41 return chisq()+standard_error2(x); 42 42 } 43 43 … … 56 56 for ( double x=min; x<=max; x+=dx) { 57 57 double y = predict(x); 58 double y_err = prediction_error(x);58 double y_err = sqrt(prediction_error2(x)); 59 59 os << x << "\t" << y << "\t" << y_err << "\n"; 60 60 } -
trunk/yat/regression/OneDimensional.h
r726 r727 64 64 65 65 /** 66 This function computes the best-fit given a model (see 67 specific class for details) by minimizing \f$68 \ sum{(\hat{y_i}-y_i)^2} \f$, where \f$ \hat{y} \f$ is the fitted value.66 This function computes the best-fit given a model (see specific 67 class for details) by minimizing \f$ \sum{(\hat{y_i}-y_i)^2} 68 \f$, where \f$ \hat{y} \f$ is the fitted value. 69 69 */ 70 70 virtual void fit(const utility::vector& x, const utility::vector& y)=0; … … 76 76 77 77 /** 78 The prediction error is defined as the square root of the 79 expected squared deviation a new data point will have from 80 value the model provides. The expected squared deviation is 81 defined as \f$ E(Y|x - \hat{y}(x))^2 \f$ and is typically 78 The prediction error is defined as the expected squared 79 deviation a new data point will have from value the model 80 provides: \f$ E(Y|x - \hat{y}(x))^2 \f$ and is typically 82 81 divided into two terms \f$ E(Y|x - E(Y|x))^2 \f$ and \f$ 83 82 E(E(Y|x) - \hat{y}(x))^2 \f$, which is the conditional variance 84 83 given \f$ x \f$ and the squared standard error (see 85 standard_error ()) of the model estimation in \f$ x \f$,84 standard_error2()) of the model estimation in \f$ x \f$, 86 85 respectively. 87 86 88 @return expected prediction error for a new data point in @a x 87 @return expected squared prediction error for a new data point 88 in @a x 89 89 */ 90 double prediction_error (const double x) const;90 double prediction_error2(const double x) const; 91 91 92 92 /// … … 114 114 115 115 /** 116 The standard error is defined as \f$ \sqrt{E(Y|x - 117 \hat{y}(x))^2 }\f$ 116 The standard error is defined as \f$ E(Y|x - \hat{y}(x))^2 \f$ 118 117 119 @return expected error of model value in @a x118 @return expected squared error of model value in @a x 120 119 */ 121 virtual double standard_error (const double x) const=0;120 virtual double standard_error2(const double x) const=0; 122 121 123 122 protected: -
trunk/yat/regression/Polynomial.cc
r726 r727 78 78 79 79 80 double Polynomial::standard_error (const double x) const80 double Polynomial::standard_error2(const double x) const 81 81 { 82 82 utility::vector vec(power_+1,1); 83 83 for (size_t i=1; i<=power_; ++i) 84 84 vec(i) = vec(i-1)*x; 85 return md_.standard_error (vec);85 return md_.standard_error2(vec); 86 86 } 87 87 -
trunk/yat/regression/Polynomial.h
r726 r727 86 86 87 87 /// 88 /// @return error of model value in @a x88 /// @return squared error of model value in @a x 89 89 /// 90 double standard_error (const double x) const;90 double standard_error2(const double x) const; 91 91 92 92 private:
Note: See TracChangeset
for help on using the changeset viewer.