# [SciPy-Dev] SciPy Goal

josef.pktd@gmai... josef.pktd@gmai...
Thu Jan 5 17:04:18 CST 2012

```On Thu, Jan 5, 2012 at 5:30 PM, Neal Becker <ndbecker2@gmail.com> wrote:
> Travis Oliphant wrote:
>
>>
>> On Jan 5, 2012, at 1:19 PM, Neal Becker wrote:
>>
>>> Travis Oliphant wrote:
>>>
>>>>
>>>> On Jan 5, 2012, at 10:00 AM, josef.pktd@gmail.com wrote:
>>>>
>>>>> On Thu, Jan 5, 2012 at 10:32 AM, Neal Becker <ndbecker2@gmail.com> wrote:
>>>>>> Some comments on signal processing:
>>>>>>
>>>>>> Correct me if I'm wrong, but I think scipy signal (like matlab) implement
>>>>>> only a
>>>>>> general purpose filter, which is an IIR filter, single rate.  Efficiency
>>>>>> is very important in my work, so I implement many optimized variations.
>>>>>>
>>>>>> Most of the time, FIR filters are used.  These then come in variations for
>>>>>> single rate, interpolation, and decimation (there is also another design
>>>>>> for
>>>>>> rational rate conversion).  Then these have variants for scalar/complex
>>>>>> input/output, as well as complex in/out with scalar coefficients.
>>>>>>
>>>>>> IIR filters are seperate.
>>>>>>
>>>>>> FFT based FIR filters are another type, and include both complex in/out as
>>>>>> well as scalar in/out (taking advantage of the 'two channel' trick for
>>>>>> fft).
>>>>>
>>>>> just out of curiosity: why no FFT base IIR filter?
>>>>>
>>>>> It looks like a small change in the implementation, but it is slower
>>>>> than lfilter for shorter time series so I mostly dropped fft based
>>>>> filtering.
>>>>
>>>> I think he is talking about filter design, correct?
>>>>
>>>
>>> filter design.
>>>
>>> About FFT-based IIR filter, I never heard of it.  I was talking about the
>>> fact that fft can be used to efficiently implement a linear convolution
>>> exactly (for the case of convolution of a finite or short sequence - the
>>> impulse response of the filter - with a long or infinite sequence, the
>>> overlap-add or overlap-save techniques are used).
>>
>> Sure, of course.   It's hard to know the way people are using terms.   I agree
>> that people don't usually use the term IIR when talking about an FFT-based
>> filter (but there is an "effective" time-domain response for every filtering
>> operation done in the Fourier domain --- as you noted).   That's what I was
>> referring to.
>>
>> It's been a while since I wrote lfilter, but it transposes the filtering
>> operation  into Direct Form II, and then does a straightforward implementation
>> of the feed-back and feed-forward equations.
>>
>> Here is some information on the approach:
>> https://ccrma.stanford.edu/~jos/fp/Direct_Form_II.html
>>
>> IIR filters implemented in the time-domain need something like lfilter.   FIR
>> filters are "just" convolution in the time domain --- and there are different
>> approaches to doing that discrete-time convolution as you've noted.   IIR
>> filters are *just* convolution as well (but convolution with an infinite
>> sequence).   Of course, if you use the FFT-domain to implement the filter,
>> then you can just as well design in that space the filtering-function you want
>> to multiply the input signal with (it's just important to keep in mind the
>> impact in the time-domain of what you are doing in the frequency domain ---
>> i.e. sharp-edges result in ringing, the basic time-frequency product
>> limitations, etc.)
>>
>> These same ideas come under different names and have different emphasis in
>> different disciplines.
>>
>> -Travis
>
> Here, I claim the best approach is to realize that
> 1. Just making the coefficients in the freq domain be samples of a desired
> response gives you no exact result (as you noted), but
> 2. On the other hand, fft can be used to perform fast convolution, which is (can
> be) mathematically exactly the same as time domain convolution.  Therefore, just
> realize that
> * use your favorite FIR filter design tool (e.g., remez) to design the filter
> Now the only approximation is in the fir filter design step, and you should know
> precisely what is the nature of any approximation

Thanks, if I understand both of you correctly, then the difference
comes down to whether we want to have a parsimonious IIR
parameterization, with only a few parameters that can be estimated as
in time series analysis (Box-Jenkins), or whether you want to design a
filter where having a "long" FIR representation doesn't have any
disadvantages (in frequency domain, FFT, the filter might be full
length anyway).

Josef

>
> _______________________________________________
> SciPy-Dev mailing list
> SciPy-Dev@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-dev
```