0
$\begingroup$

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.

$\endgroup$
4
  • $\begingroup$ Calling a function $f(x)$ is a horrible habit. No sane software developer would confuse function $f$ and output $f(x)$ but textbooks on differential calculus do it all the time. So much for the "exact sciences". $\endgroup$ Commented May 17, 2022 at 21:20
  • $\begingroup$ Again, try to break into sections. Ideally, the question would be at the top. Then the motivation for such question and your thoughts and work. In an ideal world, a reader would be able to determine in 5-10 seconds whether he or she is qualified to answer. The way this question is structured makes such quick assessment impossible. The fact that no one has yet bothered to vote does support that. Since you are not paying for answers, salesmanship does matter. $\endgroup$ Commented May 18, 2022 at 11:51
  • $\begingroup$ Are you asking for $\int\limits_{-1}^1 dx e^{ikx} e^{-ax^2}$? If so, you should look at the error function $\endgroup$
    – Sal
    Commented May 18, 2022 at 12:26
  • $\begingroup$ Do you agree with my latest edits? $\endgroup$ Commented May 18, 2022 at 20:12

1 Answer 1

0
$\begingroup$

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.

$\endgroup$
1
  • $\begingroup$ i had not asked my question properly, i have made major edits to rectify this issue now. $\endgroup$
    – user_1_1_1
    Commented May 18, 2022 at 12:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .