~ubuntu-branches/ubuntu/raring/scilab/raring-proposed

« back to all changes in this revision

Viewing changes to modules/signal_processing/help/en_US/levin.xml

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2012-08-30 14:42:38 UTC
  • mfrom: (1.4.7)
  • Revision ID: package-import@ubuntu.com-20120830144238-c1y2og7dbm7m9nig
Tags: 5.4.0-beta-3-1~exp1
* New upstream release
* Update the scirenderer dep
* Get ride of libjhdf5-java dependency

Show diffs side-by-side

added added

removed removed

Lines of Context:
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:ns3="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="levin" xml:lang="en">
3
 
  <refnamediv>
4
 
    <refname>levin</refname>
5
 
    <refpurpose>Toeplitz system solver by Levinson algorithm
6
 
      (multidimensional)
7
 
    </refpurpose>
8
 
  </refnamediv>
9
 
  <refsynopsisdiv>
10
 
    <title>Calling Sequence</title>
11
 
    <synopsis>[la,sig]=levin(n,cov)</synopsis>
12
 
  </refsynopsisdiv>
13
 
  <refsection>
14
 
    <title>Arguments</title>
15
 
    <variablelist>
16
 
      <varlistentry>
17
 
        <term>n</term>
18
 
        <listitem>
19
 
          <para>A scalar with integer value: the maximum order of the
20
 
            filter
21
 
          </para>
22
 
        </listitem>
23
 
      </varlistentry>
24
 
      <varlistentry>
25
 
        <term>cov</term>
26
 
        <listitem>
27
 
          <para>
28
 
            A <literal>(nlag*d) x d</literal> matrix. It contains the
29
 
            <literal>Rk</literal> (<literal>d x d</literal> matrices for a
30
 
            <literal>d</literal>-dimensional process) stored in the following
31
 
            way :
32
 
          </para>
33
 
          <para>
34
 
            <inlinemediaobject>
35
 
              <imageobject>
36
 
                <imagedata>
37
 
                  <mml:math>
38
 
                    <mml:semantics>
39
 
                      <mml:mfenced mml:close="" mml:open="">
40
 
                        <mml:mtable>
41
 
                          <mml:mtr>
42
 
                            <mml:mtd>
43
 
                              <mml:msub>
44
 
                                <mml:mi>R</mml:mi>
45
 
                                <mml:mn>0</mml:mn>
46
 
                              </mml:msub>
47
 
                            </mml:mtd>
48
 
                          </mml:mtr>
49
 
                          <mml:mtr>
50
 
                            <mml:mtd>
51
 
                              <mml:msub>
52
 
                                <mml:mi>R</mml:mi>
53
 
                                <mml:mn>1</mml:mn>
54
 
                              </mml:msub>
55
 
                            </mml:mtd>
56
 
                          </mml:mtr>
57
 
                          <mml:mtr>
58
 
                            <mml:mtd>
59
 
                              <mml:msub>
60
 
                                <mml:mi>R</mml:mi>
61
 
                                <mml:mn>2</mml:mn>
62
 
                              </mml:msub>
63
 
                            </mml:mtd>
64
 
                          </mml:mtr>
65
 
                          <mml:mtr>
66
 
                            <mml:mtd>
67
 
                              <mml:mo mml:stretchy="false">⋮</mml:mo>
68
 
                            </mml:mtd>
69
 
                          </mml:mtr>
70
 
                          <mml:mtr>
71
 
                            <mml:mtd>
72
 
                              <mml:msub>
73
 
                                <mml:mi>R</mml:mi>
74
 
                                <mml:mi mml:fontstyle="italic">nlags</mml:mi>
75
 
                              </mml:msub>
76
 
                            </mml:mtd>
77
 
                          </mml:mtr>
78
 
                        </mml:mtable>
79
 
                      </mml:mfenced>
