Log In | Get Help   
Home My Page Projects Code Snippets Project Openings Mareframe
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files
[mareframe] Annotation of /trunk/gadget/regressionline.h
[mareframe] / trunk / gadget / regressionline.h Repository:
ViewVC logotype

Annotation of /trunk/gadget/regressionline.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (view) (download)

1 : agomez 1 #ifndef regressionline_h
2 :     #define regressionline_h
3 :    
4 :     #include "doublevector.h"
5 :    
6 :     enum LineType { FREE = 1, FIXEDSLOPE, FIXEDINTERCEPT, FIXED };
7 :    
8 :     /**
9 :     * \class Regression
10 :     * \brief This is the base class used to fit a regression line to compare 2 vectors
11 :     * \note This will always be overridden by the derived classes that actually fit the regression line
12 :     */
13 :     class Regression {
14 :     public:
15 :     /**
16 :     * \brief This is the default Regression constructor
17 :     */
18 :     Regression();
19 :     /**
20 :     * \brief This is the Regression constructor for a regression line of a specified LineType
21 :     * \param ltype is the LineType of the regression line
22 :     */
23 :     Regression(LineType ltype);
24 :     /**
25 :     * \brief This is the default Regression destructor
26 :     */
27 :     ~Regression() {};
28 :     /**
29 :     * \brief This is the function that stores 2 vectors that will be compared using a regression line
30 :     * \param modData is the DoubleVector containing the modelled data
31 :     * \param obsData is the DoubleVector containing the observed data
32 :     */
33 :     virtual void storeVectors(const DoubleVector& modData, const DoubleVector& obsData) = 0;
34 :     /**
35 :     * \brief This is the function that fits a regression line to compare the 2 vectors that have been stored, according to the LineType that has been defined
36 :     */
37 :     void calcFit();
38 :     /**
39 :     * \brief This function will set the intercept of the regression line
40 :     * \param intercept is the intercept of the regression line
41 :     */
42 :     void setIntercept(double intercept) { a = intercept; };
43 :     /**
44 :     * \brief This function will set the slope of the regression line
45 :     * \param slope is the slope of the regession line
46 :     */
47 :     void setSlope(double slope) { b = slope; };
48 :     /**
49 :     * \brief This function will set the weights that can be used to fit the regression line
50 :     * \param weights is the DoubleVector of weights to be used
51 :     */
52 :     void setWeights(const DoubleVector& weights);
53 :     /**
54 :     * \brief This function will check to see if an error has occured
55 :     * \return error
56 :     */
57 :     int getError() { return error; };
58 :     /**
59 :     * \brief This function will return the sum of squares of errors calculated when fitting the regression line
60 :     * \return sse
61 :     */
62 :     double getSSE();
63 :     /**
64 :     * \brief This function will return the intercept of the regression line
65 :     * \return a
66 :     */
67 :     double getIntercept() { return a; };
68 :     /**
69 :     * \brief This function will return the slope of the regression line
70 :     * \return b
71 :     */
72 :     double getSlope() { return b; };
73 :     /**
74 :     * \brief This function will return the fit type for the regression line
75 :     * \return fittype
76 :     */
77 :     LineType getType() const { return linetype; };
78 :     protected:
79 :     /**
80 :     * \brief This function will calculate the sum of squares of errors for the regession line
81 :     */
82 :     void calcSSE();
83 :     /**
84 :     * \brief This function will calculate the weighted sum of squares of errors for the regession line
85 :     */
86 :     void calcSSEWeights();
87 :     /**
88 :     * \brief This function will calculate the slope of the regession line
89 :     */
90 :     void calcSlope();
91 :     /**
92 :     * \brief This function will calculate the intercept of the regession line
93 :     */
94 :     void calcIntercept();
95 :     /**
96 :     * \brief This function will calculate both the slope and the intercept of the regession line
97 :     */
98 :     void calcSlopeIntercept();
99 :     /**
100 :     * \brief This is the flag to denote whether an error has occured
101 :     */
102 :     int error;
103 :     /**
104 :     * \brief This is the flag to denote whether the weights should be used when calculating the fit to the regression line
105 :     */
106 :     int useweights;
107 :     /**
108 :     * \brief This is the sum of squares of errors from the regression line
109 :     */
110 :     double sse;
111 :     /**
112 :     * \brief This is the intercept of the regression line
113 :     */
114 :     double a;
115 :     /**
116 :     * \brief This is the slope of the regression line
117 :     */
118 :     double b;
119 :     /**
120 :     * \brief This is the DoubleVector of weights that can be used to fit the regression line
121 :     */
122 :     DoubleVector w;
123 :     /**
124 :     * \brief This is the DoubleVector that will contain the the modelled data to be used to fit the regression line
125 :     */
126 :     DoubleVector x;
127 :     /**
128 :     * \brief This is the DoubleVector that will contain the the observed data to be used to fit the regression line
129 :     */
130 :     DoubleVector y;
131 :     /**
132 :     * \brief This denotes what type of line fit is to be used for the regression line
133 :     */
134 :     LineType linetype;
135 :     };
136 :    
137 :     /**
138 :     * \class LinearRegression
139 :     * \brief This is the class used to fit a linear regression line to compare 2 vectors
140 :     */
141 :     class LinearRegression : public Regression {
142 :     public:
143 :     /**
144 :     * \brief This is the default LinearRegression constructor
145 :     * \param ltype is the LineType of the regression line
146 :     */
147 :     LinearRegression(LineType ltype);
148 :     /**
149 :     * \brief This is the default LinearRegression destructor
150 :     */
151 :     ~LinearRegression() {};
152 :     /**
153 :     * \brief This is the function that stores 2 vectors that will be compared using a linear regression line
154 :     * \param modData is the DoubleVector containing the modelled data
155 :     * \param obsData is the DoubleVector containing the observed data
156 :     */
157 :     virtual void storeVectors(const DoubleVector& modData, const DoubleVector& obsData);
158 :     };
159 :    
160 :     /**
161 :     * \class LogLinearRegression
162 :     * \brief This is the class used to fit a log linear regression line to compare 2 vectors
163 :     */
164 :     class LogLinearRegression : public Regression {
165 :     public:
166 :     /**
167 :     * \brief This is the default LogLinearRegression constructor
168 :     * \param ltype is the LineType of the regression line
169 :     */
170 :     LogLinearRegression(LineType ltype);
171 :     /**
172 :     * \brief This is the default LogLinearRegression destructor
173 :     */
174 :     ~LogLinearRegression() {};
175 :     /**
176 :     * \brief This is the function that stores 2 vectors that will be compared using a log linear regression line
177 :     * \param modData is the DoubleVector containing the modelled data
178 :     * \param obsData is the DoubleVector containing the observed data
179 :     */
180 :     virtual void storeVectors(const DoubleVector& modData, const DoubleVector& obsData);
181 :     };
182 :    
183 :     /**
184 :     * \class WeightRegression
185 :     * \brief This is the class used to fit a weighted linear regression line to compare 2 vectors
186 :     */
187 :     class WeightRegression : public LinearRegression {
188 :     public:
189 :     /**
190 :     * \brief This is the default WeightRegression constructor
191 :     * \param ltype is the LineType of the regression line
192 :     */
193 :     WeightRegression(LineType ltype);
194 :     /**
195 :     * \brief This is the default WeightRegression destructor
196 :     */
197 :     ~WeightRegression() {};
198 :     /**
199 :     * \brief This is the function that stores 2 vectors that will be compared using a linear regression line
200 :     * \param modData is the DoubleVector containing the modelled data
201 :     * \param obsData is the DoubleVector containing the observed data
202 :     */
203 :     virtual void storeVectors(const DoubleVector& modData, const DoubleVector& obsData);
204 :     };
205 :    
206 :     /**
207 :     * \class LogWeightRegression
208 :     * \brief This is the class used to fit a weighted log linear regression line to compare 2 vectors
209 :     */
210 :     class LogWeightRegression : public LogLinearRegression {
211 :     public:
212 :     /**
213 :     * \brief This is the default LogWeightRegression constructor
214 :     * \param ltype is the LineType of the regression line
215 :     */
216 :     LogWeightRegression(LineType ltype);
217 :     /**
218 :     * \brief This is the default LogWeightRegression destructor
219 :     */
220 :     ~LogWeightRegression() {};
221 :     /**
222 :     * \brief This is the function that stores 2 vectors that will be compared using a log linear regression line
223 :     * \param modData is the DoubleVector containing the modelled data
224 :     * \param obsData is the DoubleVector containing the observed data
225 :     */
226 :     virtual void storeVectors(const DoubleVector& modData, const DoubleVector& obsData);
227 :     };
228 :    
229 :     #endif

root@forge.cesga.es
ViewVC Help
Powered by ViewVC 1.0.0  

Powered By FusionForge