When calculating the FT of a signal, and the FT of that same signal but after having applied zero-padding to it, should't the amplitudes of the FT of the zero-padded signal decrease with respect to the FT amplitudes of the original signal?

1) Since the FT of the zero-padded signal has more frequency bins (since we have interpolated the spectrum), my intuition tells me that the amplitude of the frequency bins of this FT should be lower.

However, when I calculate the FT of the two signals (I use the fft function available in Scipy for Python), I get the same amplitudes for their spectra. I was not expecting this behaviour.

2) If I add the normalization term when calculating the FT (Scipy FFT does not include this), i.e. $$FT = fft(signal) / length(signal)$$, then I get different amplitudes for the two FT, which again, was not what I was expecting. Specifically, the zero-padded signal FT amplitudes decrease with respect to the non zero-padded, and the more zero-padding I add, the more the amplitudes of the FT decrease.

I am a bit confused with whether these results are supossed to be like that, or if I have done something wrong in my calculations.

All of what you’ve said makes sense and is expected. Zero padding shouldn’t be changing the amplitudes, you can check out the formula for the DFT to see why. When adding the divide-by-$$N$$, then the more zero padding is effectively increasing $$N$$ so it makes sense that you see the amplitudes grow smaller.

Edit: After reading your comment I thought I'd add this. You need to be careful what you are dividing by. For example, if you have a signal of length $$N_s$$ and take a $$N$$-point DFT you will be returned a vector of length $$N$$, not $$N_s$$. So if you zero pad and are returned a length $$N$$ vector and just divide everything by $$N$$ then of course the more you zero pad the more the magnitudes will decrease since more zero padding means larger $$N$$.

What you probably want to be doing to make everything consistent is to be dividing by the original signal length $$N_s$$ before zero padding. Here is some MATLAB code (I think MATLAB and Python implementations are identical for fft function) that demonstrates how zero padding and normalization works and you can see the consistent magnitudes in the plots.

%% Demo script for zero padding and fft
clear,clc,close all;

%% Generate some signal
F = 30;             % frequency of signal [Hz]
Fs = 4*F;           % sampling rate, twice Nyquist [Hz]
Ts = 1/Fs;          % sampling period [sec]
t = 0:Ts:20/F;       % generate 20 cycles
x = cos(2*pi*F*t);  % signal
N = length(x);      % length of signal

Nfft = length(x);   % taking a Nfft-point DFT
f = -Fs/2:Fs/Nfft:Fs/2-1/Nfft;
X = fft(x,Nfft);    % evaluate using FFT function

subplot(3,1,1)
plot(f,abs(X)/N)
xlabel('Frequency [Hz]')
ylabel('Magnitude')
grid on

Nfft0 = 256;
f0 = -Fs/2:Fs/Nfft0:Fs/2-1/Nfft0;
X0 = fft(x,Nfft0);

subplot(3,1,2)
plot(f0,abs(X0)/N)
xlabel('Frequency [Hz]')
ylabel('Magnitude')
grid on

%% With even more zero padding
Nfft00 = 512;
f00 = -Fs/2:Fs/Nfft00:Fs/2-1/Nfft00;
X00 = fft(x,Nfft00);

subplot(3,1,3)
plot(f00,abs(X00)/N)
xlabel('Frequency [Hz]')
ylabel('Magnitude')
grid on

• Could you expand a little bit on this? – sdiabr Jan 9 at 15:29
• This normalization issue is covered in the Python documentation for the fft function here: docs.scipy.org/doc/numpy-1.15.0/reference/routines.fft.html. It just comes down to how the DFT is defined; in the DFT there is typically not a $\frac{1}{N}$ term and in the inverse DFT there is. – BryanEhlers Jan 9 at 15:44

What scipy.fftpack.fft effectively does is (docs):

y(j) = (x * exp(-2*pi*sqrt(-1)*j*np.arange(n)/n)).sum().


This has no built-in normalization. If you do fft and then ifft, you need to normalize by multiplication by $$1/n$$ to get back your original data.

Or, you can do:

• step 1: fft, then normalize by $$1/\sqrt{n},$$ then
• step 2: ifft, then normalize by $$1/\sqrt{n}.$$

This gives the same final result because $$1/\sqrt{n}\times1/\sqrt{n} = 1/n,$$ and agrees with your intuition: The sum of squares of absolute values before and after each step remains equal. The steps compute the unitary discrete Fourier (DFT) and inverse discrete Fourier transforms (IDFT). With larger $$n$$ the same amount of "energy" as before will be distributed to more frequency bins so each value must be on average smaller in magnitude.

• So you do agree with that a zero-padded signal spectrum should present lower amplitude values than the non zero-padded signal spectrum? Sorry I did not fully understand your answer. – sdiabr Jan 9 at 15:27
• It depends on the normalization used. For the unitary DFT, yes. fft` without normalization, no. – Olli Niemitalo Jan 9 at 15:33