# Why a DFT of 2 senes is very noisy even with frequence sampling 5 times bigger?

I've set up this case to try to understand DFT implementing a real case in Excel

Frame Size $$\;\color{blue}{(T}$$): 5 s
Time Sampling $$\;\color{blue}{(TS}$$): 0,1 s
Block Size $$\;\color{blue}{(N = TT/TS+1)}$$: 51
Sampling Rate $$\;\color{blue}{(FS = TT/TS+1)}$$: 10 Hz
Frequency Resolution $$\;\color{blue}{(FR = FS/(N-1))}$$: 0.2 Hz

In time spectrum I have put just 2 sines functions added

The firt sine has amplitude $$\color{blue}{10}$$, phase $$\color{blue}{\pi/3}$$ and frequency $$\color{blue}{2}$$ Hz. The second sine has amplitude $$\color{blue}{5}$$, phase $$\color{blue}{0}$$ and frequency $$\color{blue}{1}$$ Hz: $$\color{blue}{\quad ( n = 0\; to \;50)}$$

$$\color{blue}{X[n] = 10\, \sin{(2\pi t 2 + \pi/3)}+ 5\, \sin{(2\pi t 1)}}$$

So I have generated DFT values where $$\color{blue}{\; k=0\; to\; 50\quad }$$ and $$\color{blue}{\quad x_k=a_k + ib_k}\;$$:

$$\color{blue}{a_k = (1/N) \; \Sigma_{n=0,N-1} X_n \cos{(2 \pi n k /N)}}$$ $$\color{blue}{b_k = (1/N) \; \Sigma_{n=0,N-1} X_n \sin{(2 \pi n k /N)}}$$

After, I've calculated module $$\color{blue}{A}$$ and phase $$\color{blue}{\Phi}$$ for $$\color{blue}{\; ( n = 0\; to \;50)}$$

$$\color{blue}{A_k = \sqrt{(a_k)^2 + (b_k)^2}}$$ $$\color{blue}{\Phi_k = atan2(b_k, a_k)}$$

I consider in my analysis $$\color{blue}{ Freq_k = k.FS/(N-1)}$$

Now my doubt arise. In my understanding, the signal should be concentrated in the values of frequencies $$\color{blue}{1}$$ Hz and $$\color{blue}{2}$$ Hz. It is not. Not even remotely. Amplitude $$\color{blue}{A_k}$$ for $$\color{blue}{8.2}$$ and $$\color{blue}{9.2}$$ Hz are very strong. In short, the frequency spectrum is very noise. Also $$\color{blue}{2.2}$$ Hz and $$\color{blue}{8}$$ hz amplitudes are almost half of $$\color{blue}{1}$$ Hz amplitude.

I'm working with frequence sampling $$\color{blue}{10}$$ Hz, five times than maximum detected frequency ($$\color{blue}{2}$$ Hz).

What's happening?

To check if I had made a mistake, I calculated the DTF inverse and the original signal was restored exactly!

• It is not clear that there is a problem. You will always get extra peaks at the high end of the spectrum, in particular $A_{N-k} = A_k$, due to aliasing. You can interpret those peaks as existing at $A_{-k}$ instead. Also, since the period of your signal is exactly 50 samples, you should drop the 51st one, and then the spectrum ought to be what you expect. – Rahul Oct 6 '18 at 21:28
• Not exactly, my total period is 5 s, 51 samples, 0.1 s between samples. When I take out the last data, the inverse DFT not match anymore. I've made a complete IDFT and all real part match with original sign and all complex part is 0. – Paulo Buchsbaum Oct 6 '18 at 22:04
• I'm studying the aliasing. I'm new in DFT so it's hard for me. – Paulo Buchsbaum Oct 6 '18 at 22:05
• Now I'm using k from -25 to 25, 51 samples. It improves a lot! The bigger values are -2Hz, -1Hz, 1Hz and 2Hz, but 2,2 Hz amplitude is around 25% of 2 Hz amplitude. Is it normal? – Paulo Buchsbaum Oct 6 '18 at 22:13