# source:trunk/test/regression_linear_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 `Author Date Id Revision`
File size: 612 bytes
RevLine
[211]1// \$Id: regression_linear_test.cc 383 2005-08-12 15:39:24Z jari \$
2
3// C++ tools include
4////////////////////
[383]5#include <c++_tools/statistics/Linear.h>
[301]6#include <c++_tools/gslapi/vector.h>
[211]7
8#include <gsl/gsl_fit.h>
9#include <iostream>
10
11
12int main()
13
14{
[301]15  using namespace theplu;
[211]16  bool ok=true;
17
[301]18  gslapi::vector x(4);
[211]19  x(0)=1970;
20  x(1)=1980;
21  x(2)=1990;
22  x(3)=2000;
[301]23  gslapi::vector y(4);
[211]24  y(0)=12;
25  y(1)=11;
26  y(2)=14;
27  y(3)=13;
[301]28  gslapi::vector w(4);
[212]29  w(0)=0.1;
30  w(1)=0.2;
31  w(2)=0.3;
32  w(3)=0.4;
[211]33
[383]34  statistics::regression::Linear r;
[223]35  r.fit(x,w,y);
[238]36  double y_predicted=0;
37  double y_predicted_err=0;
38  r.predict(0,y_predicted,y_predicted_err);
[211]39
40  if (ok)
41    return 0;
42  return -1;
43}
Note: See TracBrowser for help on using the repository browser.