0
$\begingroup$

Consider a "pure" sine wave (no visible noise):

enter image description here

and let's calculate signal-to-noise ratio of it by (mean to standard deviation): $$SNR=\frac{\mu}{\sigma}$$

here's the code in Python:

t = np.arange(0, 4e-6, 2e-9)
f1 = np.sin(50e6*t)

SNR = np.mean(f1)/np.std(f1)

the result is $SNR=0.003928$ (looks low for a pure signal)

and let's "apply" some offset to the data:

enter image description here

t = np.arange(0, 4e-6, 2e-9)
f1 = np.sin(50e6*t+10)

SNR = np.mean(f1)/np.std(f1)

and behold $SNR = 14.133893$ (but the signal still "pure"!)

What's wrong with this interpretation of $SNR$? Maybe I do something incorrect?

$\endgroup$
15
  • 2
    $\begingroup$ SNR is usually power-to-power. Just finding the mean of a sine wave will always be close to zero (though, as you see, changing the phase will alter this). You need to do something more like $\frac{\sum |x|^2}{\sigma_x}$ instead. $\endgroup$
    – Peter K.
    Nov 19, 2021 at 21:34
  • 2
    $\begingroup$ Sorry, this makes no sense whatsoever. SNR is signal energy divided by noise energy. You are dividing the mean by the standard deviation. Whatever that is, it's NOT the SNR. Can you cite where you came across this definition of SNR ? $\endgroup$
    – Hilmar
    Nov 19, 2021 at 21:34
  • 1
    $\begingroup$ Very nice link, but I cannot find the place you reference. In any event, using SNR as mean/standard deviation is not useful in many situations. For a sine wave, you have plenty of viable options, e.g., peak magnitude/standard deviation. And the power ratio is fine. I will look through chapter 8 in your linked reference. $\endgroup$
    – Ed V
    Nov 19, 2021 at 22:15
  • 2
    $\begingroup$ That's not on the link you gave (and I'm not sure what you mean by "page 17" on a web link?). I did eventually find it here. Regardless, it's wrong. $\endgroup$
    – Peter K.
    Nov 19, 2021 at 22:18
  • 1
    $\begingroup$ I found it at the end of Chapter 2 in the linked book. @PeterK. is right about that definition being wrong, but there are specific cases where it can work. For example, suppose you have a rectangular pulse and the pulse has amplitude A, with the baseline being zero. Also suppose there is additive white noise on the pulse. So you could use the mean of some measurements of the noisy pulse amplitude and the standard deviation of those (or the baseline). $\endgroup$
    – Ed V
    Nov 19, 2021 at 22:30

1 Answer 1

3
$\begingroup$

Signal to Noise ratio is the ratio of signal power to noise power. In this case the OP has a signal, and alone and is incorrectly using the mean of the signal as a metric of the signal power, and the standard deviation of the signal, also Incorrectly, as a metric of the relative noise power. Notice that if the sinusoid is an integer number of cycles, the mean will be zero, and for other cases (as the OP had done), will have non-zero mean when a cycle is truncated due to the residual of that cycle.

The good question here is then how do we best estimate SNR when we have a general capture of signal plus noise? For this I use the correlation coefficient and then from that we can get a very good estimate of the SNR. We correlate the signal+noise waveform to a known good reference of the signal alone and normalize by the standard deviation of both (this is the Pearson Correlation Coefficient) to get $\rho$, and then we can relate $\rho$ to SNR as I already detailed in the following posts:

How can I find SNR, PEAQ, and ODG values by comparing two audios?

SNR estimation prior to demodulation?

Noise detection

$\endgroup$
1
  • $\begingroup$ thank you so much! very nice links, that's what I needed! $\endgroup$
    – Curious
    Nov 20, 2021 at 20:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.