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">
4
<refname>levin</refname>
5
<refpurpose>Toeplitz system solver by Levinson algorithm
10
<title>Calling Sequence</title>
11
<synopsis>[la,sig]=levin(n,cov)</synopsis>
14
<title>Arguments</title>
19
<para>A scalar with integer value: the maximum order of the
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
39
<mml:mfenced mml:close="" mml:open="">
67
<mml:mo mml:stretchy="false">⋮</mml:mo>
74
<mml:mi mml:fontstyle="italic">nlags</mml:mi>
80
<mml:annotation mml:encoding="StarMath 5.0"> left ( matrix{R_0 ## R_1 ##
81
R_{2} ## dotsvert ## R_{nlags} } right )
94
<para>A list, the successively calculated Levinson polynomials
95
(degree 1 to <literal>n</literal>), with coefficients
103
<para>A list, the successive mean-square errors.</para>
109
<title>Description</title>
110
<para>function which solves recursively on n the following Toeplitz system
121
<mml:mfenced mml:close="" mml:open="">
129
<mml:mo mml:stretchy="false">−</mml:mo>
137
<mml:mo mml:stretchy="false">⋯</mml:mo>
141
<mml:mo mml:stretchy="false">−</mml:mo>
151
<mml:mo mml:stretchy="false">∗</mml:mo>
152
<mml:mfenced mml:close="" mml:open="">
168
<mml:mo mml:stretchy="false">⋯</mml:mo>
191
<mml:mo mml:stretchy="false">⋯</mml:mo>
198
<mml:mo mml:stretchy="false">−</mml:mo>
209
<mml:mo mml:stretchy="false">−</mml:mo>
221
<mml:mo mml:stretchy="false">⋯</mml:mo>
228
<mml:mo mml:stretchy="false">−</mml:mo>
236
<mml:mo mml:stretchy="false">⋮</mml:mo>
239
<mml:mo mml:stretchy="false">⋮</mml:mo>
242
<mml:mo mml:stretchy="false">⋯</mml:mo>
245
<mml:mo mml:stretchy="false">⋮</mml:mo>
254
<mml:mo mml:stretchy="false">−</mml:mo>
264
<mml:mo mml:stretchy="false">−</mml:mo>
270
<mml:mo mml:stretchy="false">⋯</mml:mo>
285
<mml:mo mml:stretchy="false">−</mml:mo>
295
<mml:mo mml:stretchy="false">−</mml:mo>
301
<mml:mo mml:stretchy="false">⋯</mml:mo>
313
<mml:mo mml:stretchy="false">=</mml:mo>
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}
330
where {<literal>Rk;k=1:nlag</literal>} is the sequence of
331
<literal>nlag</literal> empirical covariances
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)
344
//1) A one-dimensional process
345
// -------------------------
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).
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);
358
c1=c1';//c1 needs to be given columnwise (see the section PARAMETERS of this help)
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
367
[la1,sig1]=levin(n,c1);
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
377
for i=1:n, s1=roots(la1(i));s1=log(s1)/2/%pi/.1;
379
//now we get the estimated poles (sorted, positive ones only !)
381
s1=gsort(imag(s1));s1=s1(1:i/2);end;
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.
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
392
// |y_2| y_2=sin(2*Pi*3*t)+sin(2*Pi*4*t)+Gaussian noise
397
y2=[sin(t2)+sin(2*t2)+rand(t2);sin(3*t2)+sin(4*t2)+rand(t2)];
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
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
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 !
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.
420
<refsection role="see also">
421
<title>See Also</title>
422
<simplelist type="inline">
424
<link linkend="phc">phc</link>