2
$\begingroup$

Sometimes, we met Non-causal FIR filter problem like this picture enter image description here left is ifft of frequency response and right is time shifted fir filter to be causal filter in noise cancellation problem, delay is very annoying things.

my question is if i do filtering process in frequency domain, ideal filter (that is not delayed for making fir filter to be causal) can be used?

i can't understand why i have to do this pure delay to make causal filter.

what is the problem when i do filtering signal with frequency response of Non-causal fir filter?? i think that is just multiply process

thank you

$\endgroup$

4 Answers 4

2
$\begingroup$

left is ifft of frequency response and right is time shifted fir filter to be causal filter in noise cancellation problem, delay is very annoying things.

You are misinterpreting the results of the IFFT in your picture on the left side. This comes from using the IFFT where you should, properly, use the inverse DTFT.

The DFT (from whence the FFT comes), has an output domain that is both discrete and circular, where any given frequency $\theta$ is congruent with any other frequency $\theta + 2\pi m$. (As typically implemented, this means that for an $N$-point IFFT, any sample $n$ is congruent with any other sample $n + N\ m$).

You problem comes because you're talking about actual physical filters that operate in a time domain over all the integers. For this, the DFT (and, hence, FFT and IFFT) does not fit. Formally, you should be using the the inverse DTFT, where the domain of the output is all the integers.

Where you to do this, you would find that your filter's impulse response $h(n)$ has non-compnents for $n < 0$. This is what makes your filter non-causal. It's obvious in retrospect -- if the filter is responding before the input, then it can't exist in the physical world.

Let me reiterate this:

  • Filters that start responding to an input before it happens are non-causal.
  • We live in a causal universe.
  • Non-causal filters are not real.

Now, someone's going to object that, no, non-causal filters are real, they apply them to recorded data all the time. OK, fine, if you're applying a filter to recorded data, then you are simulating a universe where you have prior knowledge of the 'future', and then you can, within the context of your simulation, have a "non-causal" filter.

But if you're going to apply a real filter to real-time data you can no more use a non-causal filter than you can travel faster than light*.

my question is if i do filtering process in frequency domain, ideal filter (that is not delayed for making fir filter to be causal) can be used?

In the real universe, we live in the time domain. Yes, you can take pre-recorded data, you can take it's FFT, multiply by a filter's frequency response, and then take its IFFT.

But that is not operating on data in real-time. It's operating on recorded data. And because you have recorded the data, you have, indeed, added delay.

i can't understand why i have to do this pure delay to make causal filter.

See the definition of causal filters, above. It is absolutely fundamental, by definition that a filter which responds to an input before the input happens is non-causal.

If you keep this definition in mind, then the need to add delay to make a filter causal should be obvious.

what is the problem when i do filtering signal with frequency response of Non-causal fir filter?? i think that is just multiply process

It is "just" a multiplication in the frequency domain after you record enough data that you can perform an FFT on it. Recording that data takes time, "takes time" is synonymous with "adding delay" -- so when you 'just' multiply in the frequency domain, you must first add delay in the real world.

* Apparently this is actually a result in General Relativity. I still haven't wrapped my brain around it, but -- OK, I understand the presentations when the charts are still on the screen, and I'm not a general relativist, so I'll just take that as a given.

$\endgroup$
3
  • $\begingroup$ With all due respect I am not quite buying the IDTFT explanation (yet): Wouldn't the Inverse DTFT produce the same non-causal result? I believe the core reason is the original frequency response used was real. If we use the inverse of the DTFT we are just using a continuous frequency response instead of a discrete one, and the resulting sampled time domain extends to +/- infinity (and would be non-causal centered on t=0). Practicality dictates we would use an IFFT and then shift the second half to the beginning half rather than inserting the necessary phase delay (same outcome). $\endgroup$ Jan 26, 2022 at 6:31
  • 1
    $\begingroup$ IDTFT vs IFFT is a sideshow. The core question is "can I make it all causal, without adding delay, by doing it in the frequency domain?", and the answer (which I give) is "not in the real world" because to do it in the "frequency domain" (using overlap-and-add with FFTs and IFFTs, right here in the time domain) necessarily adds delay. $\endgroup$
    – TimWescott
    Jan 26, 2022 at 19:12
  • $\begingroup$ I see now-- I reread the question and see your point: the core question is why we can't make zero-phase filters in the real world and why do we need to deal with that annoying delay when we can just multiply in frequency. I didn't get that from the question on my first pass, I thought the concern was with actual implementation and the resulting circularly shifted coefficients. $\endgroup$ Jan 26, 2022 at 21:27
