comparison main/optim/inst/LinearRegression.m @ 9930:d30cfca46e8a octave-forge

optim: upgrade license to GPLv3+ and mention on DESCRIPTION the other package licenses
author carandraug
date Fri, 30 Mar 2012 15:14:48 +0000
parents b11b5363d680
children 409a264a03b6
comparison
equal deleted inserted replaced
9929:df50d0ae107f 9930:d30cfca46e8a
1 ## Copyright (C) 2007 Andreas Stahel <Andreas.Stahel@bfh.ch>
2 ##
3 ## This program is free software; you can redistribute it and/or modify it under
4 ## the terms of the GNU General Public License as published by the Free Software
5 ## Foundation; either version 3 of the License, or (at your option) any later
6 ## version.
7 ##
8 ## This program is distributed in the hope that it will be useful, but WITHOUT
9 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
11 ## details.
12 ##
13 ## You should have received a copy of the GNU General Public License along with
14 ## this program; if not, see <http://www.gnu.org/licenses/>.
15
16 ## general linear regression
17 ##
18 ## [p,y_var,r,p_var]=LinearRegression(F,y)
19 ## [p,y_var,r,p_var]=LinearRegression(F,y,weight)
20 ##
21 ## determine the parameters p_j (j=1,2,...,m) such that the function
22 ## f(x) = sum_(i=1,...,m) p_j*f_j(x) fits as good as possible to the
23 ## given values y_i = f(x_i)
24 ##
25 ## parameters
26 ## F n*m matrix with the values of the basis functions at the support points
27 ## in column j give the values of f_j at the points x_i (i=1,2,...,n)
28 ## y n column vector of given values
29 ## weight n column vector of given weights
30 ##
31 ## return values
32 ## p m vector with the estimated values of the parameters
33 ## y_var estimated variance of the error
34 ## r weighted norm of residual
35 ## p_var estimated variance of the parameters p_j
36
1 function [p,y_var,r,p_var]=LinearRegression(F,y,weight) 37 function [p,y_var,r,p_var]=LinearRegression(F,y,weight)
2
3 % general linear regression
4 %
5 % [p,y_var,r,p_var]=LinearRegression(F,y)
6 % [p,y_var,r,p_var]=LinearRegression(F,y,weight)
7 %
8 % determine the parameters p_j (j=1,2,...,m) such that the function
9 % f(x) = sum_(i=1,...,m) p_j*f_j(x) fits as good as possible to the
10 % given values y_i = f(x_i)
11 %
12 % parameters
13 % F n*m matrix with the values of the basis functions at the support points
14 % in column j give the values of f_j at the points x_i (i=1,2,...,n)
15 % y n column vector of given values
16 % weight n column vector of given weights
17 %
18 % return values
19 % p m vector with the estimated values of the parameters
20 % y_var estimated variance of the error
21 % r weighted norm of residual
22 % p_var estimated variance of the parameters p_j
23
24
25 ## Copyright (C) 2007 Andreas Stahel <Andreas.Stahel@bfh.ch>
26 ##
27 ## This program is free software; you can redistribute it and/or modify
28 ## it under the terms of the GNU General Public License as published by
29 ## the Free Software Foundation; either version 2 of the License, or
30 ## (at your option) any later version.
31 ##
32 ## This program is distributed in the hope that it will be useful,
33 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
34 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
35 ## GNU General Public License for more details.
36 ##
37 ## You should have received a copy of the GNU General Public License
38 ## along with this program; If not, see <http://www.gnu.org/licenses/>.
39 38
40 if (nargin < 2 || nargin >= 4) 39 if (nargin < 2 || nargin >= 4)
41 usage('wrong number of arguments in [p,y_var,r,p_var]=LinearRegression(F,y)'); 40 usage('wrong number of arguments in [p,y_var,r,p_var]=LinearRegression(F,y)');
42 end 41 end
43 42