# Why signal add noise cause signal undiscoverable after fft and ifft？

As we all know, Fourier transform of the sinc(t) is rect(f).
Simple python script to discover signal after fft and ifft with random normal noise.

import matplotlib.pyplot as plt
import numpy as np
np.random.seed(1234)

peak=np.fft.fft(np.sinc(np.linspace(-4, 4, 200)))
peak_ifft=np.fft.ifft(peak)
n=200
noise=np.random.normal(loc=0, scale=np.sqrt(2)/2, size=(n, 2)).view(np.complex128)
signal=noise+np.reshape(np.asarray(peak),(-1,1))
plt.figure()
plt.subplot(2,2,1)
plt.plot(np.abs(signal))
plt.title('power vs freq')
plt.subplot(2,2,2)
signal_ifft=np.fft.ifft(signal)
plt.plot(signal_ifft)
plt.title('should appear sinc,but not')
plt.subplot(2,2,3)
plt.plot(peak_ifft)
plt.title('should be sinc,and yes')
plt.show()


Output as below:

As x(t)+y(t)<->X(f)+Y(f),np.fft.ifft(np.fft(signal)) go back to origin signal,why cannot np.fft.ifft(np.fft(signal+noise))?

• you don't add, you concatenate, completely different operations. Commented Mar 8, 2022 at 16:10
• Can you please confirm that you want to use np.concatenate, and that you have indeed read and understood it's documentation? Commented Mar 8, 2022 at 16:28

You want to just do signal + noise, and you'll be fine for the noise part.

For the plot, you need the absolute of the fft, you're just plotting the real part.

import matplotlib.pyplot as plt
import numpy as np
np.random.seed(1234)
# make data
x = np.linspace(-4, 4, 200)
y = np.sinc(x)
# make fft and ifft
peak = np.fft.fft(y)
peak_ifft = np.fft.ifft(peak)
# make the frequency domain
freq = np.fft.fftfreq(len(x), np.diff(x).mean())
# make some noise!!!
n = 200
noise = np.random.normal(loc=0, scale=0.1, size=n)
# signal with noise, and the fft and ifft
signal = y + noise
peak2 = np.fft.fft(signal)
peak_ifft2 = np.fft.ifft(peak2)
# plotting
plt.figure()
plt.plot(x, y)
plt.plot(x, peak_ifft, ':')
plt.figure()
plt.plot(freq, np.abs(peak))
plt.xlim([-5,5])
plt.figure()
plt.plot(x, signal)
plt.plot(x, peak_ifft2, ':')
plt.figure()
plt.plot(freq, np.abs(peak2))
plt.xlim([-5.,5])


• when you use add,get the similar output Commented Mar 8, 2022 at 18:11
• I've refined my answer to be more explanatory and to have a full example. Does that help? Commented Mar 8, 2022 at 18:11
• Really thanks for your clear answer. Commented Mar 8, 2022 at 19:02