IIRLS Function
Approximates time-domain or frequency-domain least squares infinite impulse response (IIR) digital filters.
Usage
result = IIRLS(m, n, h[, l])
Input Parameters
m—The order of the filter numerator polynomial.
n—The order of the filter denominator polynomial.
h—An array containing samples of the impulse response or frequency response.
l—(optional) The total number of frequency response samples used in the design. This parameter is required if the Freqsample keyword is specified.
Returned Value
result—A filter structure containing the filter approximation.
Keywords
Freqsample—If present and nonzero, a frequency-domain least squares method is used.
 
note
The optional input parameter l must be used when Freqsample is specified.
Prony—If present and nonzero, Prony’s time-domain least squares method is used.
Discussion
IIRLS determines numerator and denominator coefficients of an IIR filter:
to approximate a given set of impulse response samples
h(k),     k = 0, 1, ..., K
or uniform set of frequency response samples:
where the frequency samples are selected as:
If Prony is specified, Prony’s method for time-domain design of FIR filters is used. This method is based on noting that the rational transfer function may be rewritten:
B(z) = H(z)A(z)
Using the first K + 1 terms of the impulse response h(n), the inverse z-transform of this equation can be written:
Given K M + N impulse response samples, Prony’s method selects filter coefficients to minimize least-squares equation error of the above matrix equation. If K = M + N and the impulse response samples are consistent with a rational transfer function, this method will produce a filter with an impulse response that matches the K-given impulse response samples.
If Freqsample is specified, the frequency-domain least squares method is used. This method is based on noting that if we have L + 1 uniform samples of the frequency response, the sampled rational transfer function may be rewritten:
Bk = HkAk
In this relationship, Hk is the frequency response sample defined previously:
Bk = DFT{bn}
and:
Ak = DFT{an}
and both discrete Fourier transforms (DFT) are taken over L points. The inverse DFT of the above equation can be written:
where matrix elements hn are defined as:
Given L M + N uniform frequency response samples, IIRLS selects the filter coefficients to minimize the least squares equation error of the matrix equation. If L = M + N  and the frequency response samples are consistent with a rational transfer function, this method will produce a filter with frequency response that interpolates the L-given frequency response samples.
IIRLS only produces filters with real coefficients. This requires that the sequence hn be real. The values of Hk are therefore forced to satisfy the standard symmetry properties of the DFT to ensure that hn is real. If the total number of frequency samples L used in technique is odd, the number of frequency response samples Hk provided by the user must be greater than (L + 1)/2. If L is even, the number of samples must be greater than or equal to (L + 2)/2. Because of the forced symmetry, only the first (L + 1)/2 (for L odd) or (L + 2)/2 (for L even) elements of Hk are used in the routine. Any additional samples of Hk are ignored.
 
note
If the impulse or frequency response samples are consistent with an unstable filter, then an unstable filter will be returned by IIRLS. It is recommended that you verify the stability of the returned filter by applying SCHURCOHN to the denominator coefficients. It is also possible to stabilize an unstable filter without affecting its magnitude response by using the P_STAB function.
Example 1
This example illustrates how IIRLS with the keyword Prony can be used to design a filter that matches a given set of L + 1 impulse response samples.
l = 6 
h = IIRDESIGN(l/2, 0.5, /Butter)
; Design a filter and compute a set of impulse response samples.
desired_impul = IMPRESP(h, l+1)
PARSEFILT, h, name, numer, denom
PM, numer, Title = 'Original Filter Numerator Coefficients'
PM, denom, Title = 'Original Filter Denominator Coefficients'
; Compute filter coefficients that match the desired impulse 
; response samples.
hls = IIRLS(l/2, l/2, desired_impul, /Prony)
PARSEFILT, hls, name, numerls, denomls
PM, numerls, Title='Least Squares Filter Numerator Coefficients'
PM, denomls, Title = 'Least Squares Filter ' + $
'Denominator Coefficients'
Example 2
This example illustrates how IIRLS with the keyword Freqsample can be used to design a filter that interpolates a given set of L frequency response samples.
l = 8
h = IIRDESIGN(l/2, 0.5, /Butter)
f= -2*DINDGEN(l)/DOUBLE(l+1)
desired_freqsamples = FREQRESP_Z(h, Infreq = f)
; Design a filter and compute a set of frequency response samples.
PARSEFILT, h, name, numer, denom
PM, numer, Title = 'Original Filter Numerator Coefficients'
PM, denom, Title = 'Original Filter Denominator Coefficients'
hls = IIRLS(l/2, l/2, desired_freqsamples, l, /Freqsample)
; Compute filter coefficients that match the desired frequency
; response samples.
PARSEFILT, hls, name, numerls, denomls
PM, numerls, Title='Least Squares Filter Numerator Coefficients'
PM, denomls, Title = $
'Least Squares Filter Denominator Coefficients'
See Also
For Additional Information
Parks and Burrus, 1987, sections 7.4 and 7.5.