1 function [A] = lpc(Y,P,mode);
2 % LPC Linear prediction coefficients
3 % The Burg-method is used to estimate the prediction coefficients
5 % A = lpc(Y [,P]) finds the coefficients A=[ 1 A(2) ... A(N+1) ],
6 % of an Pth order forward linear predictor
8 % Xp(n) = -A(2)*X(n-1) - A(3)*X(n-2) - ... - A(N+1)*X(n-P)
10 % such that the sum of the squares of the errors
12 % err(n) = X(n) - Xp(n)
14 % is minimized. X can be a vector or a matrix. If X is a matrix
15 % containing a separate signal in each column, LPC returns a model
16 % estimate for each column in the rows of A. N specifies the order
17 % of the polynomial A(z).
19 % If you do not specify a value for P, LPC uses a default P = length(X)-1.
22 % see also ACOVF ACORF AR2POLY RC2AR DURLEV SUMSKIPNAN LATTICE
26 % J.P. Burg, "Maximum Entropy Spectral Analysis" Proc. 37th Meeting of the Society of Exp. Geophysiscists, Oklahoma City, OK 1967
27 % J.P. Burg, "Maximum Entropy Spectral Analysis" PhD-thesis, Dept. of Geophysics, Stanford University, Stanford, CA. 1975.
28 % P.J. Brockwell and R. A. Davis "Time Series: Theory and Methods", 2nd ed. Springer, 1991.
29 % S. Haykin "Adaptive Filter Theory" 3rd ed. Prentice Hall, 1996.
30 % M.B. Priestley "Spectral Analysis and Time Series" Academic Press, 1981.
31 % W.S. Wei "Time Series Analysis" Addison Wesley, 1990.
33 % $Id: lpc.m 5090 2008-06-05 08:12:04Z schloegl $
34 % Copyright (C) 1996-2002,2008 by Alois Schloegl <a.schloegl@ieee.org>
35 % This is part of the TSA-toolbox. See also
36 % http://hci.tugraz.at/schloegl/matlab/tsa/
38 % This program is free software: you can redistribute it and/or modify
39 % it under the terms of the GNU General Public License as published by
40 % the Free Software Foundation, either version 3 of the License, or
41 % (at your option) any later version.
43 % This program is distributed in the hope that it will be useful,
44 % but WITHOUT ANY WARRANTY; without even the implied warranty of
45 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
46 % GNU General Public License for more details.
48 % You should have received a copy of the GNU General Public License
49 % along with this program. If not, see <http://www.gnu.org/licenses/>.
54 fprintf(2,'Warning LCP: data vector Y must be a column not a row vector\n');
61 % you can use any of the following routines.
62 % the lattice methods are preferable for stochastic time series.
63 % but can fail for deterministic signals see:
64 % http://sourceforge.net/mailarchive/message.php?msg_name=20080516115110.GB20642%40localhost
66 % [AR,RC,PE] = lattice(Y.',P); % Burg method
67 % [AR,RC,PE] = lattice(Y.',P,'GEOL'); % geometric lattice
68 [AR,RC,PE] = durlev(acovf(Y.',P)); % Yule-Walker