Main Content

rlevinson

Reverse Levinson-Durbin recursion

    Description

    r = rlevinson(a,eFinal) returns the autocorrelation sequence r for a prediction filter with coefficients specified in a and final prediction error power e.

    [r,u] = rlevinson(___) also returns the recursive prediction filter polynomial matrix.

    [___,k] = rlevinson(___) also returns the list of reflection coefficients.

    [___,eEvolution] = rlevinson(___) also returns the prediction errors from each iteration of the reverse Levinson-Durbin recursion.

    example

    Examples

    collapse all

    Estimate the spectrum of two sine waves in noise using an autoregressive model. Choose the best model order from a group of models returned by the reverse Levinson-Durbin recursion.

    Generate a 50,000-sample signal. Specify a sample rate of 1 kHz and a signal duration of 50 seconds. The sinusoids have frequencies of 50 Hz and 55 Hz. The noise has a variance of (0.2)2.

    rng default
    Ns = 50e3;
    Fs = 1000;
    t = (0:Ns-1)'/Fs;
    
    x = sin(2*pi*50*t) + sin(2*pi*55*t) + 0.2*randn(Ns,1);

    Estimate the autoregressive model parameters using a model of order 100.

    [ar,eFinal] = arcov(x,100);

    Solve the model using the reverse Levinson-Durbin recursion to estimate the autocorrelation sequence, recursive prediction filters, reflection coefficients and prediction errors.

    [r,u,k,eEvol] = rlevinson(ar,eFinal);

    Plot the prediction errors. Add a horizontal line for the final error power. The error decreases with an increasing filter order until reaching the final error power.

    plot(eEvol)
    hold on
    yline(eFinal,"--","eFinal")
    hold off
    ylim([0 eEvol(1)])
    xlabel("Model order")
    ylabel("Prediction Error")

    Figure contains an axes object. The axes object with xlabel Model order, ylabel Prediction Error contains 2 objects of type line, constantline.

    Estimate the power spectral density (PSD) for orders 1, 5, 25, 50, and 100. Estimate the PSD for the original autoregressive parameters.

    N = [1 5 25 50 100];
    nFFT = 8096;
    psdARpred = zeros(nFFT,5);
    
    for idx = 1:numel(N)
        order = N(idx);
        ARpred = flipud(u(:,order));
        psdARpred(:,idx) = 1./abs(fft(ARpred,nFFT)).^2;
    end
    psdAR = 1./abs(fft(ar,nFFT)).^2;

    Plot the PSD estimates. The PSD estimates for the prediction filters get progressively closer to the original autoregressive parameters as the order increases.

    F = (0:1/nFFT:1/2-1/nFFT)*Fs;
    
    figure
    plot(F,pow2db(psdARpred(1:length(psdARpred)/2,:)))
    hold on
    plot(F,pow2db(psdAR(1:length(psdAR)/2)),"--k")
    hold off
    grid
    
    legend(["Order = "+N';"Original AR"])
    xlabel("Frequency (Hz)")
    ylabel("Power (dB/Hz)")
    xlim([35 70])

    Figure contains an axes object. The axes object with xlabel Frequency (Hz), ylabel Power (dB/Hz) contains 6 objects of type line. These objects represent Order = 1, Order = 5, Order = 25, Order = 50, Order = 100, Original AR.

    Input Arguments

    collapse all

    Prediction filter coefficients, specified as a vector.

    Note

    The filter associated with a must be minimum phase to generate a valid autocorrelation sequence r.

    If a is not minimum phase , the rlevinson function can return NaN or Inf values, even if a solution exists.

    Data Types: single | double
    Complex Number Support: Yes

    Final prediction error power, specified as a scalar.

    Data Types: single | double
    Complex Number Support: Yes

    Output Arguments

    collapse all

    Autocorrelation sequence, returned as a column vector with the same number of elements as in a.

    Recursive prediction filter polynomial matrix, returned as a square matrix with as many rows and columns as in the number of elements of a.

    List of reflection coefficients, returned as a column vector of length p, where p+1 is the number of elements of a.

    List of recursive prediction errors from each iteration of the reverse Levinson-Durbin recursion, returned as a row vector. The vector eEvolution has a length p, where p+1 is the number of elements of a.

    Algorithms

    The reverse Levinson-Durbin recursion implements the step-down algorithm for solving the symmetric Toeplitz system of linear equations

    [r(1)r(2)r(p1)r(p)r(2)r(1)r(p2)r(p1)r(p1)r(p2)r(1)r(2)r(p)r(p1)r(2)r(1)][a(2)a(3)a(p)a(p+1)]=[r(2)r(3)r(p)r(p+1)],

    where r = [r(1) r(2) … r(p) r(p + 1)] and a = [1 a(2) … a(p + 1)]. The notation * represents the complex conjugate transpose operation.

    In linear prediction applications:

    • The vector r represents the autocorrelation sequence of the input to a prediction filter, where r(1) is the zero-lag element. The Toeplitz matrix R is the autocorrelation matrix.

      R=[r(1)r(2)r(p1)r(p)r(2)r(1)r(p2)r(p1)r(p1)r(p2)r(1)r(2)r(p)r(p1)r(2)r(1)]

    • The vector a represents the polynomial coefficients of this prediction filter in descending powers of z.

    • The scalar p represents the order of the prediction filter.

      A(z)=1+a(2)z1++a(n+1)zp

    The figure shows the typical filter of this type, where H(z) is the optimal linear predictor, x(n) is the input signal, x^(n) is the predicted signal, and e(n) is the prediction error signal. The variance of the prediction error, var(e) is the scalar prediction error power.

    The rlevinson function solves this system of equations to compute the autocorrelation sequence r, given a vector a with the prediction filter coefficients. The filter must be minimum-phase to generate a valid autocorrelation sequence. The scalar eFinal represents the final prediction error power, var(e), and aims to be the target estimation error of the Levinson-Durbin recursion that the rlevinson function implements.

    If you request the outputs u, k, or eEvolution, rlevinson also performs the UDU* decomposition of the inverse of the autocorrelation matrix, R−1. This decomposition resolves the matrices U and E, and permits the efficient evaluation of the inverse of the autocorrelation matrix, R−1.

    R1=UE1U

    The output argument u returns the matrix U. This matrix contains the recursive prediction filter polynomials (a1, a2, …, ap+1) from each iteration of the reverse Levinson-Durbin recursion.

    U=[a1(1)a2(2)ap+1(p+1)0a2(1)ap+1(p)00ap+1(p1)00ap+1(1)]

    Each vector ai lists the recursive polynomial coefficients, where ai(j) is the jth coefficient of the (i-1)th order prediction filter polynomial (i.e., ith step in the recursion). For example, you can get the coefficients of the 4th order prediction filter polynomial as a5, where a5 = u(5:-1:1,5), and this vector represents the polynomial A5(z)=a5(1)+a5(2)z1+...+a5(5)z4. Consequently, the (p+1)th column of U contains the input polynomial coefficient vector a, which you can get using u(p+1:-1:1,p+1)'.

    The output argument k returns a column vector with the reflection coefficients, which are the conjugates of the nondiagonal elements in the first row of U. In other words, k is returned as u(1,2:end)'.

    k=[a2(2)a3(3)ap+1(p+1)]

    The output argument eEvolution returns a row vector with the recursive prediction errors, which come from the diagonal of the matrix E, except the first element.

    E=[e1000e2000ep+1]

    eEvolution=[e2e3ep+1]

    Each element ei lists the recursive prediction errors of the (i-1)th order prediction filter polynomial (i.e., ith step in the recursion). For example, you can get the prediction error of the 4th order prediction filter polynomial as e5 = eEvolution(4), and is the prediction error for using the polynomial A5(z)=a5(1)+a5(2)z1+...+a5(5)z4 as a prediction filter.

    • The first element from the diagonal of E, e1, coincides with the first element of the autocorrelation sequence r, r(1).

    • The (p+1)th element from the diagonal of E, e1, —also the last element in eEvolution— coincides with the final prediction error power eFinal.

    References

    [1] Kay, Steven M. Modern Spectral Estimation: Theory and Application. Englewood Cliffs, NJ: Prentice-Hall, 1988.

    Extended Capabilities

    Version History

    Introduced before R2006a

    See Also

    | | | |