source: trunk/c++_tools/statistics/OneDimensionalWeighted.h @ 586

Last change on this file since 586 was 586, checked in by Peter, 15 years ago

closes #23 redesign of regression classes

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 1.6 KB
Line 
1// $Id: OneDimensionalWeighted.h 586 2006-06-19 09:56:04Z peter $
2
3#ifndef _theplu_statistics_regression_onedimensioanlweighted_
4#define _theplu_statistics_regression_onedimensioanlweighted_
5
6#include <ostream>
7
8namespace theplu {
9namespace gslapi {
10  class vector;
11}
12
13namespace statistics {
14namespace regression {
15 
16  ///
17  /// Abstract Base Class for One Dimensional fitting in a weighted
18  /// fashion.
19  ///
20  /// @todo document
21  ///
22  class OneDimensionalWeighted
23  {
24 
25  public:
26    ///
27    /// Default Constructor.
28    ///
29    inline OneDimensionalWeighted(void):s2_(0)  {}
30
31    ///
32    /// Destructor
33    ///
34    virtual ~OneDimensionalWeighted(void) {};
35         
36    ///
37    /// This function computes the best-fit given a model (see
38    /// specific class for details) by minimizing \f$
39    /// \sum{w_i(\hat{y_i}-y_i)^2} \f$, where \f$ \hat{y} \f$ is the
40    /// fitted value. The weight \f$ w_i \f$ should be proportional
41    /// to the inverse of the variance for \f$ y_i \f$
42    ///
43    virtual void fit(const gslapi::vector& x, const gslapi::vector& y, 
44                     const gslapi::vector& w)=0;
45
46    ///
47    /// function predicting in one point.
48    ///
49    virtual double predict(const double x) const=0;
50
51    ///
52    /// @return expected prediction error for a new data point in @a x
53    /// with weight @a w
54    ///
55    virtual double prediction_error(const double x, const double w=1) const=0;
56
57    ///
58    /// @return error of model value in @a x
59    ///
60    virtual double standard_error(const double x) const=0;
61
62  protected:
63    double s2_; // noise level - the typical variance for a point with
64                // weight w is s2/w
65
66  };
67
68}}} // of namespaces regression, statisitcs and thep
69
70#endif
Note: See TracBrowser for help on using the repository browser.