source: trunk/c++_tools/statistics/Naive.cc @ 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 Author Date Id Revision
File size: 799 bytes
Line 
1// $Id: Naive.cc 586 2006-06-19 09:56:04Z peter $
2
3#include <c++_tools/statistics/Naive.h>
4
5#include <c++_tools/statistics/Averager.h>
6#include <c++_tools/statistics/AveragerWeighted.h>
7#include <c++_tools/statistics/OneDimensional.h>
8#include <c++_tools/gslapi/vector.h>
9
10#include <iostream>
11
12
13namespace theplu {
14namespace statistics {
15namespace regression {
16
17
18  void Naive::fit(const gslapi::vector& x, const gslapi::vector& y)
19  {
20    ap_.reset();
21    for (size_t i=0; i<y.size(); i++)
22      ap_.add(x(i),y(i));
23  }
24
25  double Naive::predict(const double x) const
26  { 
27    return ap_.y_averager().mean(); 
28  }
29 
30  double Naive::prediction_error(const double x) const
31  {
32    return sqrt(msd_*(1.0+1.0/ap_.n()));
33  }
34
35  double Naive::standard_error(const double x) const
36  {
37    return sqrt(msd_/ap_.n());
38  }
39
40
41}}} // of namespaces regression, statisitcs and thep
Note: See TracBrowser for help on using the repository browser.