source: trunk/c++_tools/statistics/MultiDimensional.h @ 586

Last change on this file since 586 was 586, checked in by Peter, 15 years ago

closes #23 redesign of regression classes

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 1.4 KB
Line 
1// $Id: MultiDimensional.h 586 2006-06-19 09:56:04Z peter $
2
3#ifndef _theplu_statistics_regression_multidimensional_
4#define _theplu_statistics_regression_multidimensional_
5
6#include <c++_tools/gslapi/matrix.h>
7#include <c++_tools/gslapi/vector.h>
8
9#include <gsl/gsl_multifit.h>
10
11
12namespace theplu {
13namespace statistics {
14namespace regression {
15
16  ///
17  /// @brief MultiDimesional fitting.
18  ///
19  class MultiDimensional
20  {
21  public:
22
23    ///
24    /// @brief Default Constructor
25    ///
26    inline MultiDimensional(void) : chisquare_(0), work_(NULL) {}
27
28    ///
29    /// @brief Destructor
30    ///
31    inline ~MultiDimensional(void) { if (work_) gsl_multifit_linear_free(work_);}
32
33    ///
34    ///
35    ///
36    void fit(const gslapi::matrix& X, const gslapi::vector& y);
37
38    ///
39    ///
40    ///
41    gslapi::vector fit_parameters(void) { return fit_parameters_; }
42
43    ///
44    /// @return value in @a x according to fitted model
45    ///
46    inline double predict(const gslapi::vector& x) const 
47    { return fit_parameters_ * x; }
48
49    ///
50    /// @return expected prediction error for a new data point in @a x
51    ///
52    double prediction_error(const gslapi::vector& x) const;
53
54    ///
55    /// @return error of model value in @a x
56    ///
57    double standard_error(const gslapi::vector& x) const;
58
59  private:
60    double chisquare_;
61    gslapi::matrix covariance_;
62    gslapi::vector fit_parameters_;
63    gsl_multifit_linear_workspace* work_;
64
65  };
66
67
68}}} // of namespaces regression, statisitcs and thep
69
70#endif
Note: See TracBrowser for help on using the repository browser.