source: trunk/yat/regression/Naive.h

Last change on this file was 4207, checked in by Peter, 5 weeks ago

update copyright statements

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.1 KB
Line 
1#ifndef _theplu_yat_regression_naive_
2#define _theplu_yat_regression_naive_
3
4// $Id: Naive.h 4207 2022-08-26 04:36:28Z peter $
5
6/*
7  Copyright (C) 2004 Peter Johansson
8  Copyright (C) 2005, 2006, 2007, 2008 Jari Häkkinen, Peter Johansson
9  Copyright (C) 2022 Peter Johansson
10
11  This file is part of the yat library, http://dev.thep.lu.se/yat
12
13  The yat library is free software; you can redistribute it and/or
14  modify it under the terms of the GNU General Public License as
15  published by the Free Software Foundation; either version 3 of the
16  License, or (at your option) any later version.
17
18  The yat library is distributed in the hope that it will be useful,
19  but WITHOUT ANY WARRANTY; without even the implied warranty of
20  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21  General Public License for more details.
22
23  You should have received a copy of the GNU General Public License
24  along with yat. If not, see <http://www.gnu.org/licenses/>.
25*/
26
27#include "OneDimensional.h"
28
29#include <utility>
30
31namespace theplu {
32namespace yat {
33  namespace utility {
34    class VectorBase;
35  }
36namespace regression {
37
38  /**
39     @brief Naive Regression
40
41     Data are modeled as \f$ y_i = \alpha + \epsilon_i \f$
42
43  */
44  class Naive : public OneDimensional
45  {
46
47  public:
48    ///
49    /// @brief The default constructor
50    ///
51    Naive(void);
52
53    ///
54    /// @brief The destructor
55    ///
56    virtual ~Naive(void);
57
58    ///
59    /// This function computes the best-fit for the naive model \f$ y
60    /// = m \f$ from vectors \a x and \a y, by minimizing \f$
61    /// \sum{(y_i-m)^2} \f$.
62    ///
63    void fit(const utility::VectorBase& x, const utility::VectorBase& y);
64
65    ///
66    /// The predicted value is the average \f$ m \f$
67    ///
68    double predict(const double x) const;
69
70    /**
71       \f$ \frac{\sum \epsilon_i^2}{N-1} \f$
72
73       @return Conditional variance
74    */
75    double s2(void) const;
76
77    ///
78    /// \f$ \frac{s^2}{N} \f$
79    ///
80    /// @return squared standard error
81    ///
82    /// @see statistics::Averager
83    ///
84    double standard_error2(const double x) const;
85
86  private:
87    ///
88    /// @brief The copy constructor (not implemented).
89    ///
90    Naive(const Naive&);
91
92    double mse_;
93  };
94
95}}} // of namespaces regression, yat, and theplu
96
97#endif
Note: See TracBrowser for help on using the repository browser.