Last change
on this file since 217 was
217,
checked in by Peter, 18 years ago
|
test_regression_local added
|
-
Property svn:eol-style set to
native
-
Property svn:keywords set to
Author Date Id Revision
|
File size:
692 bytes
|
Line | |
---|
1 | // $Id: test_regression_linear.cc 217 2004-12-29 09:37:24Z peter $ |
---|
2 | |
---|
3 | // C++ tools include |
---|
4 | //////////////////// |
---|
5 | #include "RegressionLinear.h" |
---|
6 | #include "vector.h" |
---|
7 | |
---|
8 | |
---|
9 | // Standard includes |
---|
10 | //////////////////// |
---|
11 | #include <gsl/gsl_fit.h> |
---|
12 | #include <iostream> |
---|
13 | |
---|
14 | |
---|
15 | using namespace std; |
---|
16 | |
---|
17 | int main() |
---|
18 | |
---|
19 | { |
---|
20 | bool ok=true; |
---|
21 | |
---|
22 | theplu::gslapi::vector x(4); |
---|
23 | x(0)=1970; |
---|
24 | x(1)=1980; |
---|
25 | x(2)=1990; |
---|
26 | x(3)=2000; |
---|
27 | theplu::gslapi::vector y(4); |
---|
28 | y(0)=12; |
---|
29 | y(1)=11; |
---|
30 | y(2)=14; |
---|
31 | y(3)=13; |
---|
32 | theplu::gslapi::vector w(4); |
---|
33 | w(0)=0.1; |
---|
34 | w(1)=0.2; |
---|
35 | w(2)=0.3; |
---|
36 | w(3)=0.4; |
---|
37 | |
---|
38 | theplu::statistics::RegressionLinear r; |
---|
39 | r.fit_weighted(x,w,y); |
---|
40 | printf("# best fit: Y = %g + %g X\n", r.m(), r.k()); |
---|
41 | |
---|
42 | r.fit(x,y); |
---|
43 | printf("# best fit: Y = %g + %g X\n", r.m(), r.k()); |
---|
44 | |
---|
45 | if (ok) |
---|
46 | return 0; |
---|
47 | return -1; |
---|
48 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.