Amplitude cutoff following FFT suppose I have a noisy sine wave (as R code):

# Sampling frequency
fs &lt;- 1000
# Sampling period
ts &lt;- 1/fs
# Length of signal
l &lt;- 1500
# Time vector
t &lt;- seq(0, l - 1)*ts
# Signal
s &lt;- 0.4*sin(2*pi*50*t) + sin(2*pi*120*t)
# Noise
x &lt;- s + 2*rnorm(length(t))
# Plot signal
qplot(t, x) + geom_line()


and want to determine the amplitudes of the signal with:

# FFT
y &lt;- fft(x)
# Two-sided spectrum
p2 &lt;- abs(y/l)
# Convert to one-sided spectrum
p1 &lt;- p2[1:(l/2 + 1)]
p1[2:(length(p1) - 1)] &lt;- 2*p1[2:(length(p1) - 1)]
# Define frequency
f &lt;- fs*seq(0, l/2)/l
# Plot spectrum
qplot(f, p1) + geom_line()


How can I decide whether a peak in the spectrum is indeed the amplitude of the signal and not noise? Is there a formula to define a threshold?

Thanks!
You may have to read on SS (spectrum sensing) techniques. There is a famous method called "Energy detection".

Else

If the noise is WGN, then its PSD is constant. So at a particular frequency of the spectrum, if the PSD is around that of noise, then it's noise, else it's signal.