1
<?xml version="1.0" encoding="UTF-8"?>
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:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" version="5.0-subset Scilab" xml:lang="en" xml:id="wiener">
4
<refname>wiener</refname>
5
<refpurpose> Wiener estimate</refpurpose>
8
<title>Calling Sequence</title>
9
<synopsis>[xs,ps,xf,pf]=wiener(y,x0,p0,f,g,h,q,r)</synopsis>
12
<title>Arguments</title>
18
system matrices in the interval <literal>[t0,tf]</literal>
25
=<literal>[f0,f1,...,ff]</literal>, and <literal>fk</literal> is a nxn matrix
33
=<literal>[g0,g1,...,gf]</literal>, and <literal>gk</literal> is a nxn matrix
41
=<literal>[h0,h1,...,hf]</literal>, and <literal>hk</literal> is a mxn matrix
51
<para>covariance matrices of dynamics and observation noise</para>
57
=<literal>[q0,q1,...,qf]</literal>, and <literal>qk</literal> is a nxn matrix
65
=<literal>[r0,r1,...,rf]</literal>, and <literal>gk</literal> is a mxm matrix
75
<para>initial state estimate and error variance</para>
82
observations in the interval <literal>[t0,tf]</literal>. <literal>y=[y0,y1,...,yf]</literal>, and <literal>yk</literal> is a column m-vector
90
Smoothed state estimate <literal>xs= [xs0,xs1,...,xsf]</literal>, and <literal>xsk</literal> is a column n-vector
98
Error covariance of smoothed estimate <literal>ps=[p0,p1,...,pf]</literal>, and <literal>pk</literal> is a nxn matrix
106
Filtered state estimate <literal>xf= [xf0,xf1,...,xff]</literal>, and <literal>xfk</literal> is a column n-vector
114
Error covariance of filtered estimate <literal>pf=[p0,p1,...,pf]</literal>, and <literal>pk</literal> is a nxn matrix
121
<title>Description</title>
123
function which gives the Wiener estimate using
124
the forward-backward Kalman filter formulation
128
<title>Sample</title>
141
x0=m0+p0c'*rand(ones(m0));
142
y=h*x0+chol(r)'*rand(ones(1:hi))';
152
[x1,y]=system(x0,f2,g,h,q,r);
162
[xs,ps,xf,pf]=wiener(yt,m0,p0,ft,gt,ht,qt,rt);
163
a=min([x(1,:)-2*sqrt(ps(1,1:2:2*(n+1))),xf(1,:),xs(1,:)]);
164
b=max([x(1,:)+2*sqrt(ps(1,1:2:2*(n+1))),xf(1,:),xs(1,:)]);
165
c=min([x(2,:)-2*sqrt(ps(2,2:2:2*(n+1))),xf(2,:),xs(2,:)]);
166
d=max([x(2,:)+2*sqrt(ps(2,2:2:2*(n+1))),xf(2,:),xs(2,:)]);
167
xmargin=max([abs(a),abs(b)]);
168
ymargin=max([abs(c),abs(d)]);
174
plot([a a b],[d c c]);
175
plot2d(x(1,:)',x(2,:)',[2],"000")
176
plot2d(xf(1,:)',xf(2,:)',[2],"000")
177
plot2d(xs(1,:)',xs(2,:)',[2],"000")
178
plot2d(xs(1,:)',xs(2,:)',[-2],"000")
179
plot2d(xf(1,:)',xf(2,:)',[-3],"000")
180
plot2d(x(1,:)',x(2,:)',[-4],"000")
184
<title>Examples</title>
185
<programlisting role="example"><![CDATA[
186
// initialize state statistics (mean and er. variance)
197
// initialize system process
201
x0=m0+p0c'*rand(ones(m0));
202
y=h*x0+chol(r)'*rand(ones(1:hi))';
204
// initialize plotted variables
214
// generate the state and observation
215
// at time k (i.e. xk and yk)
216
[x1,y]=system(x0,f2,g,h,q,r);
226
// get the wiener filter estimate
227
[xs,ps,xf,pf]=wiener(yt,m0,p0,ft,gt,ht,qt,rt);
229
a=min([x(1,:)-2*sqrt(ps(1,1:2:2*(n+1))),xf(1,:),xs(1,:)]);
230
b=max([x(1,:)+2*sqrt(ps(1,1:2:2*(n+1))),xf(1,:),xs(1,:)]);
231
c=min([x(2,:)-2*sqrt(ps(2,2:2:2*(n+1))),xf(2,:),xs(2,:)]);
232
d=max([x(2,:)+2*sqrt(ps(2,2:2:2*(n+1))),xf(2,:),xs(2,:)]);
233
xmargin=max([abs(a),abs(b)]);
234
ymargin=max([abs(c),abs(d)]);
239
// plot frame, real state (x), and estimates (xf, and xs)
241
plot([a a b],[d c c]);
242
plot2d(x(1,:)',x(2,:)',[2],"000")
243
plot2d(xf(1,:)',xf(2,:)',[2],"000")
244
plot2d(xs(1,:)',xs(2,:)',[2],"000")
245
// mark data points (* for real data, o for estimates)
246
plot2d(xs(1,:)',xs(2,:)',[-2],"000")
247
plot2d(xf(1,:)',xf(2,:)',[-3],"000")
248
plot2d(x(1,:)',x(2,:)',[-4],"000")