1
$\begingroup$

I have a question about using the Dirichlet kernel as a filter. Let us suppose that I have samples of a continuous function sampled with frequency $F_s=10 \,\texttt{Hz}$. The function is band-limited and the sampling frequency is well above the Nyquist frequency, but there is noise added to the data. I need a lowpass filter to remove all the high frequency components introduced by the noise above a certain frequency $B$.

My understanding is that $\text{sinc}(2Bt)$ would represent the ideal lowpass filter because computing its Fourier transform (FT) gives a rectangular frequency response of single-sided width $B$. However, this filter has an infinite duration in time and we need to truncate it. The abrupt truncation with a rectangular window causes unwanted Gibbs oscillations in the frequency domain and, consequently, we smooth the $\text{sinc}$ with an appropriate window instead to mitigate this problem.

However, because we implement all our calculations on machines, continuous functions are sampled and FT become Discrete Fourier transforms (DFT). Then, why don't we just use the Dirichlet kernel as the lowpass filter? Let's say that my filter has $N$ coefficients, with $N$ odd. The DFT will have spacing ${\Delta}f=F_s/N$. If I take $N_B$ as the nearest integer to $B/{\Delta}f$, then the Dirichlet kernel $D_n=\sin[{\pi}(2N_B+1)n/N]/\sin({\pi}n/N)$ will have a rectangular DFT with single-sided bandwidth given by $N_B{\Delta}f$. Of course, if I have $M$ samples of the input function, the output will have $M-(N-1)$ samples. It seems to me that $D_n$ is the ideal filter that we need. Am I wrong about this?

I know that $D_n$ tends to $\text{sinc}(2Bt)$ as $N$ goes to $\infty$. So I guess an issue related to my question is, for what value of $N$ is the discrete approximation to the continuous case good enough that we don't have to worry about it anymore? On the other hand, when we are limited to relatively small values of $N$ (for instance, if we don't want to exacerbate the data loss $M-(N-1)$), should we just do things as if everything were discrete or should we carry over results from the continuous case (like filtering with $\text{sinc}$ for example)?

Thank you in advance for your answers!

$\endgroup$
4
  • $\begingroup$ The Dirichlet kernel seems to me is an issue of bandlimited interpolation between bins of a periodic and uniformly-sampled data. And I don't know why, but the texts don't deal with the issue of whether $N$ is even or if $N$ is odd, and there is a subtle difference. $\endgroup$ Commented May 16 at 21:33
  • $\begingroup$ Here's an interesting article that I haven't read yet. I am looking for an IEEE article that came to the same conclusion that Cedron and I had. Still looking.... $\endgroup$ Commented May 16 at 21:36
  • $\begingroup$ I think it's this: Schanze, “Sinc interpolation of discrete periodic signals”. I thought I had a copy of it, but I cannot find it. I am not IEEE and will not pay $33 for a copy. [JOS makes a reference to it in his resampling page](ccrma.stanford.edu/~jos/resample/…) but I think that my and Cedron's expressions (slightly different for even vs. odd $N$) is better. $\endgroup$ Commented May 16 at 21:50
  • $\begingroup$ I took a look at those articles... they are quite interesting and very helpful. Thank you! $\endgroup$
    – Simone
    Commented May 17 at 3:00

1 Answer 1

2
$\begingroup$

The Dirichlet Kernel is a "Time Aliased Sinc Function", and using it as the coefficients for the low pass filter avoids truncation issues we would see as the OP describes correctly with the truncated Sinc function, but leads to greater distortion in the frequency domain for the frequency response corresponding to all frequencies that are in between the samples given by the DFT (The frequency response is the DTFT of the time domain samples, as even though we are sampled in time, we can have samples of any frequency on the continuous frequency domain). The Dirichlet Kernel would result in the exact frequency values sampled for a rectangular low pass (such as 1,1,1,0,0,0,0 .....0, 0, 1,1] in the frequency domain, but the continuous frequency response would have much more ripple (error) at all the frequencies in between those "bin centers" than what we would get with using samples of the truncated Sinc function as the filter.

