cb1777ef89d8bb1db9c99a2b3da6c516e8e806c6
[scilab.git] / scilab / modules / cacsd / help / en_US / reglin.xml
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!--
3  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
4  * Copyright (C) INRIA - 
5  * 
6  * This file must be used under the terms of the CeCILL.
7  * This source file is licensed as described in the file COPYING, which
8  * you should have received as part of this distribution.  The terms
9  * are also available at    
10  * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
11  *
12  -->
13 <refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:lang="en" xml:id="reglin">
14     <refnamediv>
15         <refname>reglin</refname>
16         <refpurpose>Linear regression</refpurpose>
17     </refnamediv>
18     <refsynopsisdiv>
19         <title>Calling Sequence</title>
20         <synopsis>[a,b,sig]=reglin(x,y)</synopsis>
21     </refsynopsisdiv>
22     <refsection>
23         <title>Description</title>
24         <para>
25             solve the regression problem y=a*x+ b in the least square sense. 
26             <literal>sig</literal> is the standard deviation of the residual. <literal>x</literal> and <literal>y</literal>
27             are two matrices of size <literal>x(p,n)</literal> and <literal>y(q,n)</literal>, where  <literal>n</literal>
28             is the number of samples.
29         </para>
30         <para>
31             The estimator <literal>a</literal> is a matrix of size <literal>(q,p)</literal> and <literal>b</literal> is a
32             vector of size <literal>(q,1)</literal>
33         </para>
34         <programlisting role=""><![CDATA[ 
35 // simulation of data for a(3,5) and b(3,1)
36 x=rand(5,100);
37 aa=testmatrix('magi',5);aa=aa(1:3,:);
38 bb=[9;10;11]
39 y=aa*x +bb*ones(1,100)+ 0.1*rand(3,100);
40 // identification 
41 [a,b,sig]=reglin(x,y);
42 max(abs(aa-a))
43 max(abs(bb-b))
44 // an other example : fitting a polynomial
45 f=1:100; x=[f.*f; f];
46 y= [ 2,3]*x+ 10*ones(f) + 0.1*rand(f);
47 [a,b]=reglin(x,y)
48  ]]></programlisting>
49     </refsection>
50     <refsection role="see also">
51         <title>See Also</title>
52         <simplelist type="inline">
53             <member>
54                 <link linkend="pinv">pinv</link>
55             </member>
56             <member>
57                 <link linkend="leastsq">leastsq</link>
58             </member>
59             <member>
60                 <link linkend="qr">qr</link>
61             </member>
62         </simplelist>
63     </refsection>
64 </refentry>