Changeset 1643 for trunk/yat/regression/CSpline.h
 Timestamp:
 Dec 13, 2008, 1:23:39 AM (14 years ago)
 File:

 1 copied
Legend:
 Unmodified
 Added
 Removed

trunk/yat/regression/CSpline.h
r1637 r1643 1 #ifndef _theplu_yat_regression_ linear_2 #define _theplu_yat_regression_ linear_1 #ifndef _theplu_yat_regression_cspline_ 2 #define _theplu_yat_regression_cspline_ 3 3 4 4 // $Id$ 5 5 6 6 /* 7 Copyright (C) 2004, 2005, 2006, 2007 Jari Häkkinen, Peter Johansson 8 Copyright (C) 2008 Peter Johansson 7 Copyright (C) 2008 Jari Häkkinen 9 8 10 9 This file is part of the yat library, http://dev.thep.lu.se/yat … … 24 23 */ 25 24 26 #include "OneDimensional.h" 27 28 #include <cmath> 25 #include "GSLInterpolation.h" 29 26 30 27 namespace theplu { 31 28 namespace yat { 32 33 class VectorBase;34 29 namespace utility { 30 class VectorConstView; 31 } 35 32 namespace regression { 36 33 37 34 /** 38 @brief linear regression. 39 40 Data are modeled as \f$ y_i = \alpha + \beta (x_im_x) + 41 \epsilon_i \f$. 35 @brief Documentation please. 42 36 */ 43 class Linear : public OneDimensional 44 { 45 46 public: 47 /// 48 /// @brief The default constructor 49 /// 50 Linear(void); 37 class CSpline : public GSLInterpolation 38 { 51 39 52 /// 53 /// @brief The destructor 54 /// 55 virtual ~Linear(void); 56 40 public: 57 41 /** 58 The parameter \f$ \alpha \f$ is estimated as \f$ 59 \frac{1}{n}\sum y_i \f$ 60 61 @return the parameter \f$ \alpha \f$ 42 @brief The default constructor 62 43 */ 63 double alpha(void) const; 44 CSpline(const utility::VectorConstView& x, 45 const utility::VectorConstView& y); 64 46 65 47 /** 66 The standard deviation is estimated as \f$ \sqrt{\frac{s^2}{n}} 67 \f$ where \f$ s^2 = \frac{\sum \epsilon^2}{n2} \f$ 68 69 @return standard deviation of parameter \f$ \alpha \f$ 48 @brief The destructor 70 49 */ 71 double alpha_var(void) const;50 ~CSpline(void); 72 51 52 private: 73 53 /** 74 The parameter \f$ \beta \f$ is estimated as \f$ 75 \frac{\textrm{Cov}(x,y)}{\textrm{Var}(x)} \f$ 76 77 @return the parameter \f$ \beta \f$ 54 Copy Constructor. (not implemented) 78 55 */ 79 double beta(void) const;56 CSpline(const CSpline&); 80 57 81 /**82 The standard deviation is estimated as \f$ \frac{s^2}{\sum83 (xm_x)^2} \f$ where \f$ s^2 = \frac{\sum \epsilon^2}{n2} \f$84 85 @return standard deviation of parameter \f$ \beta \f$86 */87 double beta_var(void) const;88 89 /**90 Model is fitted by minimizing \f$ \sum{(y_i  \alpha  \beta91 (xm_x))^2} \f$. By construction \f$ \alpha \f$ and \f$ \beta \f$92 are independent.93 */94 void fit(const utility::VectorBase& x, const utility::VectorBase& y) ;95 96 ///97 /// @return \f$ \alpha + \beta x \f$98 ///99 double predict(const double x) const;100 101 /**102 \f$ \frac{\sum \epsilon_i^2}{N2} \f$103 104 @return variance of residuals105 */106 double s2(void) const;107 108 /**109 The error of the model is estimated as \f$110 \textrm{alpha\_err}^2+\textrm{beta\_err}^2*(xm_x)*(xm_x)\f$111 112 @return estimated error of model in @a x113 */114 double standard_error2(const double x) const;115 116 117 private:118 ///119 /// Copy Constructor. (not implemented)120 ///121 Linear(const Linear&);122 123 double alpha_;124 double alpha_var_;125 double beta_;126 double beta_var_;127 58 }; 128 59
Note: See TracChangeset
for help on using the changeset viewer.