1 function [a,VAR,S,a_aux,b_aux,e_aux,MLE,pos] = rmle(arg1,arg2);
2 % RMLE estimates AR Parameters using the Recursive Maximum Likelihood
3 % Estimator according to [1]
5 % Use: [a,VAR]=rmle(x,p)
7 % x is a column vector of data
10 % a is a vector with the AR parameters of the recursive MLE
11 % VAR is the excitation white noise variance estimate
14 % [1] Kay S.M., Modern Spectral Analysis - Theory and Applications.
15 % Prentice Hall, p. 232-233, 1988.
18 % $Id: rmle.m 9609 2012-02-10 10:18:00Z schloegl $
19 % Copyright (C) 2004 by Jose Luis Gutierrez <jlg@gmx.at>
20 % Grupo GENESIS - UTN - Argentina
22 % This program is free software: you can redistribute it and/or modify
23 % it under the terms of the GNU General Public License as published by
24 % the Free Software Foundation, either version 3 of the License, or
25 % (at your option) any later version.
27 % This program is distributed in the hope that it will be useful,
28 % but WITHOUT ANY WARRANTY; without even the implied warranty of
29 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 % GNU General Public License for more details.
32 % You should have received a copy of the GNU General Public License
33 % along with this program. If not, see <http://www.gnu.org/licenses/>.
41 a_aux=zeros(p+1,p);, a_aux(1,:)=1;
43 e_aux=zeros(p,1);, p_aux=zeros(p,1);
50 S(i+1,j+1)=S(i+1,j+1)+x(n+1+i)*x(n+1+j);
59 coef2=((N-2)*c1)/((N-1)*d1);
60 coef1=-(e0+N*d1)/((N-1)*d1);
61 ti=-(N*c1)/((N-1)*d1);
62 raices=roots([coef3 coef2 coef1 ti]);
64 if raices(o)>-1 && raices(o)<1
66 b_aux(p+1,1)=raices(o);
69 e_aux(1,1)=S(1,1)+2*a_aux(2,1)*S(1,2)+(a_aux(2,1)^2)*S(2,2);
70 p_aux(1,1)=e_aux(1,1)/N;
75 ck=a_aux(1:k,k-1)'*Ck*b_aux(p+1:-1:p+2-k,k-1);
76 dk=b_aux(p+1:-1:p+2-k,k-1)'*Dk*b_aux(p+1:-1:p+2-k,k-1);
78 coef2re=((N-2*k)*ck)/((N-k)*dk);
79 coef1re=-(k*e_aux(k-1,1)+N*dk)/((N-k)*dk);
80 tire=-(N*ck)/((N-k)*dk);
81 raices=roots([coef3re coef2re coef1re tire]);
83 if raices(o,1)>-1 && raices(o,1)<1
84 MLE(o,1)=((1-raices(o)^2)^(k/2))/(((e_aux(k-1)+2*ck*raices(o)+dk*(raices(o)^2))/N)^(N/2));
90 a_aux(i+1,k)=a_aux(i+1,k-1)+k_max*a_aux(k-i+1,k-1);
93 b_aux(p+1-k:p+1,k)=a_aux(1:k+1,k);
94 e_aux(k,1)=e_aux(k-1,1)+2*ck*k_max+dk*k_max^2;
95 p_aux(k,1)=e_aux(k,1)/N;