1
1
<?xml version="1.0" encoding="UTF-8"?>
2
2
<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns5="http://www.w3.org/1999/xhtml" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" version="5.0-subset Scilab" xml:id="lsq_splin" xml:lang="en">
4
<refname>lsq_splin</refname>
5
<refpurpose>weighted least squares cubic spline fitting</refpurpose>
8
<title>Calling Sequence</title>
9
<synopsis>[y, d] = lsq_splin(xd, yd [, wd], x)</synopsis>
12
<title>Arguments</title>
17
<para>vectors of the same size, data to be fitted by a cubic
26
(optional) a vector of same format than <literal>xd</literal>
27
and <literal>yd</literal>, weights of the least square fit.
34
<para>a strictly increasing (row or column) vector, breakpoints of
43
vectors of same format than <literal>x</literal>, the triplet
44
(x,y,d) defines the approximated cubic spline.
51
<title>Description</title>
52
<para>This function computes an approximated cubic spline
53
<emphasis>s</emphasis> for the data <literal>xd, yd, wd</literal> (in the
54
following <emphasis>m</emphasis> is supposed to be the length of these
55
vectors) and from a choice of the spline breakpoints <literal>x</literal>
56
(for instance if you want n breakpoints uniformly chosen you may use
57
<literal>x=linspace(min(xd),max(xd),n))</literal>). If
58
<emphasis>S</emphasis> is the space of all cubic splines functions with
59
breakpoints <emphasis>x1 < x2 < ... < xn</emphasis> then the
60
resulting spline <emphasis>s</emphasis> is such that:
65
<imagedata align="center" fileref="../mml/lsq_splin_equation1.mml"/>
70
for all <emphasis>fin S</emphasis>, i.e. realizes the minimum of
71
the sum of the squared errors over all functions of
72
<emphasis>S</emphasis>.
75
The spline <emphasis>s</emphasis> is completely defined by the
76
triplet <literal>(x,y,d)</literal> (<literal>y</literal> and
77
<literal>d</literal> are the vectors of the spline ordinates and first
78
derivatives at the xi 's : <emphasis>yi=s(xi)</emphasis> and
79
<emphasis>di=s'(xi)</emphasis>) and its evaluation at some points must be
80
done by the <link linkend="interp">interp</link> function.
84
<title>Remarks</title>
86
When <literal>wd</literal> is not given, all the points have the
90
A point <emphasis>(xd(k),yd(k))</emphasis> is considered in the fit
91
if <emphasis>xd(k) in [x1,xn] and wd(k) > 0</emphasis>. In particular
92
you can put a null (or even negative) weight to all data points you want
93
to ignore in the fitting. When the total number of points taken into
94
account in the fit procedure is (strictly) less than 4 an error is
98
The vector <literal>xd</literal> do not need to be in increasing
101
<para>Depending on the number and on the positions of the
102
<emphasis>xd(k)</emphasis> 's and on the choice of the
103
<emphasis>x(i)</emphasis> 's there may be several solutions but only one
104
is selected. When this occurs a warning message is displayed in the Scilab
105
command window. This function is intended to be used when
106
<emphasis>m</emphasis> is much larger than <emphasis>n</emphasis> and in
107
this case no such problem may occurred.
111
<title>Examples</title>
112
<programlisting role="example"><![CDATA[
4
<refname>lsq_splin</refname>
5
<refpurpose>weighted least squares cubic spline fitting</refpurpose>
8
<title>Calling Sequence</title>
9
<synopsis>[y, d] = lsq_splin(xd, yd [, wd], x)</synopsis>
12
<title>Arguments</title>
17
<para>vectors of the same size, data to be fitted by a cubic
26
(optional) a vector of same format than <literal>xd</literal>
27
and <literal>yd</literal>, weights of the least square fit.
34
<para>a strictly increasing (row or column) vector, breakpoints of
43
vectors of same format than <literal>x</literal>, the triplet
44
(x,y,d) defines the approximated cubic spline.
51
<title>Description</title>
52
<para>This function computes an approximated cubic spline
53
<emphasis>s</emphasis> for the data <literal>xd, yd, wd</literal> (in the
54
following <emphasis>m</emphasis> is supposed to be the length of these
55
vectors) and from a choice of the spline breakpoints <literal>x</literal>
56
(for instance if you want n breakpoints uniformly chosen you may use
57
<literal>x=linspace(min(xd),max(xd),n))</literal>). If
58
<emphasis>S</emphasis> is the space of all cubic splines functions with
59
breakpoints <emphasis>x1 < x2 < ... < xn</emphasis> then the
60
resulting spline <emphasis>s</emphasis> is such that:
65
<imagedata align="center" fileref="../mml/lsq_splin_equation1.mml"/>
70
for all <emphasis>fin S</emphasis>, i.e. realizes the minimum of
71
the sum of the squared errors over all functions of
72
<emphasis>S</emphasis>.
75
The spline <emphasis>s</emphasis> is completely defined by the
76
triplet <literal>(x,y,d)</literal> (<literal>y</literal> and
77
<literal>d</literal> are the vectors of the spline ordinates and first
78
derivatives at the xi 's : <emphasis>yi=s(xi)</emphasis> and
79
<emphasis>di=s'(xi)</emphasis>) and its evaluation at some points must be
80
done by the <link linkend="interp">interp</link> function.
84
<title>Remarks</title>
86
When <literal>wd</literal> is not given, all the points have the
90
A point <emphasis>(xd(k),yd(k))</emphasis> is considered in the fit
91
if <emphasis>xd(k) in [x1,xn] and wd(k) > 0</emphasis>. In particular
92
you can put a null (or even negative) weight to all data points you want
93
to ignore in the fitting. When the total number of points taken into
94
account in the fit procedure is (strictly) less than 4 an error is
98
The vector <literal>xd</literal> do not need to be in increasing
101
<para>Depending on the number and on the positions of the
102
<emphasis>xd(k)</emphasis> 's and on the choice of the
103
<emphasis>x(i)</emphasis> 's there may be several solutions but only one
104
is selected. When this occurs a warning message is displayed in the Scilab
105
command window. This function is intended to be used when
106
<emphasis>m</emphasis> is much larger than <emphasis>n</emphasis> and in
107
this case no such problem may occurred.
111
<title>Examples</title>
112
<programlisting role="example"><![CDATA[
113
113
// this is an artificial example where the data xd and yd
114
114
// are build from a perturbed sin function
115
115
a = 0; b = 2*%pi;