1
$\begingroup$

Suppose I have a list of amplitude (straight line signal):

x = [1,1,1,0,1,1,1,1]

By intuition, zero value in list x makes the noise of straight signal.

If we modified some value, such as 2, we get more noise level.

y = [1,1,1,0,1,2,1,1]

Hence by my intuition, SNR of list x is greater than SNR of list y.

So how do I calculate SNR from a list?

I know that formula of SNR basically if signal amplitude is voltage.

SNR = 20*log(S_i/N_i)

Where S_i is value of a list signal in an index.

But I have no idea how to get N_i.

Assume we are using volt unit.

I expect I can compute SNR programmatically from scratch without any external library with python.

$\endgroup$

1 Answer 1

2
$\begingroup$

$$SNR = 10 * log((\sum_{i=0}^{N-1} s(i)^2) / (\sum_{i=0}^{N-1} n(i)^2))$$

Where $N$ is the length of the signal, $s(i)$ is signal amplitudes/magnitude and $n(i)$ is noise amplitude/magnitude.

In Your case the summation of noise signal for y is 2 and that of x is 1 hence SNR of x is more than y.

In your case where You are defining the signal to be "straight signal", the original signal can be considered as $[1, 1, 1, 1, 1, 1, 1, 1]$. Let's call this X

noise in signal $n_x = X - x = [0, 0, 0, 1, 0, 0, 0, 0]$

and

noise in signal $n_y = X - y = [0, 0, 0, 1, 0, -1, 0, 0]$

$\endgroup$
2
  • $\begingroup$ Do I need to normalize the data, it seems you normalize to 0. $\endgroup$ Mar 21, 2023 at 14:00
  • $\begingroup$ Normalization was not applied on the signal. $\endgroup$
    – SakSath
    Mar 22, 2023 at 5:19

Your Answer

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

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