[Home] [News] [API] [Example usage] [FAQ] [Roadmap] [Download] [Contact]

Regression

   1: /***************************************************************************
   2:                           main.cpp  -  description
   3:                              -------------------
   4:     begin                : Sun Feb 17 21:06:25 EST 2002
   5:     copyright            : (C) 2002 by Antonio
   6:     email                : alrl1@alu.um.es
   7:  ***************************************************************************/
   9: 
  10: /***************************************************************************
  11:  *                                                                         *
  12:  *   This program is free software; you can redistribute it and/or modify  *
  13:  *   it under the terms of the GNU General Public License as published by  *
  14:  *   the Free Software Foundation; either version 2 of the License, or     *
  15:  *   (at your option) any later version.                                   *
  16:  *                                                                         *
  17:  ***************************************************************************/
  19: 
  20: #include <iostream> 
  21: using namespace std;
  22: 
  23: #include "../CMatrix/cmatrix.h" 
  24: 
  25: #define	DATA	100	// number of input data 
  26: #define	VARS	12	// number of vars 
  27: 
  28: int main(void)	{
  29: 
  30: 	CMatrix	A(DATA,VARS,0.0);
  31: 	CMatrix b(DATA,1,0.0);
  32: 	CMatrix m(VARS,1,0.0);
  33: 	CMatrix x(VARS,1,0.0);
  34: 
  35: 	// we get data A randomized, and, (shhh) the supposely unknown vector m.
  36: 	A.randomize(1,100,1);
  37: 	m.randomize(1,100,1);
  38: 	m.print("m");
  39: 
  40: 	// we compute the supposed output for vector m and data A.
  41: 	b = A*m;
  42: 
  43: 	// and we obtain again the vector m in the matrix x,
  44: 	// thanks to regression.
  45: 	x = leastSquaresError_find(A,b);
  46: 	x.print("x");
  47: 
  48: 	// we print the result showing everyone the accuracy of the method.
  49: 	(x-m).print("x-m");
  50: 
  51: }
  52: 
  53: 
  54: