source: trunk/c++_tools/statistics/Local.h @ 614

Last change on this file since 614 was 614, checked in by Jari Häkkinen, 15 years ago

Minor fixes in doxygen documentation.

  • 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 614 2006-08-31 05:08:05Z jari $
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    /// @param nof_points Number of points used in each fit
63    /// @param step_size Size of step between each fit
64    ///
65    void fit(const size_t step_size, const size_t nof_points);
66
67    ///
68    /// @return x-values where fitting was performed.
69    ///
70    inline const gslapi::vector& x(void) const { return x_; }
71
72  private:
73    ///
74    /// Copy Constructor. (Not implemented)
75    ///
76    Local(const Local&);
77
78    std::vector<std::pair<double, double> > data_;
79    Kernel* kernel_;
80    OneDimensionalWeighted* regressor_;
81    gslapi::vector x_;
82    gslapi::vector y_predicted_; 
83    gslapi::vector y_err_; 
84
85  };
86
87  ///
88  /// The output operator for the RegressionLocal class.
89  ///
90  std::ostream& operator<<(std::ostream&, const Local& );
91
92
93}}} // of namespaces regression, statistics and thep
94
95#endif
Note: See TracBrowser for help on using the repository browser.