1 function [MX,res,arg3] = ar2rc(ar);
2 % converts autoregressive parameters into reflection coefficients
3 % with the Durbin-Levinson recursion for multiple channels
4 % function [AR,RC,PE] = ar2rc(AR);
5 % function [MX,PE] = ar2rc(AR);
8 % AR autoregressive model parameter
11 % AR autoregressive model parameter
12 % RC reflection coefficients (= -PARCOR coefficients)
13 % PE remaining error variance (relative to PE(1)=1)
14 % MX transformation matrix between ARP and RC (Attention: needs O(p^2) memory)
15 % AR = MX(:,K*(K-1)/2+(1:K));
16 % RC = MX(:,(1:K).*(2:K+1)/2);
18 % All input and output parameters are organized in rows, one row
19 % corresponds to the parameters of one channel
21 % see also ACOVF ACORF DURLEV RC2AR
24 % P.J. Brockwell and R. A. Davis "Time Series: Theory and Methods", 2nd ed. Springer, 1991.
25 % S. Haykin "Adaptive Filter Theory" 3rd ed. Prentice Hall, 1996.
26 % M.B. Priestley "Spectral Analysis and Time Series" Academic Press, 1981.
27 % W.S. Wei "Time Series Analysis" Addison Wesley, 1990.
29 % $Id: ar2rc.m 5090 2008-06-05 08:12:04Z schloegl $
30 % Copyright (C) 1998-2002,2008 by Alois Schloegl <a.schloegl@ieee.org>
32 % This program is free software: you can redistribute it and/or modify
33 % it under the terms of the GNU General Public License as published by
34 % the Free Software Foundation, either version 3 of the License, or
35 % (at your option) any later version.
37 % This program is distributed in the hope that it will be useful,
38 % but WITHOUT ANY WARRANTY; without even the implied warranty of
39 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
40 % GNU General Public License for more details.
42 % You should have received a copy of the GNU General Public License
43 % along with this program. If not, see <http://www.gnu.org/licenses/>.
47 res=[ones(lr,1) zeros(lr,lc)];
49 if nargout<3 % needs O(p^2) memory
50 MX=zeros(lr,lc*(lc+1)/2);
51 MX(:,lc*(lc-1)/2+(1:lc))=ar;
53 % Durbin-Levinson Algorithm
56 %idx=K*(K-1)/2; %see below
57 MX(:,(K-2)*(K-1)/2+(1:K-1)) = (MX(:,idx+(1:K-1)) + MX(:,(idx+K)*ones(K-1,1)).*MX(:,idx+(K-1:-1:1)))./((ones(lr,1)-abs(MX(:,idx+K)).^2)*ones(1,K-1));
61 idx=K*(K-1)/2; %see below
62 res(:,K+1) = res(:,K).*(1-abs(MX(:,idx+K)).^2);
65 %arp=MX(:,K*(K-1)/2+(1:K));
66 %rc =MX(:,(1:K).*(2:K+1)/2);
68 else % needs O(p) memory
73 MX=ar; % assign output
75 % Durbin-Levinson Algorithm
77 ar(:,1:K)=(ar(:,1:K)+ar(:,(K+1)*ones(K,1)).*ar(:,K:-1:1))./((ones(lr,1)-abs(ar(:,K+1)).^2)*ones(1,K));
82 res(:,K+1) = res(:,K) .* (1-abs(ar(:,K)).^2);
85 % assign output arguments