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

Last change on this file since 1615 was 1487, checked in by Jari Häkkinen, 13 years ago

Addresses #436. GPL license copy reference should also be updated.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.3 KB
Line 
1#ifndef _theplu_yat_regression_polynomialweighted_
2#define _theplu_yat_regression_polynomialweighted_
3
4// $Id: PolynomialWeighted.h 1487 2008-09-10 08:41:36Z jari $
5
6/*
7  Copyright (C) 2006, 2007 Jari Häkkinen, Peter Johansson
8  Copyright (C) 2008 Peter Johansson
9
10  This file is part of the yat library, http://dev.thep.lu.se/yat
11
12  The yat library is free software; you can redistribute it and/or
13  modify it under the terms of the GNU General Public License as
14  published by the Free Software Foundation; either version 3 of the
15  License, or (at your option) any later version.
16
17  The yat library is distributed in the hope that it will be useful,
18  but WITHOUT ANY WARRANTY; without even the implied warranty of
19  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20  General Public License for more details.
21
22  You should have received a copy of the GNU General Public License
23  along with yat. If not, see <http://www.gnu.org/licenses/>.
24*/
25
26#include "OneDimensionalWeighted.h"
27#include "MultiDimensionalWeighted.h"
28#include "yat/utility/Vector.h"
29
30namespace theplu {
31namespace yat {
32namespace regression {
33
34  ///
35  /// @brief Polynomial Regression in weighted fashion.
36  ///
37  class PolynomialWeighted : public OneDimensionalWeighted
38  {
39  public:
40
41    ///
42    /// @param power degree of polynomial model
43    ///
44    PolynomialWeighted(size_t power);
45
46    ///
47    /// @brief Destructor
48    ///
49    ~PolynomialWeighted(void);
50
51    ///
52    /// This function computes the best-fit given the polynomial model
53    /// model by minimizing \f$ \sum{w_i(\hat{y_i}-y_i)^2} \f$, where
54    /// \f$ \hat{y} \f$ is the fitted value. The weight \f$ w_i \f$
55    /// should be proportional to the inverse of the variance for \f$
56    /// y_i \f$
57    ///
58    void fit(const utility::VectorBase& x, const utility::VectorBase& y,
59             const utility::VectorBase& w);
60
61    ///
62    /// @return parameters of the model
63    ///
64    /// @see MultiDimensional
65    ///
66    const utility::Vector& fit_parameters(void) const;
67
68    ///
69    /// @brief Mean Squared Error
70    ///
71    double s2(const double w=1) const;
72
73    ///
74    /// function predicting in one point.
75    ///
76    double predict(const double x) const;
77
78    ///
79    /// @return error of model value in @a x
80    ///
81    double standard_error2(const double x) const;
82
83  private:
84    MultiDimensionalWeighted md_;
85    size_t power_;
86
87  };
88
89}}} // of namespaces regression, yat, and theplu
90
91#endif
Note: See TracBrowser for help on using the repository browser.