1
$\begingroup$

Consider a system model of the form: $y_n = ax_n + v_n$ where $x_n$ is the input that is corrupted by $v_n$ which is an Additive White Gaussian Noise of zero-mean and variance 1 for $n = 1,2,...,N$ samples. $a$ is an unknown parameter representing the channel coefficient. How do I generate $v_n$ which is White but of a different variance other than $1$ and a particular SNR?

QUESTION: I am not sure whether the following way creates a signal of non-unit variance and how to determine the variance? If I create a signal z_10 using awgn() with a particular SNR say 10 dB, then would its variance be different from another signal, z_20 created using SNR = 20 dB? What is the proper way to create signal of a particular variance and know its SNR? y_wnoise = y + sqrt(variance)*randn(size(y)) but how do I include the SNR value?

The way I have implemented in MATLAB is as follows. Did I do it correctly?

%generate data:
N = 50; %number of data points
s = randn(1,N);
a = 0.6;
for n = 1:N
   y(n) = a*s(n); 
end
SNR = [10,15]


%generate noisy signal of different variance
z_10 = awgn(y,10,'measured');
z_15 = awgn(y,15,'measured');
OR
z1 = y + sqrt(0.6)*randn(1,N);
$\endgroup$
1
$\begingroup$

It depends on what you mean by SNR. It's a common joke in the DSP community to spell it out as "something to noise ratio", referring to the fact that there is no unique definition of SNR, so the term by itself means nothing.

Define it yourself and use it appropriately.

What's common is to define it as ${\rm SNR} = \frac{P_{\rm s}}{P_{\rm n}}$ where $P_{\rm s}$ is the power (variance) of the signal samples ($x_n$ in your notation) and $P_{\rm n}$ is the power (variance) of the noise samples.

Hence:

P_s = 1;   % target signal power
SNR = 15;  % target SNR in dB
P_n = P_s / 10^(SNR/10); % calculated noise power

s = randn(1,N)*sqrt(P_s);
v = randn(1,N)*sqrt(P_n);
y = a*s + v;

You don't need the for loop there by the way. You can use the awgn function, it should do something very similar. Again, there is no clear need for it though.

Note that this definition of the SNR is independent of a. Depending on your application this may be desirable or undesirable. In the latter case, you can include it in your SNR definition. Feel free to do so. Just define everything very clearly.

*edit: In response to your question: the SNR is really a ratio of signal power to noise power. So to change the SNR, you can change both. If you want the SNR to be 10 dB higher, you can decrease the noise variance by 10 or alternatively increase the signal variance by 10.

If you want to change the SNR while keeping the noise variance fixed (say, 1), you're welcome to do so. Almost the same approach:

P_n = 1;   % target noise power
SNR = 15;  % target SNR in dB
P_s = P_n / 10^(-SNR/10); % calculated signal power

s = randn(1,N)*sqrt(P_s);
v = randn(1,N)*sqrt(P_n);
y = a*s + v;

This also means looking at the noise variance itself doesn't tell you about the SNR conditions. If you assume it's 1 this can mean a low SNR (if the signal power is, say, below 1) or a high SNR (if it is much higher than 1).

$\endgroup$
  • $\begingroup$ @Sm1: I augmented my reply, hopefully accounting for your comments. $\endgroup$ – Florian Jul 23 at 14:21
  • $\begingroup$ $P_s/P_n = 10^{{\rm SNR}/10}$ hence $P_s = P_n \cdot 10^{{\rm SNR}/10} = P_n / 10^{-{\rm SNR}/10}$. $\endgroup$ – Florian Jul 23 at 15:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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