source: trunk/src/RegressionLocal.h @ 235

Last change on this file since 235 was 235, checked in by Peter, 17 years ago

Major modifications

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.3 KB
Line 
1// $Id: RegressionLocal.h 235 2005-02-21 14:53:48Z 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
16namespace theplu {
17namespace 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 taking type of \a regressor,
35    /// type of \a kernel.
36    ///
37    RegressionLocal(Regression& regressor, RegressionKernel& kernel);
38
39    ///
40    /// Copy Constructor. (Not implemented)
41    ///
42    RegressionLocal(const RegressionLocal&);
43
44    ///
45    /// Destructor
46    ///
47    virtual ~RegressionLocal(void) {};
48
49
50    ///
51    /// adding a data point
52    ///
53    inline void add(const double x, const double y) 
54    { data_.push_back(std::make_pair(x,y)); }
55
56    ///
57    /// Function returning the points where to predict
58    ///
59    inline const std::vector<double>& x(void) const { return x_; }
60
61    ///
62    /// Function returning predicted values
63    ///
64    inline const std::vector<double>& y(void) const { return y_; }
65
66    ///
67    /// Function returning error of predictions
68    ///
69    inline const std::vector<double>& y_err(void) const { return y_err_; }
70 
71    ///
72    /// Performs the fit in data defined by add using a kernel and a
73    /// regression method defined in the constructor. The algorithm
74    /// selects boundaries for the kernel such that \a fraction of the
75    /// data points are used and the point where the fit is done is in
76    /// the middle. Starting with the smallest x, the function jumps
77    /// \a step_size point in each iteration to do the next fit
78    ///
79    void fit(const double fraction, const u_int step_size=1);
80
81    ///
82    /// @return prediction values and parameters
83    ///
84    std::ostream& print(std::ostream&) const;
85             
86    ///
87    /// @return header for print()
88    ///
89    inline std::ostream& print_header(std::ostream& s) const 
90    { return regressor_->print_header(s); }
91
92         
93  private:
94    std::vector<std::pair<double, double> > data_;
95    gslapi::vector data_y_;
96    RegressionKernel* kernel_;
97    Regression* regressor_;
98    std::vector<double> x_; 
99    std::vector<double> y_;
100    std::vector<double> y_err_;
101   
102   
103  };
104
105}} // of namespace statistics and namespace theplu
106
107#endif
108
Note: See TracBrowser for help on using the repository browser.