1
$\begingroup$
 n_3=sqrt(0.1)*randn(1,K);
 n_4=sqrt(0.1)*randn(1,K);
 beta_NLoS=(n_3+1i*n_4); % CN(0,0.1)

I want to create a $CN(0,0.1)$,does my code have any problem?

$\endgroup$
2
$\begingroup$

If you want a Circular Complex Gaussian Noise (Independent):

vComplexNoise = sqrt(noiseVar / 2) * (randn(1, numSamples) + (1i * randn(1, numSamples)))

For correlated noise you'll need to define the Co Variance Matrix and use Cholesky Decomposition.

Update

Following @Stanley Pawlukiewicz advise, run the following code:

numSamples = 100000;
noiseVar   = 4;

mA = sqrt(noiseVar / 2) * (randn(numSamples, 1) + (1i * randn(numSamples, 1)));

var(mA)

You should see result which is very close to noiseVar on the screen.

$\endgroup$
  • $\begingroup$ so the code i written is just a complex gaussian ,not circular? $\endgroup$ – electronic component Aug 22 '18 at 7:57
  • $\begingroup$ vComplexNoise = sqrt(0.1 / 2) * (randn(1, K) + (1i * randn(1, k))) like this? $\endgroup$ – electronic component Aug 22 '18 at 7:59
  • $\begingroup$ Yep, just like you wrote above. Please mark this as answered. $\endgroup$ – Royi Aug 22 '18 at 8:13
  • $\begingroup$ but is't the gaussian distribution $\frac{1}{\sqrt{\sigma^2 2*\pi}}$ $\endgroup$ – electronic component Aug 22 '18 at 8:24
  • 1
    $\begingroup$ The formula for the Gaussian distribution with the variance in the denominator is the distribution function itself, not the random data itself! Then randn function will produce a (real) Gaussian (normal) distribution with a normalized variance of 1. So to get any other variance you need to scale the magnitude of whatever is generated by the standard deviation. Hence sqrt(noiseVar/2). The reason for the divide by 2 as Royi pointed out is that you are generating independent sequences that will sum together. For the sum of independent random variables the variances add. $\endgroup$ – Dan Boschen Aug 22 '18 at 10:42

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.