⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 earpk.m

📁 时间序列工具箱
💻 M
字号:
function  [a,A] = earpk(Y,p);
% [a,A] = earpk(Y,p);
% Estimate Coefficients of AR-Process
%	Y(t) = a' * Y(t-1) + E(t)
% using the Kalman approach
%
% Input:
% 	p	model order
%	Y	Signal (AR-Process)
%
% Output:
%	a	AR-Parameter
%	A	VarianceCovariance Matrix

%	Version 2.30
%	last revision 21.03.1998
%	Copyright (c) 1997, 1998 by Alois Schloegl
%	e-mail: a.schloegl@ieee.org	

% This library is free software; you can redistribute it and/or
% modify it under the terms of the GNU Library General Public
% License as published by the Free Software Foundation; either
% Version 2 of the License, or (at your option) any later version.
%
% This library is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
% Library General Public License for more details.
%
% You should have received a copy of the GNU Library General Public
% License along with this library; if not, write to the
% Free Software Foundation, Inc., 59 Temple Place - Suite 330,
% Boston, MA  02111-1307, USA.

ly = size(Y);
if ~sum(ly <= 1)
    error('Must be a vector.')
end
ly = max(ly);
if diff(ly)>0
	Y = Y';    % Make sure it's a row vector
end;	

a=zeros(p,1);
A=diag(ones(1,p));
%------------------------------------------------
%	Update Equations
%------------------------------------------------
for i=1:p,
	xt=[Y(i-1:-1:1)';zeros(p-i+1,1)];
    	e = Y(i) - xt'*a;
	axt = A*xt;
	ft = (xt' * axt + 1);
	c = axt / ft;		
	a = a + c*e;
	A = A - c*xt'*A;
end;
for i=p+1:ly,
 	xt=Y(i-1:-1:i-p)';	% vectorize the past p samples
    	e = Y(i) - xt'*a;	% one-step prediction error
	axt = A*xt;             % temporary variable
	ft = (xt' * axt + 1);   % nominator of Kalman Gain
	c = axt / ft;           % Kalman gain vector
	a = a + c*e;            % Update of AR-coefficients
	A = A - c*xt'*A;	% Update of Covariance-Matrix
end;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -