How to compute the Fourier transform of a zero-centered Gaussian pulse over a specified range, say $[0,1]$?

165 Views Asked by At

Given an even Gaussian kernel $f : \Bbb R \to \Bbb R^+$

$$f(x) = \exp \left(- \frac{1}{2\sigma^2} x^2 \right)$$

and a probability density function (or, if you discretize $[0,1]$, then a probability mass function) $g : [0,1] \to \Bbb R_0^+$, how can I compute the Fourier transform of the Gaussian $f$ over the real range $[0,1]$ only?


Basically, after obtaining this Fourier transform, I will take its product with the FFT of $g(x)$ as I am trying to compute the convolution of $f$ and $g$.

$$ h(t) = (f*g)(t) = \int_{-\infty}^\infty f(\tau)g(t-\tau)d\tau $$

$$ h(x) = \{g*f\}(x) = \mathcal{F}^{-1} \left\{ G\cdot F \right\} $$

That is why I need the DFT of $f$ to be of the same length as that of DFT of $g$. For more on the motivation to ask this question, refer to the end.

So I want to compute this Fourier transform of $f(x)$ by calling the fft function on a discretized version of $f$. The reference I am looking at says that to do this, compute function fd as shown below. The kernel considered here is symmetric like a bell curve centered at $0$ that dies away by the time you reach $+5$ or $-5$, and I guess that is why they are doing -5:1:5 but I am not sure, any help to understand that will also be helpful. And x is just the vector obtained when we discretize $[0,1]$ with the step size, say $\delta=0.01$.

fd = zeros( size(x) );
for shift = -5:1:5
    fd = fd + f(x+shift);
end

And then we simply call fft on fd as if fd is the discretized version of the windowing kernel. But I am confused based on what theory is fd the discretized version of the kernel? According to me, we should only have used one line of code below. I know that is wrong but why?

fd = f(x)

Motivation

The exact lines of code that this question is trying to understand are lines 195-197 here and what theory explains it.

1

There are 1 best solutions below

1
On

You write:

$$h(x) := \int dy\ g(y) f(y-x)$$

That is not a convolution, but a correlation. A convolution

$$ (f*g)(t) = \int_{-\infty}^\infty f(\tau)g(t-\tau)d\tau$$

Notice the negative sign of $\tau$ for one of the functions !

Furthermore the convolution identity you cite:

$$h(x) = \{g*f\}(x) = \mathcal{F}^{-1} \left\{ G\cdot F \right\}$$

only holds for circular convolution and not for other types of convolution.

For example if you do a normal linear convolution with zero padding or mirroring or border extension at the edges, the results will not match the inverse Fourier transform of the product of the Fourier transforms of the functions.

Now, all this being said, you can derive that the Fourier Transform of a Gaussian function is another Gaussian function. I think the standard variation is the reciprocal.