yat/regression/Naive.h

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