0

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?

Curious
  • 355
  • 1
  • 11
  • 2
    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. – Peter K. Nov 19 '21 at 21:34
  • 2
    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 ? – Hilmar Nov 19 '21 at 21:34
  • @Hilmar, sure: http://www.dspguide.com/ch8/1.htm, page 17. I'd like to argue about power or energy - what about voltage acquired for instance by ADC? how would you calculate $SNR$ in this case? – Curious Nov 19 '21 at 21:39
  • @PeterK., how would you calculate $SNR$ of the signal acquired by ADC (it is often in volts)? – Curious Nov 19 '21 at 21:40
  • In some fields, we also use SNR definitions that are signal magnitude divided by noise standard deviation. So for your sine wave, the DC offset is not signal. It is just a constant. But you could use peak amplitude as signal or some other sensible notion of signal. The important thing is to be clear about what you do and report later. – Ed V Nov 19 '21 at 21:46
  • @EdV, for sure!) that's why I'm asking about this) what to to do with NO power signals (voltage or current, for example)? Here: dspguide.com/ch8/1.htm at page 17 the author lists voltage vs. time and right after defines $SNR$ as mean to standard deviation without any attention, that we can use this formula only for power – Curious Nov 19 '21 at 21:55
  • 1
    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. – Ed V Nov 19 '21 at 22:15
  • I, like @EdV, cannot find the place you reference in that link. Care to include a screenshot in your question? Or check the link? – Peter K. Nov 19 '21 at 22:16
  • Here the citation at page 17: This gives rise to the term: signal-to-noise ratio (SNR), which is equal to the mean divided by the standard deviation. – Curious Nov 19 '21 at 22:17
  • 2
    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. – Peter K. Nov 19 '21 at 22:18
  • @PeterK., sorry for that, yes that's my fault (I thought it is the link for the whole book and didn't pay enough attention for it), here it is: http://www.dspguide.com/ch2/2.htm – Curious Nov 19 '21 at 22:19
  • 1
    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). – Ed V Nov 19 '21 at 22:30
  • 1
    @EdV Agreed. Certainly wrong for a sine wave, as in the question. – Peter K. Nov 19 '21 at 22:32
  • @EdV and Peter K., thank you for your comments, I absolutely agree with you and think this definition is not suitable for harmonic signals. Do you know some standard estimations of $SNR$ for periodic signals? it's a bit unclear for me, how to estimate $SNR$ of such signals. – Curious Nov 20 '21 at 11:27
  • 1
    I’m voting to close this question because it was caused by an incorrect definition. – Marcus Müller Nov 20 '21 at 12:24

1 Answers1

3

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

Dan Boschen
  • 50,942
  • 2
  • 57
  • 135