source: trunk/lib/statistics/Naive.cc @ 430

Last change on this file since 430 was 430, checked in by Peter, 18 years ago

changed interface of Regression::Local

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 837 bytes
Line 
1// $Id: Naive.cc 430 2005-12-08 22:53:08Z 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  void Naive::predict(const double x, double& y, double& y_err) const
26  { 
27    y = ap_.x_averager().mean(); 
28    y_err = ap_.x_averager().std()*(1.0+1.0/ap_.n());
29  }
30 
31  std::ostream& Naive::print_header(std::ostream& s) const
32  {
33    s << "# column 1: x\n"
34      << "# column 2: y\n"
35      << "# column 3: y_err";
36    return s;
37  }
38
39
40}}} // of namespaces regression, statisitcs and thep
Note: See TracBrowser for help on using the repository browser.