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

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

closes #23 redesign of regression classes

• Property svn:eol-style set to native
• Property svn:keywords set to Author Date Id Revision
File size: 1.5 KB
Line
1// $Id: Naive.h 586 2006-06-19 09:56:04Z peter$
2
3#ifndef _theplu_statistics_regression_naive_
4#define _theplu_statistics_regression_naive_
5
6#include <c++_tools/statistics/OneDimensional.h>
7
8#include <c++_tools/gslapi/vector.h>
9
10#include <iostream>
11#include <utility>
12
13
14namespace theplu {
15namespace statistics {
16namespace regression {
17
18  ///
19  /// @bief naive fitting.
20  ///
21  /// @todo document
22  ///
23  class Naive : public OneDimensional
24  {
25
26  public:
27    ///
28    /// Default Constructor.
29    ///
30    inline Naive(void) : OneDimensional(), m_(0.0), m_err_(0.0) {}
31
32    ///
33    /// Copy Constructor. (not implemented)
34    ///
35    Naive(const Naive&);
36
37    ///
38    /// Destructor
39    ///
40    virtual ~Naive(void) {};
41
42    ///
43    /// This function computes the best-fit for the naive model \f$y 44 /// = m \f$ from vectors \a x and \a y, by minimizing \f$45 /// \sum{(y_i-m)^2} \f$. This function is the same as using the
46    /// weighted version with unity weights.
47    ///
48    void fit(const gslapi::vector& x, const gslapi::vector& y);
49
50    ///
51    /// Function predicting value using the naive model.
52    ///
53    double predict(const double x) const;
54
55    ///
56    /// The expected deviation from the line for a new data point. The
57    /// error has two components: the variance of point and error in
58    /// estimation of the mean.
59    ///
60    double prediction_error(const double x) const;
61
62    ///
63    /// @return standard error
64    ///
65    double standard_error(const double x) const;
66
67  private:
68    double m_;
69    double m_err_; // error of estimation of mean m_
70
71  };
72
73
74}}} // of namespaces regression, statisitcs and thep
75
76#endif
Note: See TracBrowser for help on using the repository browser.