How the noise in time domain affect the power in frequency domain after FFT? - Signal Processing Stack Exchange most recent 30 from dsp.stackexchange.com 2019-11-19T07:25:08Z https://dsp.stackexchange.com/feeds/question/46049 https://creativecommons.org/licenses/by-sa/4.0/rdf https://dsp.stackexchange.com/q/46049 0 How the noise in time domain affect the power in frequency domain after FFT? canon https://dsp.stackexchange.com/users/32918 2017-12-28T07:28:27Z 2017-12-28T12:07:45Z <p>I am new to signal processing. And I am puzzled when studying FFT. I create time series plus a random noise in Python:</p> <p><code> import numpy as np N=1000 x = np.linspace(-50,50,N) noise = np.random.random(N)*0.1 y = np.sin(2*np.pi*x/10) + noise </code></p> <p>Then perform FFT to the time series and get power spectrum. But I find the spectrum is totally different when I execute my script each time. I know it must be the random noise's effect, which are different in different execution. However, as you can see, the sine function is periodic, so we should see clearly a signal in the power spectrum. The puzzle is, the very strong periodic "signal" is submerged in the noise in frequency domain FOR SOMETIME.</p> <p>I want to know how the noise in time domain affect the noise&amp;signal in frequency domain.</p> <p>Many thanks!</p> https://dsp.stackexchange.com/questions/46049/-/46054#46054 2 Answer by Fat32 for How the noise in time domain affect the power in frequency domain after FFT? Fat32 https://dsp.stackexchange.com/users/13309 2017-12-28T11:54:19Z 2017-12-28T12:07:45Z <p>You have problems in defining the noise and sampling frequency. Your noise is not zero mean and your sampling rate is not well defined. Following simple Python code computes the DFT magnitude of the sine plus noise example. (Note: I'm not a python user so please modify the code as necessary)</p> <pre><code># -*- coding: utf-8 -*- import numpy as np import matplotlib.pyplot as plt from scipy.fftpack import fft import numpy.random as npr N = 1000 # Set signal sample length t1 = -5; # Simulation begins at t1 t2 = 5; # Simulation ends at t2 x = np.linspace(t1,t2,N);# Define the sampling grid as x[n] Ts = (t2-t1)/N; # Compute resulting sampling period Fs = 1/Ts; # Compute resulting sampling rate noise = (npr.random(N)-0.5); # Generate ZERO MEAN uniform noise fsin = 0.2*Fs; # Sine Wave Frequency in [0:Fs/2] y = np.sin(2*np.pi*fsin*x) + noise # Generate SINE + Noise # Take FFT and display its MAGNITUDE w = np.linspace(0,2,N) waves = fft(y,N) plt.plot(w,abs(waves)) </code></pre> <p>Where the resulting plot is:</p> <p><a href="https://i.stack.imgur.com/W2bP8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/W2bP8.png" alt="enter image description here"></a></p>