1 | // $Id: RegressionLocal.h 221 2004-12-30 22:36:25Z peter $ |
---|
2 | |
---|
3 | #ifndef _theplu_statistics_regression_local_ |
---|
4 | #define _theplu_statistics_regression_local_ |
---|
5 | |
---|
6 | // C++ tools include |
---|
7 | ///////////////////// |
---|
8 | #include "Regression.h" |
---|
9 | #include "RegressionKernel.h" |
---|
10 | #include "vector.h" |
---|
11 | |
---|
12 | // Standard C++ includes |
---|
13 | //////////////////////// |
---|
14 | |
---|
15 | |
---|
16 | namespace theplu { |
---|
17 | namespace statistics { |
---|
18 | |
---|
19 | |
---|
20 | /// |
---|
21 | /// Class for Locally-weighted regression. |
---|
22 | /// |
---|
23 | |
---|
24 | class RegressionLocal |
---|
25 | { |
---|
26 | |
---|
27 | public: |
---|
28 | /// |
---|
29 | /// Default Constructor. |
---|
30 | /// |
---|
31 | RegressionLocal(void); |
---|
32 | |
---|
33 | /// |
---|
34 | /// Constructor loading the object with data, type of regressor, |
---|
35 | /// type of kernel and in how many points to predict. |
---|
36 | /// |
---|
37 | RegressionLocal(const gslapi::vector& x, const gslapi::vector& y, |
---|
38 | Regression& r, RegressionKernel& k, const size_t); |
---|
39 | |
---|
40 | /// |
---|
41 | /// Copy Constructor. (Not implemented) |
---|
42 | /// |
---|
43 | RegressionLocal(const RegressionLocal&); |
---|
44 | |
---|
45 | /// |
---|
46 | /// Destructor |
---|
47 | /// |
---|
48 | virtual ~RegressionLocal(void) {}; |
---|
49 | |
---|
50 | /// |
---|
51 | /// Function returning the points where to predict |
---|
52 | /// |
---|
53 | inline gslapi::vector estimated_x(void) const { return estimated_x_; } |
---|
54 | |
---|
55 | /// |
---|
56 | /// Function returning predicted values |
---|
57 | /// |
---|
58 | inline gslapi::vector estimated_y(void) const { return estimated_y_; } |
---|
59 | |
---|
60 | /// |
---|
61 | /// Function returning error of predictions |
---|
62 | /// |
---|
63 | inline gslapi::vector estimated_y_err(void) const {return estimated_y_err_;} |
---|
64 | |
---|
65 | /// |
---|
66 | /// Function performing the fit, using a \a fraction of the data |
---|
67 | /// point and regression method defined in the constructor. The |
---|
68 | /// algorithm uses equally many points around the point to |
---|
69 | /// predict. If this is not possible (because the point is too far |
---|
70 | /// left/right) the points to the extreme left/right is used. |
---|
71 | /// |
---|
72 | void fit(const double fraction); |
---|
73 | |
---|
74 | |
---|
75 | private: |
---|
76 | std::vector<std::pair<double, double> > data_; |
---|
77 | gslapi::vector data_y_; |
---|
78 | RegressionKernel* kernel_; |
---|
79 | Regression* regression_; |
---|
80 | gslapi::vector estimated_x_; |
---|
81 | gslapi::vector estimated_y_; |
---|
82 | gslapi::vector estimated_y_err_; |
---|
83 | |
---|
84 | |
---|
85 | }; |
---|
86 | |
---|
87 | /// |
---|
88 | /// The output operator for Local Regression Class. |
---|
89 | /// |
---|
90 | std::ostream& operator<< (std::ostream& s, const RegressionLocal&); |
---|
91 | |
---|
92 | }} // of namespace statistics and namespace theplu |
---|
93 | |
---|
94 | #endif |
---|
95 | |
---|