2
$\begingroup$

From wikipedia:

The discrete Fourier transform (DFT) converts a finite sequence of equally-spaced samples of a function into a same-length sequence of equally-spaced samples of the discrete-time Fourier transform (DTFT)

also from wikipedia (DTFT):

It produces a function of frequency that is a periodic summation of the continuous Fourier transform of the original continuous function

To my understanding (and I'm probably wrong here) this should mean that sampling a function in the time domain and applying DFT (FFT to be precise) should be equivalent to applying FT and sampling in the frequency domain, however I have not been able to reproduce this.

Here's an example:

$$ f(x) = \exp(- \pi x^2)\\ \mathcal{F}[f(x)](\zeta) = \int_{-\infty}^{\infty} \exp(- \pi x^2) \exp(- 2\pi ix \zeta) dx = \exp(- \pi \zeta^2) $$

so using python:

import numpy as np
from numpy.fft import fftshift, fftfreq, fft

size  = 201
upper = 8 * np.pi
lower = 0

time_domain = np.linspace(lower, upper, size)
function    = np.exp(-np.pi * time_domain**2)

freq_domain = fftshift(fftfreq(size, d=(upper-lower)/size))
analytical  = np.exp(-np.pi * freq_domain**2)
numerical   = fftshift(fft(function))

I get this result:

Original results

by plotting the amplitude of the numerical result against the analytical. I'm not really concerned about a difference in scale, but even after normalizing both curves I get this:

Results after normalization

I'd like to understand the conceptual issue here.

EDIT:

I think the FFT code part is right, at least with the function

$$f(x) = sin(2 \pi x) + sin(8 \pi x)$$

I get peaks in $1$ and $4$

enter image description here

also if it is not equivalent, is there a way to better approximate the analytical version using the DFT?

$\endgroup$
  • $\begingroup$ It's not true that sampling in the time domain then applying the DFT is equivalent to applying the Fourier transform then sampling in the frequency domain. I think the DFT formula can be viewed as a Riemann sum approximation to the integral that appears in the definition of the Fourier transform. $\endgroup$ – littleO May 9 at 16:37
  • $\begingroup$ (I only use the continuous FT) the gaussian isn't band-limited or periodic so you shouldn't expect equality but it does seem too far off. Have you used the FFT correctly- have you checked that things make sense when the signal is an exact sum of sines? $\endgroup$ – Calvin Khor May 9 at 17:06
  • $\begingroup$ Edited the post with further details. $\endgroup$ – vlizana May 9 at 18:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.