source: trunk/test/regression_local_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: 946 bytes
Line 
1// $Id: regression_local_test.cc 383 2005-08-12 15:39:24Z jari $
2
3#include <c++_tools/statistics/KernelBox.h>
4#include <c++_tools/statistics/Linear.h>
5#include <c++_tools/statistics/Local.h>
6#include <c++_tools/statistics/Naive.h>
7#include <c++_tools/gslapi/vector.h>
8
9#include <string>
10#include <cmath>
11#include <fstream>
12#include <iostream>
13#include <vector>
14
15using namespace theplu;
16
17bool test(statistics::regression::OneDimensional& r, statistics::Kernel& k)
18{
19  statistics::regression::Local rl(r,k);
20  for (size_t i=0; i<1000; i++){
21    double x = i;
22    double y = 10.0;
23    rl.add(x, y);
24  }
25
26  std::ofstream myout("data/tmp.txt");
27  rl.fit(myout,0.1,1);
28
29  std::vector<double> y = rl.y();
30  for (size_t i=0; i<y.size(); i++) 
31    if (y[i]!=10.0){
32      return false;
33    }
34  return true;
35}
36
37int main()
38
39{ 
40  bool ok=true;
41 
42  statistics::regression::Naive rn;
43  statistics::KernelBox kb;
44  ok = (ok && test(rn,kb));
45
46  statistics::regression::Linear rl;
47  ok = (ok && test(rl,kb));
48
49
50  if (ok) 
51    return 0;
52  return -1;
53}
Note: See TracBrowser for help on using the repository browser.