80
 
                      <mml:annotation mml:encoding="StarMath 5.0"> left ( matrix{R_0 ## R_1 ##
81
 
                        R_{2} ## dotsvert ## R_{nlags} } right )
82
 
                      </mml:annotation>
83
 
                    </mml:semantics>
84
 
                  </mml:math>
85
 
                </imagedata>
86
 
              </imageobject>
87
 
            </inlinemediaobject>
88
 
          </para>
89
 
        </listitem>
90
 
      </varlistentry>
91
 
      <varlistentry>
92
 
        <term>la</term>
93
 
        <listitem>
94
 
          <para>A list, the successively calculated Levinson polynomials
95
 
            (degree 1 to <literal>n</literal>), with coefficients
96
 
            <literal>Ak</literal>
97
 
          </para>
98
 
        </listitem>
99
 
      </varlistentry>
100
 
      <varlistentry>
101
 
        <term>sig</term>
102
 
        <listitem>
103
 
          <para>A list, the successive mean-square errors.</para>
104
 
        </listitem>
105
 
      </varlistentry>
106
 
    </variablelist>
107
 
  </refsection>
108
 
  <refsection>
109
 
    <title>Description</title>
110
 
    <para>function which solves recursively on n the following Toeplitz system
111
 
      (normal equations)
112
 
    </para>
113
 
    <para>
114
 
      <inlinemediaobject>
115
 
        <imageobject>
116
 
          <imagedata>
117
 
            <mml:math>
118
 
              <mml:semantics>
119
 
                <mml:mrow>
120
 
                  <mml:mrow>
121
 
                    <mml:mfenced mml:close="" mml:open="">
122
 
                      <mml:mtable>
123
 
                        <mml:mtr>
124
 
                          <mml:mtd>
125
 
                            <mml:mi>I</mml:mi>
126
 
                          </mml:mtd>
127
 
                          <mml:mtd>
128
 
                            <mml:mrow>
129
 
                              <mml:mo mml:stretchy="false">−</mml:mo>
130
 
                              <mml:msub>
131
 
                                <mml:mi>A</mml:mi>
132
 
                                <mml:mn>1</mml:mn>
133
 
                              </mml:msub>
134
 
                            </mml:mrow>
135
 
                          </mml:mtd>
136
 
                          <mml:mtd>
137
 
                            <mml:mo mml:stretchy="false">⋯</mml:mo>
138
 
                          </mml:mtd>
139
 
                          <mml:mtd>
140
 
                            <mml:mrow>
141
 
                              <mml:mo mml:stretchy="false">−</mml:mo>
142
 
                              <mml:msub>
143
 
                                <mml:mi>A</mml:mi>
144
 
                                <mml:mi>n</mml:mi>
145
 
                              </mml:msub>
146
 
                            </mml:mrow>
147
 
                          </mml:mtd>
148
 
                        </mml:mtr>
149
 
                      </mml:mtable>
150
 
                    </mml:mfenced>
151
 
                    <mml:mo mml:stretchy="false">∗</mml:mo>
152
 
                    <mml:mfenced mml:close="" mml:open="">
153
 
                      <mml:mtable>
154
 
                        <mml:mtr>
155
 
                          <mml:mtd>
156
 
                            <mml:msub>
157
 
                              <mml:mi>R</mml:mi>
158
 
                              <mml:mn>1</mml:mn>
159
 
                            </mml:msub>
160
 
                          </mml:mtd>
161
 
                          <mml:mtd>
162
 
                            <mml:msub>
163
 
                              <mml:mi>R</mml:mi>
164
 
                              <mml:mn>2</mml:mn>
165
 
                            </mml:msub>
166
 
                          </mml:mtd>
167
 
                          <mml:mtd>
168
 
                            <mml:mo mml:stretchy="false">⋯</mml:mo>
169
 
                          </mml:mtd>
170
 
                          <mml:mtd>
171
 
                            <mml:msub>
172
 
                              <mml:mi>R</mml:mi>
173
 
                              <mml:mi>n</mml:mi>
174
 
                            </mml:msub>
175
 
                          </mml:mtd>
176
 
                        </mml:mtr>
177
 
                        <mml:mtr>
178
 
                          <mml:mtd>
179
 
                            <mml:msub>
180
 
                              <mml:mi>R</mml:mi>
181
 
                              <mml:mn>0</mml:mn>
182
 
                            </mml:msub>
183
 
                          </mml:mtd>
184
 
                          <mml:mtd>
185
 
                            <mml:msub>
186
 
                              <mml:mi>R</mml:mi>
187
 
                              <mml:mn>1</mml:mn>
188
 
                            </mml:msub>
189
 
                          </mml:mtd>
190
 
                          <mml:mtd>
191
 
                            <mml:mo mml:stretchy="false">⋯</mml:mo>
192
 
                          </mml:mtd>
193
 
                          <mml:mtd>
194
 
                            <mml:msub>
195
 
                              <mml:mi>R</mml:mi>
196
 
                              <mml:mrow>
197
 
                                <mml:mi>n</mml:mi>
198
 
                                <mml:mo mml:stretchy="false">−</mml:mo>
199
 
                                <mml:mn>1</mml:mn>
200
 
                              </mml:mrow>
201
 
                            </mml:msub>
202
 
                          </mml:mtd>
203
 
                        </mml:mtr>
204
 
                        <mml:mtr>
205
 
                          <mml:mtd>
206
 
                            <mml:msub>
207
 
                              <mml:mi>R</mml:mi>
208
 
                              <mml:mrow>
209
 
                                <mml:mo mml:stretchy="false">−</mml:mo>
210
 
                                <mml:mn>1</mml:mn>
211
 
                              </mml:mrow>
212
 
                            </mml:msub>
213
 
                          </mml:mtd>
214
 
                          <mml:mtd>
215
 
                            <mml:msub>
216
 
                              <mml:mi>R</mml:mi>
217
 
                              <mml:mn>0</mml:mn>
218
 
                            </mml:msub>
219
 
                          </mml:mtd>
220
 
                          <mml:mtd>
221
 
                            <mml:mo mml:stretchy="false">⋯</mml:mo>
222
 
                          </mml:mtd>
223
 
                          <mml:mtd>
224
 
                            <mml:msub>
225
 
                              <mml:mi>R</mml:mi>
226
 
                              <mml:mrow>
227
 
                                <mml:mi>n</mml:mi>
228
 
                                <mml:mo mml:stretchy="false">−</mml:mo>
229
 
                                <mml:mn>2</mml:mn>
230
 
                              </mml:mrow>
231
 
                            </mml:msub>
232
 
                          </mml:mtd>
233
 
                        </mml:mtr>
234
 
                        <mml:mtr>
235
 
                          <mml:mtd>
236
 
                            <mml:mo mml:stretchy="false">⋮</mml:mo>
237
 
                          </mml:mtd>
238
 
                          <mml:mtd>
239
 
                            <mml:mo mml:stretchy="false">⋮</mml:mo>
240
 
                          </mml:mtd>
241
 
                          <mml:mtd>
242
 
                            <mml:mo mml:stretchy="false">⋯</mml:mo>
243
 
                          </mml:mtd>
244
 
                          <mml:mtd>
245
 
                            <mml:mo mml:stretchy="false">⋮</mml:mo>
246
 
                          </mml:mtd>
247
 
                        </mml:mtr>
248
 
                        <mml:mtr>
249
 
                          <mml:mtd>
250
 
                            <mml:msub>
251
 
                              <mml:mi>R</mml:mi>
252
 
                              <mml:mrow>
253
 
                                <mml:mn>2</mml:mn>
254
 
                                <mml:mo mml:stretchy="false">−</mml:mo>
255
 
                                <mml:mi>n</mml:mi>
256
 
                              </mml:mrow>
257
 
                            </mml:msub>
258
 
                          </mml:mtd>
259
 
                          <mml:mtd>
260
 
                            <mml:msub>
261
 
                              <mml:mi>R</mml:mi>
262
 
                              <mml:mrow>
263
 
                                <mml:mn>3</mml:mn>
264
 
                                <mml:mo mml:stretchy="false">−</mml:mo>
265
 
                                <mml:mi>n</mml:mi>
266
 
                              </mml:mrow>
267
 
                            </mml:msub>
268
 
                          </mml:mtd>
269
 
                          <mml:mtd>
270
 
                            <mml:mo mml:stretchy="false">⋯</mml:mo>
271
 
                          </mml:mtd>
272
 
                          <mml:mtd>
273
 
                            <mml:msub>
274
 
                              <mml:mi>R</mml:mi>
275
 
                              <mml:mn>1</mml:mn>
276
 
                            </mml:msub>
277
 
                          </mml:mtd>
278
 
                        </mml:mtr>
279
 
                        <mml:mtr>
280
 
                          <mml:mtd>
281
 
                            <mml:msub>
282
 
                              <mml:mi>R</mml:mi>
283
 
                              <mml:mrow>
284
 
                                <mml:mn>1</mml:mn>
285
 
                                <mml:mo mml:stretchy="false">−</mml:mo>
286
 
                                <mml:mi>n</mml:mi>
287
 
                              </mml:mrow>
288
 
                            </mml:msub>
289
 
                          </mml:mtd>
290
 
                          <mml:mtd>
291
 
                            <mml:msub>
292
 
                              <mml:mi>R</mml:mi>
293
 
                              <mml:mrow>
294
 
                                <mml:mn>2</mml:mn>
295
 
                                <mml:mo mml:stretchy="false">−</mml:mo>
296
 
                                <mml:mi>n</mml:mi>
297
 
                              </mml:mrow>
298
 
                            </mml:msub>
299
 
                          </mml:mtd>
300
 
                          <mml:mtd>
301
 
                            <mml:mo mml:stretchy="false">⋯</mml:mo>
302
 
                          </mml:mtd>
303
 
                          <mml:mtd>
304
 
                            <mml:msub>
305
 
                              <mml:mi>R</mml:mi>
306
 
                              <mml:mn>0</mml:mn>
307
 
                            </mml:msub>
308
 
                          </mml:mtd>
309
 
                        </mml:mtr>
310
 
                      </mml:mtable>
311
 
                    </mml:mfenced>
312
 
                  </mml:mrow>
313
 
                  <mml:mo mml:stretchy="false">=</mml:mo>
314
 
                  <mml:mn>0</mml:mn>
315
 
                </mml:mrow>
316
 
                <mml:annotation mml:encoding="StarMath 5.0">left ( matrix{I # -A_1
317
 
                  # dotsaxis #-A_n} right )* left ( matrix{R_1 # R_2 # dotsaxis #R_n
318
 
                  ## R_0 # R_1 # dotsaxis #R_{n-1}## R_{-1} # R_0 # dotsaxis
319
 
                  #R_{n-2}## dotsvert # dotsvert# dotsaxis # dotsvert## R_{2-n} #
320
 
                  R_{3-n} # dotsaxis #R_{1}## R_{1-n} # R_{2-n} # dotsaxis #R_{0}
321
 
                  }right ) = 0
322
 
                </mml:annotation>
323
 
              </mml:semantics>
324
 
            </mml:math>
325
 
          </imagedata>
326
 
        </imageobject>
327
 
      </inlinemediaobject>
328
 
    </para>
329
 
    <para>
330
 
      where {<literal>Rk;k=1:nlag</literal>} is the sequence of
331
 
      <literal>nlag</literal> empirical covariances
332
 
    </para>
333
 
  </refsection>
334
 
  <refsection>
335
 
    <title>Examples</title>
336
 
    <programlisting role="example"><![CDATA[ 
337
 
//We use the 'levin' macro for solving the normal equations 
338
 
//on two examples: a one-dimensional and a two-dimensional process.
339
 
//We need the covariance sequence of the stochastic process.
340
 
//This example may usefully be compared with the results from 
341
 
//the 'phc' macro (see the corresponding help and example in it)
342
 
//
343
 
//
344
 
//1) A one-dimensional process
345
 
//   -------------------------
346
 
//
347
 
//We generate the process defined by two sinusoids (1Hz and 2 Hz) 
348
 
//in additive Gaussian noise (this is the observed process); 
349
 
//the simulated process is sampled at 10 Hz (step 0.1 in t, underafter).
350
 
 
351
 
t1=0:.1:100;rand('normal');
352
 
y1=sin(2*%pi*t1)+sin(2*%pi*2*t1);y1=y1+rand(y1);plot(t1,y1);
353
 
 
354
 
//covariance of y1
355
 
 
356
 
nlag=128;
357
 
c1=corr(y1,nlag);
358
 
c1=c1';//c1 needs to be given columnwise (see the section PARAMETERS of this help)
359
 
 
360
 
//compute the filter for a maximum order of n=10
361
 
//la is a list-type variable each element of which 
362
 
//containing the filters of order ranging from 1 to n; (try varying n)
363
 
//in the d-dimensional case this is a matrix polynomial (square, d X d)
364
 
//sig gives, the same way, the mean-square error
365
 
 
366
 
n=15;
367
 
[la1,sig1]=levin(n,c1);
368
 
 
369
 
//verify that the roots of 'la' contain the 
370
 
//frequency spectrum of the observed process y
371
 
//(remember that y is sampled -in our example 
372
 
//at 10Hz (T=0.1s) so that we need to retrieve 
373
 
//the original frequencies (1Hz and 2 Hz) through 
374
 
//the log and correct scaling by the frequency sampling)
375
 
//we verify this for each filter order
376
 
 
377
 
for i=1:n, s1=roots(la1(i));s1=log(s1)/2/%pi/.1;
378
 
 
379
 
//now we get the estimated poles (sorted, positive ones only !)
380
 
 
381
 
s1=gsort(imag(s1));s1=s1(1:i/2);end;
382
 
 
383
 
//the last two frequencies are the ones really present in the observed 
384
 
//process ---> the others are "artifacts" coming from the used model size.
385
 
//This is related to the rather difficult problem of order estimation.
386
 
//
387
 
//2) A 2-dimensional process 
388
 
//   -----------------------
389
 
//(4 frequencies 1, 2, 3, and 4 Hz, sampled at 0.1 Hz :
390
 
//   |y_1|        y_1=sin(2*Pi*t)+sin(2*Pi*2*t)+Gaussian noise
391
 
// y=|   | with : 
392
 
//   |y_2|        y_2=sin(2*Pi*3*t)+sin(2*Pi*4*t)+Gaussian noise
393
 
 
394
 
d=2;dt=0.1;
395
 
nlag=64;
396
 
t2=0:2*%pi*dt:100;
397
 
y2=[sin(t2)+sin(2*t2)+rand(t2);sin(3*t2)+sin(4*t2)+rand(t2)];
398
 
c2=[];
399
 
for j=1:2, for k=1:2, c2=[c2;corr(y2(k,:),y2(j,:),nlag)];end;end;
400
 
c2=matrix(c2,2,128);cov=[];
401
 
for j=1:64,cov=[cov;c2(:,(j-1)*d+1:j*d)];end;//covar. columnwise
402
 
c2=cov;
403
 
 
404
 
//in the multidimensional case, we have to compute the 
405
 
//roots of the determinant of the matrix polynomial 
406
 
//(easy in the 2-dimensional case but tricky if d>=3 !). 
407
 
//We just do that here for the maximum desired 
408
 
//filter order (n); mp is the matrix polynomial of degree n
409
 
 
410
 
[la2,sig2]=levin(n,c2);
411
 
mp=la2(n);determinant=mp(1,1)*mp(2,2)-mp(1,2)*mp(2,1);
412
 
s2=roots(determinant);s2=log(s2)/2/%pi/0.1;//same trick as above for 1D process
413
 
s2=gsort(imag(s2));s2=s2(1:d*n/2);//just the positive ones !
414
 
 
415
 
//There the order estimation problem is seen to be much more difficult !
416
 
//many artifacts ! The 4 frequencies are in the estimated spectrum 
417
 
//but beneath many non relevant others.
418
 
 ]]></programlisting>
419
 
  </refsection>
420
 
  <refsection role="see also">
421
 
    <title>See Also</title>
422
 
    <simplelist type="inline">
423
 
      <member>
424
 
        <link linkend="phc">phc</link>
425
 
      </member>
426
 
    </simplelist>
427
 
  </refsection>
428
 
</refentry>