Below shows the two functions; the truncated Sinc labeled "IFT", and the Dirichlet Kernel labeled "IDFT"

Sinc vs Dirichlet Kernel

The Sinc in orange has it's distortion due to being truncated from the ideal Sinc that extends to $\pm \infty$, while the Dirichlet Kernel has it's distortion as deviating from the ideal Sinc, which can be shown to be mathematically equivalent to aliasing from the tails of the Sinc that extend beyond the boundary shown (hence the elevated values). This distortion appears as an error in the frequency response.

I detail the difference between the two approaches in DSP #31905, with some bottom-line plots from that post copied below.

Below is the comparative frequency response for a 99-Tap FIR using coefficients of the Dirichlet Kernel (and labeled "Frequency Sampling") in Blue, compared to coefficients of a truncated Sinc (and labeled "Window" as it has been windowed with a rectangular window) in red. In the scale of the first plot we primarily see the difference in the stop-band, in that it has greater error which is attributed to the time domain aliasing of an ideal Sinc response in the time domain.

stop band

Below is a zoom in of the passband, again showing the greater error that results.

pass band

The lesson from above is that both the truncated Sinc and the Dirichlet Kernel are non-ideal (neither is a brick-wall response), with the deviation due to either truncation error for the rectangular windowed Sinc, or time-domain aliasing for the Dirichlet Kernel. But importantly, the truncated Sinc out-performs the Dirichlet Kernel. We can continue to improve the truncated Sinc with higher performing windows, or we can continue to improve the Dirichlet Kernel by oversampling first in the frequency domain to reduce the time domain aliasing (effectively push the time duration out further), and then windowing that result. Oversampling the frequency domain to reduce aliasing for a rectangular frequency response just makes the Dirichlet Kernel approach the ideal Sinc!

$\endgroup$
6
  • $\begingroup$ Hi Dan, thank you for your answer! I accepted your answer since it addresses my main question. However, I am still puzzled by the fact that we use DFTs to compute frequency responses of filters with which we filter sampled continuous functions. It sounds a little bit like a circular argument to me. Am I worrying about nothing? Is there a minimum value of $N$, or a combination of minimum values of $N$ and $F_s$, for which the continuous case is approximated well enough? $\endgroup$
    – Simone
    Commented May 16 at 21:39
  • $\begingroup$ The FFT will give samples on the frequency response, and specifically we zero pad the FFT to get closer to that continuous frequency response which is the result of a DTFT (zero padding a time sequence and then computing the DFT gives more samples on the DFT. The minimum number for N depends on how long the true impulse response to get a particular frequency response takes to decay combined with having the sampling rate for that time duration consistent with Nyquist (so you are balancing both aliasing in time as well as aliasing in frequency) $\endgroup$ Commented May 17 at 9:45
  • $\begingroup$ So we can always reach the exact value in frequency for any number of samples that we pick, and it will be exact - at those frequencies only! The less samples the more error we would have for the remaining frequency response between those samples (unless we chose that one resulting solution for that frequency response, which we can see by zero padding the samples in time) $\endgroup$ Commented May 17 at 9:59
  • $\begingroup$ A helpful answer Dan (+1)! You show that the Dirichlet kernel performs worse in the frequency domain (which of course manifests in the time domain one way or another), but I wonder if there are any advantages to using the Dirichlet kernel in other respects? For example, I've heard it produces better results than a windowed sinc near the edges of a signal when used for interpolation. Is that true? $\endgroup$
    – Gillespie
    Commented May 17 at 16:25
  • 1
    $\begingroup$ Posted here @DanBoschen: dsp.stackexchange.com/q/93984/55647 $\endgroup$
    – Gillespie
    Commented May 18 at 18:27

Your Answer

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

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