source: trunk/lib/statistics/OneDimensionalWeighted.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 Id
File size: 1.8 KB
Line 
1// $Id: OneDimensionalWeighted.h 495 2006-01-11 17:27:22Z 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) : x_(0.0), y_(0.0), y_err_(0.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$ is 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    /// function predicting in one point. y will contain the y(x)
47    /// according to the model. y_err will contain the estimated error
48    /// of y(x).
49    ///
50    virtual void predict(const double x, double& y, double& y_err, 
51                         const double w=1) =0;
52    ///
53    /// @return prediction value and parameters
54    ///
55    virtual std::ostream& print(std::ostream&) const=0;
56             
57    ///
58    /// @return header for print()
59    ///
60    virtual std::ostream& print_header(std::ostream& s) const=0;
61             
62  protected:
63    ///
64    /// x for predicted point
65    ///
66    double x_;
67    ///
68    /// y for predicted point
69    ///
70    double y_;
71    ///
72    /// estimated error of predicted point (in y).
73    ///
74    double y_err_;
75  };
76
77}}} // of namespaces regression, statisitcs and thep
78
79#endif
Note: See TracBrowser for help on using the repository browser.