yat/regression/MultiDimensionalWeighted.h

Code
Comments
Other
Rev Date Author Line
681 11 Oct 06 jari 1 #ifndef _theplu_yat_regression_multidimensionalweighted_
681 11 Oct 06 jari 2 #define _theplu_yat_regression_multidimensionalweighted_
586 19 Jun 06 peter 3
616 31 Aug 06 jari 4 // $Id$
586 19 Jun 06 peter 5
675 10 Oct 06 jari 6 /*
2119 12 Dec 09 peter 7   Copyright (C) 2006, 2007, 2008 Jari Häkkinen, Peter Johansson
4207 26 Aug 22 peter 8   Copyright (C) 2009, 2022 Peter Johansson
616 31 Aug 06 jari 9
1437 25 Aug 08 peter 10   This file is part of the yat library, http://dev.thep.lu.se/yat
675 10 Oct 06 jari 11
675 10 Oct 06 jari 12   The yat library is free software; you can redistribute it and/or
675 10 Oct 06 jari 13   modify it under the terms of the GNU General Public License as
1486 09 Sep 08 jari 14   published by the Free Software Foundation; either version 3 of the
675 10 Oct 06 jari 15   License, or (at your option) any later version.
675 10 Oct 06 jari 16
675 10 Oct 06 jari 17   The yat library is distributed in the hope that it will be useful,
675 10 Oct 06 jari 18   but WITHOUT ANY WARRANTY; without even the implied warranty of
675 10 Oct 06 jari 19   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
675 10 Oct 06 jari 20   General Public License for more details.
675 10 Oct 06 jari 21
675 10 Oct 06 jari 22   You should have received a copy of the GNU General Public License
1487 10 Sep 08 jari 23   along with yat. If not, see <http://www.gnu.org/licenses/>.
675 10 Oct 06 jari 24 */
675 10 Oct 06 jari 25
1121 22 Feb 08 peter 26 #include "yat/utility/Matrix.h"
1120 21 Feb 08 peter 27 #include "yat/utility/Vector.h"
675 10 Oct 06 jari 28
586 19 Jun 06 peter 29 #include <gsl/gsl_multifit.h>
586 19 Jun 06 peter 30
586 19 Jun 06 peter 31 namespace theplu {
680 11 Oct 06 jari 32 namespace yat {
586 19 Jun 06 peter 33 namespace regression {
586 19 Jun 06 peter 34
586 19 Jun 06 peter 35   ///
586 19 Jun 06 peter 36   /// @brief MultiDimesional fitting.
586 19 Jun 06 peter 37   ///
586 19 Jun 06 peter 38   class MultiDimensionalWeighted
586 19 Jun 06 peter 39   {
586 19 Jun 06 peter 40   public:
586 19 Jun 06 peter 41
586 19 Jun 06 peter 42     ///
586 19 Jun 06 peter 43     /// @brief Default Constructor
586 19 Jun 06 peter 44     ///
703 18 Dec 06 jari 45     MultiDimensionalWeighted(void);
586 19 Jun 06 peter 46
586 19 Jun 06 peter 47     ///
586 19 Jun 06 peter 48     /// @brief Destructor
586 19 Jun 06 peter 49     ///
703 18 Dec 06 jari 50     ~MultiDimensionalWeighted(void);
586 19 Jun 06 peter 51
586 19 Jun 06 peter 52     ///
741 13 Jan 07 peter 53     /// @return sum of squared residuals
741 13 Jan 07 peter 54     ///
741 13 Jan 07 peter 55     double chisq(void) const;
741 13 Jan 07 peter 56
751 17 Feb 07 jari 57     /**
751 17 Feb 07 jari 58        \see gsl_multifit_wlinear
751 17 Feb 07 jari 59
751 17 Feb 07 jari 60        \throw A GSL_error exception is thrown if memory allocation
751 17 Feb 07 jari 61        fails or the underlying GSL calls fails (usually matrix
751 17 Feb 07 jari 62        dimension errors).
751 17 Feb 07 jari 63     */
4125 14 Jan 22 peter 64     void fit(const utility::MatrixBase& X, const utility::VectorBase& y,
1022 01 Feb 08 peter 65              const utility::VectorBase& w);
586 19 Jun 06 peter 66
586 19 Jun 06 peter 67     ///
586 19 Jun 06 peter 68     /// @return value in @a x according to fitted model
586 19 Jun 06 peter 69     ///
1022 01 Feb 08 peter 70     double predict(const utility::VectorBase& x) const;
586 19 Jun 06 peter 71
586 19 Jun 06 peter 72     ///
739 12 Jan 07 peter 73     /// @return expected squared prediction error for a new data point
739 12 Jan 07 peter 74     /// in @a x
586 19 Jun 06 peter 75     ///
4200 19 Aug 22 peter 76     double prediction_error2(const utility::VectorBase& x,
2127 22 Dec 09 peter 77                              const double w=1) const;
586 19 Jun 06 peter 78
586 19 Jun 06 peter 79     ///
586 19 Jun 06 peter 80     /// @return error of model value in @a x
586 19 Jun 06 peter 81     ///
1022 01 Feb 08 peter 82     double standard_error2(const utility::VectorBase& x) const;
586 19 Jun 06 peter 83
586 19 Jun 06 peter 84     ///
648 14 Sep 06 peter 85     /// @return parameters of fitted model
586 19 Jun 06 peter 86     ///
1120 21 Feb 08 peter 87     const utility::Vector& fit_parameters(void) const;
586 19 Jun 06 peter 88
740 12 Jan 07 peter 89     ///
740 12 Jan 07 peter 90     /// @return variance of residuals
740 12 Jan 07 peter 91     ///
740 12 Jan 07 peter 92     double s2(const double w=1.0) const;
740 12 Jan 07 peter 93
586 19 Jun 06 peter 94   private:
2127 22 Dec 09 peter 95     // no copy allowed
2127 22 Dec 09 peter 96     MultiDimensionalWeighted(const MultiDimensionalWeighted&);
2127 22 Dec 09 peter 97     MultiDimensionalWeighted& operator=(const MultiDimensionalWeighted&);
2127 22 Dec 09 peter 98
586 19 Jun 06 peter 99     double chisquare_;
1121 22 Feb 08 peter 100     utility::Matrix covariance_;
1120 21 Feb 08 peter 101     utility::Vector fit_parameters_;
739 12 Jan 07 peter 102     double s2_;
586 19 Jun 06 peter 103     gsl_multifit_linear_workspace* work_;
586 19 Jun 06 peter 104
586 19 Jun 06 peter 105   };
586 19 Jun 06 peter 106
681 11 Oct 06 jari 107 }}} // of namespaces regression, yat, and theplu
586 19 Jun 06 peter 108
586 19 Jun 06 peter 109 #endif