Is there a way to convert a
FIR to an
IIR filter with the most similar behavior?
I would say that the answer to your question - if taken literally - is 'no', there is no general way to simply convert an FIR filter to an IIR filter.
I agree with RBJ that one way to approach the problem is to look at the FIR filter's impulse response and use a time domain method (such as Prony's method) to approximate that impulse response by an IIR filter.
If you start from the frequency response then you have lots of methods for designing IIR filters. Even though it was published about 25 years ago, I believe that the method by Chen and Parks is still one of the better ways to approach the design problem. Another very simple method for the frequency domain design of IIR filters is the equation error method, which is described in the book Digital Filter Design by Parks and Burrus. I've explained it in this answer.
If the phase response is of importance to you, then one problem you will be facing when designing IIR filters in the frequency domain is the exact choice of the desired phase response. If the overall shape of the desired phase is given you still have one degree of freedom, which is the delay. E.g., if the desired phase is $\phi_D(\omega)$, and the desired magnitude is $M_D(\omega)$ then your desired frequency response can be chosen as
where $\tau$ is an unknown delay parameter. Of course you can say that if $\phi_D(\omega)$ is given then you don't want to modify it with an additional (positive or negative) delay. But it turns out that in practice the average delay is not always important, and - more importantly - for certain values of $\tau$ your approximation will be much better for a given filter order than for others. So the delay $\tau$ can become an additional design parameter and should be chosen optimally or at least reasonably.
I've written a thesis on the design of digital filters with prescribed magnitude and phase responses. One chapter deals with the frequency domain design of IIR filters. That method can be used to design IIR filters with approximately linear phase in the pass-bands, or to approximate any other desired phase (and magnitude) response. The filters are not only guaranteed to be stable, but you can also prescribe a maximum pole radius, i.e., you can define a certain stability margin. You can also find this method in a paper published in the IEEE Transactions on Signal Processing.
Matt L's answer is the best from a DSP perspective.
There exist a whole array of techniques from the control literature that might also do what you're asking. While this is not explicitly turning an FIR filter into an IIR, the techniques will generally find an IIR solution unless some other constraints are applied.
Some of the techniques are:
Optimal Hankel Norm Approximation uses the infinity-like Hankel norm to approximate a high order system with one of a lower order. There is a matlab implementation of it in the Robust Control Toolbox.
Yet another method that might be able approximate (not exactly match) a given arbitrary frequency response (such as one described by some given FIR filter) by an IIR filter, is Differential Evolution. Differential Evolution is a type of genetic algorithm that, for this use, iteratively selects and adapts a set of poles and zeros in an attempt to minimize a computed difference error. There seem to be a few IEEE papers on the topic, as well as a chapter in one of Rick Lyons books ("Streamlining DSP").
If you're trying to match the impulse response of the IIR to a given impulse response, however it's mathematically defined (I guess the FIR is as good of a definition as any), I've always thought that the Prony method was the first stab at the problem.
If you're trying to match the frequency response of the IIR to a given frequency response, however it's mathematically defined (I guess the frequency response of the FIR is as good of a definition as any), I've recently thought that Greg Berchin's FDLS might be the way to go. Richard Lyons (who commented to your question), published a monograph where Greg had a chapter describing the method. Matt L also has researched and published on the problem.
well yes, since you didn't require an exact equivalent but not without grief
A FIR filter is equivalent to a polynomial
One can derive a Pade approximation.
It will not necessarily be stable, it is very sensitive to scaling, and the result isn't thrilling.
Using a hanning window as an FIR example and the Pade routine in the symbolic toolbox (which most people don't have but gnu Maxima does)
My other idea which I haven't pursued would be to generate a pseudorandom MA process and then use an ARMA estimator to recover the rational transfer function.
p = poly2sym(sym(round(100*hanning(16))))% scaled hanning
p = 3*x^15 + 13*x^14 + 28*x^13 + 45*x^12 + 64*x^11 + 80*x^10 + 93*x^9 + 99*x^8 + 99*x^7 + 93*x^6 + 80*x^5 + 64*x^4 + 45*x^3 + 28*x^2 + 13*x + 3
h=pade(p,'Order', [3 3])
h = -(2534*x^3 + 11071*x^2 + 10368*x + 2961)/(- 2213*x^3 + 1964*x^2 + 821*x - 987)
n = - 2534*x^3 - 11071*x^2 - 10368*x - 2961
d = - 2213*x^3 + 1964*x^2 + 821*x - 987
num = -2534 -11071 -10368 -2961
den = -2213 1964 821 -987
rn = -3.2067 + 0.0000i
-0.5812 + 0.1633i
-0.5812 - 0.1633i
rd = -0.6679 + 0.0000i
0.7777 + 0.2510i
0.7777 - 0.2510i
num=num/sum(abs(num)); %normalizing coefficients
figure(1) plot(z,log10(abs(h))); ylabel('dB') figure(2) [h,z]=freqz(fir,1,1024); plot(z,log10(abs(h))); ylabel('dB')
It it tempting to speculate that if a windowed impulse response, h of lenght L can be "well modelled" by a low order (relative to L) iir filter, then the latter can be used to extrapolate the FIR filter beyond its original length.
What is the practical pros and cons of using prony (time domain) vs using invfreqz (frequency domain)?