1
$\begingroup$

i think that is just multiply process

Multiplying in the frequency domain implements circular convolution, not linear convolution. That's why you need to use algorithms like overlap-add or overlap-save for frequency domain filtering.

Frequency domain processing also isn't a great fit for most active noise cancellation problems since the latency is too large. In order to do an FFT of length $N$ you need to wait until you have accumulated $N$ samples. Typically the latency for an FFT based system is $2N$ samples.

If you only care about the magnitude of the transfer function, you can minimize the delay (and keep things causal) by using a minimum-phase instead of a zero phase.

$\endgroup$
1
  • $\begingroup$ just to be clear may be good to add "in the discrete time domain" to your first sentence since that statement as it stands isn't generally true, right? $\endgroup$ Jan 25, 2022 at 4:59
1
$\begingroup$

Update: I realize now the OP is asking why we have to have any of that "annoying" delay in filter implementations given we can just multiply by a zero-phase filter in frequency. Tim answered that question while below with my prior answer, I provide the details as to why the OP's left plot is non-causal (and requires fftshift to correct), as well as reasons why simply multiplying FFT bins in the frequency domain is not a good filtering approach unless we are only interested in the FFT bins (such as OFDM).

Prior answer:


If the user means filtering by "multiplying in the frequency domain" the process of filtering by changing the DFT bins directly, then this is the "Frequency Sampling Method" of filter design which for most applications is an inferior method of performing filtering. It is inferior for all cases where we are interested in the frequency response over a continuous frequency range, and not just the frequencies at the exact bin centers of the FFT.

This is similar to the reason it is not recommended to just null frequency bins if we want to eliminate specific frequencies versus other notch filtering techniques (see @hotpaw2's famous answer here; and as I demonstrated with general filter design approaches here: the result will be more ripple in the passband and stopband for the continuous frequency response of the filter (the DTFT), than we can get with other design approaches. This means for a given requirement we may need a lot more samples (filter coefficients) to meet those requirements.

That said, the OP has designed a filter here in this example using the Frequency Sampling Method, and the results would be identical: multiply directly in frequency the FFT of a signal by the sampled frequency response that resulted in the impulse response shown (circularly time shifted IFFT), which would require block processing and overlap-add or overlap-save for streaming results as Hilmar detailed, OR as an FIR filter using the circularly time shifted IFFT values and can then stream sample by sample.

The fundamental reason the OP has achieved a non-causal result is because the original target response in frequency had zero phase; which can't be physically implemented with an FIR filter. The FIR filter that can be implemented will have a linear phase component in frequency with a negative phase slope versus frequency that is proportional to its delay (0 to $2\pi$ radians from DC to the sampling rate for every unit sample delay). If the OP had started with a target response for both magnitude AND phase, with sufficient delay that is implementable, then the IFFT result on the right will be realized directly. However it is easiest to just know that but proceed with a zero phase solution in frequency when we are only concerned with magnitude and want a linear phase (fixed delay) and do the simple correction in time (Using 'ifftshift' in MATLAB, Octave and Python scipy.signal).

Note too how we can implement "zero-phase" filters with post-processing (such as 'filtfilt' in the tools), which is similar to the multiply in frequency approach in that we can't actually multiply until after we receive a whole block of data - either way there will be delay!

$\endgroup$
0
$\begingroup$

I'm sorry to ask the question in this form as I can't comment under your answer. @Dan Boschen After reading the above answer, I understand that the reason for the left picture is that the frequency domain multiplication of the recorded data leads to the appearance of delay. But after reading your explanation about non-causal emergence, I have a question about "The fundamental reason the OP has achieved a non-causal result is because the original target response in frequency had zero phase".If the frequency response is not zero-phase, the same result as the left figure will appear when doing IFFT, why? In other words, doesn't the original target response refer to the frequency response of the filter?

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.