%% Yule-Walker AR Method
% The Yule-Walker AR method of spectral estimation computes the AR parameters by solving the following linear system, which give the Yule-Walker equations in matrix form:
% \left\lbrack \begin{array}{cccc}
% r\left(0\right) & r\left(1\right) & \cdots  & r\left(p-1\right)\\
% r\left(1\right) & r\left(0\right) & \cdots  & r\left(p-2\right)\\
% \vdots  & \vdots  & \ddots  & \vdots \\
% r\left(p-1\right) & r\left(p-2\right) & \cdots  & r\left(0\right)
% \end{array}\right\rbrack \left\lbrack \begin{array}{c}
% a\left(1\right)\\
% a\left(2\right)\\
% \vdots \\
% a\left(p\right)
% \end{array}\right\rbrack =\left\lbrack \begin{array}{c}
% r\left(1\right)\\
% r\left(2\right)\\
% \vdots \\
% r\left(p\right)
% \end{array}\right\rbrack.
% In practice, the biased estimate of the autocorrelation is used for the unknown true autocorrelation. The Yule-Walker AR method produces the same results as a maximum entropy estimator.
% The use of a biased estimate of the autocorrelation function ensures that the autocorrelation matrix above is positive definite. Hence, the matrix is invertible and a solution is guaranteed to exist. Moreover, the AR parameters thus computed always result in a stable all-pole model. The Yule-Walker equations can be solved efficiently using Levinson’s algorithm, which takes advantage of the Hermitian Toeplitz structure of the autocorrelation matrix.
% The toolbox function pyulear implements the Yule-Walker AR method. For example, compare the spectrum of a speech signal using Welch's method and the Yule-Walker AR method. Initially compute and plot the Welch periodogram.

load mtlb
pwelch(mtlb,hamming(256),128,1024,Fs)

%
% The Yule-Walker AR spectrum is smoother than the periodogram because of the simple underlying all-pole model.

order = 14;
pyulear(mtlb,order,1024,Fs)

% Copyright 2018 The MathWorks, Inc.