source: trunk/yat/regression/OneDimensional.h @ 695

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

References #81 improved documentation

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.4 KB
Line 
1#ifndef _theplu_yat_regression_onedimensional_
2#define _theplu_yat_regression_onedimensional_
3
4// $Id: OneDimensional.h 695 2006-10-25 09:20:17Z peter $
5
6/*
7  Copyright (C) The authors contributing to this file.
8
9  This file is part of the yat library, http://lev.thep.lu.se/trac/yat
10
11  The yat library is free software; you can redistribute it and/or
12  modify it under the terms of the GNU General Public License as
13  published by the Free Software Foundation; either version 2 of the
14  License, or (at your option) any later version.
15
16  The yat library is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  General Public License for more details.
20
21  You should have received a copy of the GNU General Public License
22  along with this program; if not, write to the Free Software
23  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
24  02111-1307, USA.
25*/
26
27#include "yat/statistics/AveragerPair.h"
28
29#include <ostream>
30
31namespace theplu {
32namespace yat {
33namespace utility {
34  class vector;
35}
36namespace regression {
37 
38  ///
39  /// Abstract Base Class for One Dimensional fitting.   
40  ///
41  /// @todo document
42  ///
43  class OneDimensional
44  {
45 
46  public:
47    ///
48    /// Default Constructor.
49    ///
50    inline OneDimensional(void) {}
51
52    ///
53    /// Destructor
54    ///
55    virtual ~OneDimensional(void) {};
56         
57    /**
58       This function computes the best-fit given a model (see
59       specific class for details) by minimizing \f$
60       \sum{(\hat{y_i}-y_i)^2} \f$, where \f$ \hat{y} \f$ is the fitted value.
61    */
62    virtual void fit(const utility::vector& x, const utility::vector& y)=0; 
63   
64    ///
65    /// @return expected value in @a x accrding to the fitted model
66    ///
67    virtual double predict(const double x) const=0;
68
69    /**
70       The prediction error is defined as the square root of the
71       expected squared deviation a new data point will have from
72       value the model provides. The expected squared deviation is
73       defined as \f$ E(Y|x - \hat{y}(x))^2 \f$ and is typically
74       divided into two terms \f$ E(Y|x - E(Y|x))^2 \f$ and \f$
75       E(E(Y|x) - \hat{y}(x))^2 \f$, which is the conditional variance
76       in \f$ x \f$ and the squared standard error (see
77       standard_error()) of the model estimation in \f$ x \f$,
78       respectively.
79   
80       @return expected prediction error for a new data point in @a x
81    */
82    virtual double prediction_error(const double x) const=0;
83
84    ///
85    /// @brief print output to ostream @a os
86    ///
87    /// Printing estimated model to @a os in the points defined by @a
88    /// min, @a max, and @a n. The values printed for each point is
89    /// the x-value, the estimated y-value, and the estimated standard
90    /// deviation of a new data poiunt will have from the y-value
91    /// given the x-value (see prediction_error()).
92    ///
93    /// @param n number of points printed
94    /// @param min smallest x-value for which the model is printed
95    /// @param max largest x-value for which the model is printed
96    ///
97    std::ostream& print(std::ostream& os,const double min, 
98                        double max, const u_int n) const;
99
100    /**
101       The standard error is defined as \f$ \sqrt{E(Y|x -
102       \hat{y}(x))^2 }\f$
103
104       @return error of model value in @a x
105    */
106    virtual double standard_error(const double x) const=0;
107
108  protected:
109    ///
110    /// Averager for pair of x and y
111    ///
112    statistics::AveragerPair ap_;
113
114    ///
115    /// mean squared deviation (model from data points)
116    ///
117    double msd_; 
118  };
119
120}}} // of namespaces regression, yat, and theplu
121
122#endif
Note: See TracBrowser for help on using the repository browser.