source: trunk/yat/regression/PolynomialWeighted.h @ 1797

Last change on this file since 1797 was 1797, checked in by Peter, 13 years ago

updating copyright statements

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.2 KB
Line 
1#ifndef _theplu_yat_regression_polynomialweighted_
2#define _theplu_yat_regression_polynomialweighted_
3
4// $Id: PolynomialWeighted.h 1797 2009-02-12 18:07:10Z peter $
5
6/*
7  Copyright (C) 2006, 2007, 2008 Jari Häkkinen, Peter Johansson
8
9  This file is part of the yat library, http://dev.thep.lu.se/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 3 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 yat. If not, see <http://www.gnu.org/licenses/>.
23*/
24
25#include "OneDimensionalWeighted.h"
26#include "MultiDimensionalWeighted.h"
27#include "yat/utility/Vector.h"
28
29namespace theplu {
30namespace yat {
31namespace regression {
32
33  ///
34  /// @brief Polynomial Regression in weighted fashion.
35  ///
36  class PolynomialWeighted : public OneDimensionalWeighted
37  {
38  public:
39
40    ///
41    /// @param power degree of polynomial model
42    ///
43    PolynomialWeighted(size_t power);
44
45    ///
46    /// @brief Destructor
47    ///
48    ~PolynomialWeighted(void);
49
50    ///
51    /// This function computes the best-fit given the polynomial model
52    /// model by minimizing \f$ \sum{w_i(\hat{y_i}-y_i)^2} \f$, where
53    /// \f$ \hat{y} \f$ is the fitted value. The weight \f$ w_i \f$
54    /// should be proportional to the inverse of the variance for \f$
55    /// y_i \f$
56    ///
57    void fit(const utility::VectorBase& x, const utility::VectorBase& y,
58             const utility::VectorBase& w);
59
60    ///
61    /// @return parameters of the model
62    ///
63    /// @see MultiDimensional
64    ///
65    const utility::Vector& fit_parameters(void) const;
66
67    ///
68    /// @brief Mean Squared Error
69    ///
70    double s2(const double w=1) const;
71
72    ///
73    /// function predicting in one point.
74    ///
75    double predict(const double x) const;
76
77    ///
78    /// @return error of model value in @a x
79    ///
80    double standard_error2(const double x) const;
81
82  private:
83    MultiDimensionalWeighted md_;
84    size_t power_;
85
86  };
87
88}}} // of namespaces regression, yat, and theplu
89
90#endif
Note: See TracBrowser for help on using the repository browser.