source: trunk/test/regression_naive_test.cc @ 383

Last change on this file since 383 was 383, checked in by Jari Häkkinen, 16 years ago

Moved regression stuff into a namespace ...statistics::regression.
Filenames was changed and a first draft of a Polynomial regression is
implemented (compiles but does not run properly).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 588 bytes
Line 
1// $Id: regression_naive_test.cc 383 2005-08-12 15:39:24Z jari $
2
3#include <c++_tools/statistics/Naive.h>
4#include <c++_tools/gslapi/vector.h>
5
6int main()
7{ 
8  using namespace theplu;
9  bool ok=true;
10
11  gslapi::vector x(4);
12  x(0)=1970;
13  x(1)=1980;
14  x(2)=1990;
15  x(3)=2000;
16  gslapi::vector y(4);
17  y(0)=12;
18  y(1)=11;
19  y(2)=14;
20  y(3)=13;
21  gslapi::vector w(4);
22  w(0)=0.1;
23  w(1)=0.2;
24  w(2)=0.3;
25  w(3)=0.4;
26
27  statistics::regression::Naive r;
28  r.fit(x,y,w);
29  double y_predicted=0;
30  double y_predicted_err=0;
31
32  r.predict(0.0,y_predicted,y_predicted_err);
33
34  if (y_predicted!=0.1*12+0.2*11+0.3*14+0.4*13){
35    ok=false;
36  }
37
38  if (ok) 
39    return 0;
40  return -1;
41}
Note: See TracBrowser for help on using the repository browser.