Engee documentation

yulewalk

Designing a recursive digital filter.

Library

EngeeDSP

Syntax

Function call

  • b, a = yulewalk(n, f, m) — returns the coefficients of the IIR filter transfer function n`th order, the amplitude-frequency response of which approximately corresponds to the values specified in `f and m.

Arguments

Input arguments

# n — filter order

+ a positive integer scalar

Details

The filter order, specified as a positive integer scalar.

Типы данных

Float32, Float64

# f — frequency values

+ vector

Details

Frequency values set as a vector with elements ranging from 0 before 1, where 1 corresponds to the Nyquist frequency, or half the sampling frequency. The first element f must be equal to 0, and the last one — 1. All intermediate elements must be arranged in ascending order. Vector f It may have repeated frequency values corresponding to the steps of the frequency response.

Типы данных

Float32, Float64

# m — amplitude response

+ vector

Details

The amplitude response, defined as a vector containing the required response values at the frequency values specified in f. Vector length m must be equal to the length of the vector f.

Типы данных

Float32, Float64

Output arguments

# b, a are the coefficients of the filter

+ string vectors

Details

The filter coefficients returned as row vectors. The coefficients of the output filter are ordered in descending order of degrees :

Examples

Designing a low—pass filter using the Yule-Walker method

Details

Let’s design a low-pass filter 8-th order with a normalized cutoff frequency 0.6. Let’s construct its frequency response and superimpose on it the characteristic of the corresponding ideal filter.

import EngeeDSP.Functions: yulewalk, freqz

f1 = [0, 0.6, 0.6, 1]
m1 = [1, 1, 0, 0]

b1,a1 = yulewalk(8,f1,m1)
h1,w1 = freqz(b1,a1,128)

p = plot(w1/π, mag2db.(abs.(h1)),
         xlabel = "ω/π",
         ylabel = "Magnitude (dB)",
         grid = true,
         legend = false,
         linecolor = :blue)

vline!(f1[2:3], linestyle = :dash, linecolor = :black)

yulewalk 1

Increase the attenuation in the suppression band by specifying a wider transition band.

f2 = [0, 0.55, 0.6, 0.65, 1]
m2 = [1, 1, 0.5, 0, 0]

b2,a2 = yulewalk(8,f2,m2);
h2,w2 = freqz(b2,a2,128)

plot!(w2/π, mag2db.(abs.(h2)),
      linecolor = :red)

yulewalk 2

Recommendations

When setting the frequency response, avoid excessively abrupt transitions from the bandwidth to the barrier band. You may need to experiment with the slope of the transition region to obtain an optimal filter design.

Algorithms

Function yulewalk constructs recursive digital IIR filters using the least squares method to approximate a given frequency response. The approximation is performed in the time domain.

  • To calculate the coefficients of the denominator, the function yulewalk It uses modified Yule—Walker equations, the correlation coefficients of which are calculated using the inverse Fourier transform of a given frequency response.

  • To calculate the numerator, the function yulewalk performs the following steps:

    1. Calculates the numerator polynomial corresponding to the additive decomposition of the power-frequency characteristic.

    2. Calculates the total frequency response corresponding to the polynomials of the numerator and denominator.

    3. Uses the spectral factorization method to obtain the impulse response of the filter.

    4. Obtains the numerator polynomial by least squares approximation of this impulse response.

Literature

  1. Friedlander, B., and Boaz Porat. The Modified Yule-Walker Method of ARMA Spectral Estimation. IEEE® Transactions on Aerospace Electronic Systems. Vol. AES-20, Number 2, 1984, pp. 158–173.