# Fitting filters to frequency response¶

This module contains several functions to carry out a least-squares fit to a given complex frequency response.

This module contains the following functions:

• LSIIR: Least-squares IIR filter fit to a given frequency response
• LSFIR: Least-squares fit of a digital FIR filter to a given frequency response

Deprecated since version 1.2.71: The module identification will be combined with the module deconvolution and renamed to model_estimation in the next major release 3.0. From then on you should only use the new module model_estimation instead.

PyDynamic.identification.fit_filter.LSIIR(Hvals, Nb, Na, f, Fs, tau=0, justFit=False)[source]

Least-squares IIR filter fit to a given frequency response.

This method uses Gauss-Newton non-linear optimization and pole mapping for filter stabilization

Parameters: Hvals (numpy array of frequency response values of shape (M,)) – Nb (integer numerator polynomial order) – Na (integer denominator polynomial order) – f (numpy array of frequencies at which Hvals is given of shape) – (M,) – Fs (sampling frequency) – tau (integer initial estimate of time delay) – justFit (boolean, when true then no stabilization is carried out) – b,a (IIR filter coefficients as numpy arrays) tau (filter time delay in samples)

References

PyDynamic.identification.fit_filter.LSFIR(H, N, tau, f, Fs, Wt=None)[source]

Least-squares fit of a digital FIR filter to a given frequency response.

Parameters: H (frequency response values of shape (M,)) – N (FIR filter order) – tau (delay of filter) – f (frequencies of shape (M,)) – Fs (sampling frequency of digital filter) – Wt ((optional) vector of weights of shape (M,) or shape (M,M)) – filter coefficients bFIR (ndarray) of shape (N+1,)