%% Burg Method
% The Burg method for AR spectral estimation is based on minimizing the forward and backward prediction errors while satisfying the Levinson-Durbin recursion. In contrast to other AR estimation methods, the Burg method avoids calculating the autocorrelation function, and instead estimates the reflection coefficients directly.
%  The primary advantages of the Burg method are resolving closely spaced sinusoids in signals with low noise levels, and estimating short data records, in which case the AR power spectral density estimates are very close to the true values. In addition, the Burg method ensures a stable AR model and is computationally efficient.
% The accuracy of the Burg method is lower for high-order models, long data records, and high signal-to-noise ratios (which can cause line splitting, or the generation of extraneous peaks in the spectrum estimate). The spectral density estimate computed by the Burg method is also susceptible to frequency shifts (relative to the true frequency) resulting from the initial phase of noisy sinusoidal signals. This effect is magnified when analyzing short data sequences.
% The toolbox function pburg implements the Burg method. Compare the spectrum estimates of a speech signal generated by both the Burg method and the Yule-Walker AR method. Initially compute and plot the Burg estimate.

load mtlb
order = 14;
pburg(mtlb(1:512),order,1024,Fs)

%
% The Yule-Walker estimate is very similar if the signal is long enough.

pyulear(mtlb(1:512),order,1024,Fs)

% Compare the spectrum of a noisy signal computed using the Burg method and the Welch method. Create a two-component sinusoidal signal with frequencies 140 Hz and 150 Hz embedded in white Gaussian noise of variance 0.1². The second component has twice the amplitude of the first component. The signal is sampled at 1 kHz for 1 second. Initially compute and plot the Welch spectrum estimate.

fs = 1000;
t = (0:fs)/fs;
A = [1 2];
f = [140;150];
xn = A*cos(2*pi*f*t) + 0.1*randn(size(t));

pwelch(xn,hamming(256),128,1024,fs)

% Compute and plot the Burg estimate using a model of order 14.

pburg(xn,14,1024,fs)

% Copyright 2018 The MathWorks, Inc.