Random numbers from complex PDF

조회 수: 5 (최근 30일)
Alex Kurek
Alex Kurek 2016년 4월 21일
편집: Roger Stafford 2016년 4월 21일
Hi,
I need to generate random complex numbers. My PDF looks like this:
[X, Y] = meshgrid( span, span );
alfaJ = X + 1i*Y;
PDF = 1/(pi*(G-1)) * exp( -abs(alfaJ).^2 / (G-1) );
This PDF looks like this:
And I try to do this to get random numbers:
rePDF = sum(PDF, 1);
reSum = cumsum (rePDF); % is this CDF ok?
nearestRe = abs(reSum - rand);
nearestIm = abs(reSum - rand);
[~, A_Re] = min(nearestRe);
[~, A_Im] = min(nearestIm);
And finally I have:
A = A_Re + 1i*A_Im;
But histograms of A_Re and A_Im are not symetricall and generally i think those random numbers are to large. What is wrong? Is this approach not suited for complex numbers?
Cheers, Alex
  댓글 수: 2
jgg
jgg 2016년 4월 21일
You don't seem to be using the covariance of the value when you compute your random numbers, which is why things are messed up. There's nothing special about complex numbers; this is equivalent to trying to sample from a multivariable distribution.
If you know this is normal with a given covariance, you can use mvnrnd.
If it's something else, the best way to do it would be to sample real number first, then using the conditional PDF, sample the complex number afterwards. You need to use use the conditional PDF, though, not the unconditional PDF (which I think is what's going on here)
Alex Kurek
Alex Kurek 2016년 4월 21일
편집: Alex Kurek 2016년 4월 21일
Thank you.
What I have is this PDF only. I do this now:
mu = mean(P);
sigma = std(P);
rng default % For reproducibility
r = mvnrnd(mu,sigma,20);
plot(R(:,1),R(:,2),'+')
But it seems the numbers are still not OK:
Cheers, Alex

댓글을 달려면 로그인하십시오.

채택된 답변

Roger Stafford
Roger Stafford 2016년 4월 21일
편집: Roger Stafford 2016년 4월 21일
The probability of lying inside a circle about the center with radius R in the X-Y plane is
P = 1-exp(-R^2/(G-1))
Therefore
R = sqrt(-(G-1)*log(1-P))
Consequently you can generate n random values for X and Y using the 'rand' function by:
R = sqrt(-(G-1)*log(rand(n,1)));
T = 2*pi*rand(n,1);
X = R.*cos(T);
Y = R.*sin(T);
Or you can express it as:
alpha = R.*exp(1i*T);

추가 답변 (0개)

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by