# Amplitude of discrete Fourier transform of Gaussian is incorrect

I am trying to understand why the amplitude of the FFT (computed with numpy) of a Gaussian differs from its analytic solution.

The $\mathcal{F}\{e^{-\pi t^2}\} = e^{-\pi f^2}$. However if I calculate it with the FFT function in numpy the resulting Gaussian's amplitude is not 1?

I have already done the following:

• I do divide the fft result by the number of samples (normalize).
• I have even tried shifting the Gaussian so that its first sample is its height. This corrects the sinusoidal behaviour, and removes the maginary part, but does not improve the amplitude result (same as absolute value of unshifted case). I will however be taking the absolute value in any case.

Here is the code:

def test_gauss_1D(self,a,f_c,delta_f):
delta_t = 1.0/(2.0*f_c)
N = int(np.ceil(1/(delta_f*delta_t)))+1
if (N % 2) == 0:
N = N + 1

t = np.linspace(-(N-1)/2*delta_t,(N-1)/2*delta_t,N)
f = np.linspace(-1/(2*delta_t),1/(2*delta_t),N)

x_t = np.exp(-np.pi*t**2)

#x_t = np.roll(x_t,-1*(N-1)/2)

#x_t = 1/(np.sqrt(2*np.pi)*a)*np.exp(-t**2/(2*a**2))

#print "std = ", 1/(4*a**2*np.pi**2)
#print "ampl =", np.sqrt(2*np.pi)*a

plt.plot(t,x_t)
plt.show()

#x_f = np.fft.fft(x_t)/N
#print "N = ",N
x_f = np.fft.fft(x_t)/N

x_f = np.roll(x_f,1*(N-1)/2)

plt.plot(f,np.absolute(f))
plt.show()


Here are the images: As you can see the amplitude is incorrect in the second image (should be one).

Why is this?

• Is there a missing factor of $1/2\pi$? – Bill Barth Mar 31 '14 at 12:56
• No the missing factor is $10\frac{1}{12}$. – trienko Mar 31 '14 at 13:07

## 2 Answers

The normalization needs to include the sampling frequency. Multiple your x_f by delta_t and you should be all set.

• This seems to be correct answer. It works, but I don't understand why. – Jason Jun 11 '19 at 8:46
• I found some explanation on this sampling period variable: dsp.stackexchange.com/a/31986/43658. – Jason Jun 12 '19 at 2:28

I think you have used an incorrect normalisation: the factor of 1/N is the result of applying both the transform and the inverse transform. For just the forward normalisation you therefore want 1/(sqrt(N)). When I run your code with this normalisation, I see a peak of sqrt(2), so the correct normalisation is therefore 1/(sqrt(2*N)).

I suspect that the final factor of two comes from the exact definition of N, and whether or not positive and negative frequencies should count twice. In any case, I can't seem to find it on the numpy documentation page: http://docs.scipy.org/doc/numpy/reference/routines.fft.html
{"ft_lang_label":"__label__en","ft_lang_prob":0.80572087,"math_prob":0.9881479,"size":1379,"snap":"2021-04-2021-17","text_gpt3_token_len":450,"char_repetition_ratio":0.11054546,"word_repetition_ratio":0.0,"special_character_ratio":0.35460478,"punctuation_ratio":0.1626506,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9998642,"pos_list":[0,1,2,3,4],"im_url_duplicate_count":[null,2,null,2,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-04-17T15:16:41Z\",\"WARC-Record-ID\":\"<urn:uuid:a4a82e2a-9a3d-4425-97ac-548e744fd69b>\",\"Content-Length\":\"172855\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:d5e40ab7-7927-4c97-ae1d-0f0bea46b2cf>\",\"WARC-Concurrent-To\":\"<urn:uuid:7f36afe2-b90c-45c6-9591-872f06fd5e5e>\",\"WARC-IP-Address\":\"151.101.129.69\",\"WARC-Target-URI\":\"https://scicomp.stackexchange.com/questions/11233/amplitude-of-discrete-fourier-transform-of-gaussian-is-incorrect/11236\",\"WARC-Payload-Digest\":\"sha1:KG223DUFK5RIKHVRKTBRDS7PEIRQYPRC\",\"WARC-Block-Digest\":\"sha1:6MYALOTPOPDRD5WLENNMC5EYVDRF3HVQ\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-17/CC-MAIN-2021-17_segments_1618038460648.48_warc_CC-MAIN-20210417132441-20210417162441-00304.warc.gz\"}"}