# Amplitude cutoff following FFT

suppose I have a noisy sine wave (as R code):

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


and want to determine the amplitudes of the signal with:

# FFT
y <- fft(x)
# Two-sided spectrum
p2 <- abs(y/l)
# Convert to one-sided spectrum
p1 <- p2[1:(l/2 + 1)]
p1[2:(length(p1) - 1)] <- 2*p1[2:(length(p1) - 1)]
# Define frequency
f <- 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!

• this is matlab, right? if so, please add the matlab tag! also, hm, there might be a formula for an appropriate threshold, but how are we going to decide on what it is? In the end, it's your choice of how much you'd accept classifying noise as sinusoid in favor of not missing sinusoids. In the digital communication field, we call that Receiver Operation Characteristics, ROC, and are always aware of the fact that we're making a tradeoff between being too sensitive and being too robust against noise. – Marcus Müller Mar 24 '17 at 12:30
• ups, missed the first line ("R code"), adding that tag myself. – Marcus Müller Mar 24 '17 at 12:39
• Thanks @MarcusMüller. So how would you then go about if you had a large number of signals that all might have different amplitudes. For such a large number of signals it's not possible to look at each individual spectrum. Thus, I thought there might be a way to automatically distinguish between an amplitude present in the signal and noise. – Pascal Mar 24 '17 at 12:39
• how so? I mean, if that was always automatically possible, I could have infinitely many sines at once, and tell them from noise, and use these to transport infinitely much info from A to B. – Marcus Müller Mar 24 '17 at 12:40
• Hence, you find a cumulative probability function that something above a certain threshold is only signal of interest, and then select an amount of missed signals you're willing to accept, or an amount of misinterpreted noise you're willing to accept, and then choose the threshold based on that stochastic model – Marcus Müller Mar 24 '17 at 12:42

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.

Can we use Otsu's method here ? I have used it in image processing to distinguish the background of an image from the foreground. Now, I and Pascal have the same problem for audio signals.

In particular, should we

1. Look at the audio frequency spectrum and find a threshold frequency or
2. Look at the histogram of amplitudes and select a threshold amplitude ?

this is John BG jgb2012@sky.com

1.- Calibrate first the noise in absence of signals, and then look for signals.

In the lab it's easy, on the field, it may be easy, or complicated, depending upon different factors.

2.- So with your code, you can first measure the noise, set a threshold, and then decide that whatever peaks above the thresholds are signals and whatever below is just noise.

3.- Your sampling has to be fast enough to avoid missing short signals that may go unnoticed between 2 consecutive samples.

With thresholds, inevitably, come BER curves, because noise is random, so although noise has an average amplitude, the instantaneous noise varies in such a way that it may be lower than the threshold, and a short signal below the threshold may then take place, short enough and low enough to again go unnoticed. Because the threshold is never placed right on the noise, there's always certain overhead that must be added.

4.- How do you plant to catch overlapping or too close signals? If 2 signals are too close, again you need enough frequency resolution to resolve them.

What if 2 different signals are right on the same frequency?

I mention this because in your code you go for a single plot of the spectrum, that I guess it's going to be the amplitude, but the phase may also be useful precisely to discern overlapping signals.

5.- Probability detection over distance.

This is an example

https://www.researchgate.net/figure/Detection-prob-vs-Eb-N0_fig6_4325314

of UWB radar with known pulse shape, and scenario studied in advance:

As mentioned above, field tests have been carried out, to calibrate without 'signals' or 'targets' and then the probability of detection can be evaluated.

6.- In this example Irfan shows us some MATLAB code to simulate probability error over EbN0