# source:trunk/lib/statistics/Local.h@495

Last change on this file since 495 was 495, checked in by Peter, 16 years ago

modified interface for Regression::Local

• Property svn:eol-style set to `native`
• Property svn:keywords set to `Author Date Id Revision`
File size: 2.3 KB
Line
1// \$Id: Local.h 495 2006-01-11 17:27:22Z peter \$
2
3#ifndef _theplu_statistics_regression_local_
4#define _theplu_statistics_regression_local_
5
6#include <c++_tools/statistics/Kernel.h>
7#include <c++_tools/statistics/OneDimensionalWeighted.h>
8#include <c++_tools/gslapi/vector.h>
9
10#include <iostream>
11
12namespace theplu {
13namespace statistics {
14namespace regression {
15
16  ///
17  /// Class for Locally weighted regression.
18  ///
19  /// Locally weighted regression is an algorithm for learning
20  /// continuous non-linear mappings in a non-parametric manner.  In
21  /// locally weighted regression, points are weighted by proximity to
22  /// the current x in question using a Kernel. A weighted regression
23  /// is then computed using the weighted points and a specific
24  /// Regression method. This procedure is repeated, which results in
25  /// a pointwise approximation of the underlying (unknown) function.
26  ///
27  class Local
28  {
29
30  public:
31    ///
32    /// Constructor taking type of \a regressor,
33    /// type of \a kernel.
34    ///
35    inline Local(OneDimensionalWeighted& r, Kernel& k)
36      : kernel_(&k), regressor_(&r) {}
37
38    ///
39    /// Destructor
40    ///
41    virtual ~Local(void) {};
42
43
44    ///
45    /// adding a data point
46    ///
47    inline void add(const double x, const double y)
48    { data_.push_back(std::make_pair(x,y)); }
49
50    ///
51    /// Function returning predicted values
52    ///
53    inline const gslapi::vector& y_predicted(void) const
54    { return y_predicted_; }
55
56    ///
57    /// Function returning error of predictions
58    ///
59    inline const gslapi::vector& y_err(void) const { return y_err_; }
60
61    ///
62    /// @todo doc
63    /// @param nof_points Number of points used in each fit
64    /// @param step_size Size of step between each fit
65    ///
66    void fit(const size_t step_size, const size_t nof_points);
67
68    ///
69    /// @return x-values where fitting was performed.
70    ///
71    inline const gslapi::vector& x(void) const { return x_; }
72
73  private:
74    ///
75    /// Copy Constructor. (Not implemented)
76    ///
77    Local(const Local&);
78
79    std::vector<std::pair<double, double> > data_;
80    Kernel* kernel_;
81    OneDimensionalWeighted* regressor_;
82    gslapi::vector x_;
83    gslapi::vector y_predicted_;
84    gslapi::vector y_err_;
85
86  };
87
88  ///
89  /// The output operator for the RegressionLocal class.
90  ///
91  std::ostream& operator<<(std::ostream&, const Local& );
92
93
94}}} // of namespaces regression, statistics and thep
95
96#endif
Note: See TracBrowser for help on using the repository browser.