STK++ 0.9.13
tutoLeastSquare.cpp
Go to the documentation of this file.
1#include <STKpp.h>
2using namespace STK;
4int main(int argc, char** argv)
5{
6 CArrayXX y(1000,3), x(1000,5), beta(5,3);
7 Law::Normal l(0,1);
8 x.rand(l);
9 beta << 0, 1, 2,
10 2, 3, 4,
11 2, 1, 6,
12 0, 3,-1,
13 3,-1, 1;
14 y = x * beta + CArrayXX(1000, 3).rand(l);
15 stk_cout << "STK++ MultiLeastSquare:\n";
16 stk_cout << "-----------------------\n";
18 stk_cout << "beta matrix:\n";
19 stk_cout << ols.x();
20 stk_cout << "\nlapack MultiLeastSquare:\n";
21 stk_cout << "------------------------\n";
23 stk_cout << "beta matrix:\n";
24 stk_cout << ls.x();
25 return 0;
26}
#define stk_cout
Standard stk output stream.
This file include all the header files of the STK++ project.
Derived & rand(Law::IUnivLaw< Type > const &law)
set random values to this using a distribution law given by the user.
ArrayB const & x() const
virtual bool run()
Compute the Least-Square solution.
Normal distribution law.
The class MultiLeastSQquare solve the least square problem when the response b is multidimensional.
The class MultiLeastSQquare solve the least square problem when the response b is multidimensional.
The namespace STK is the main domain space of the Statistical ToolKit project.
CArray< Real, UnknownSize, UnknownSize, Arrays::by_col_ > CArrayXX
Definition STK_CArray.h:50
int main(int argc, char **argv)