Random numbers from complex PDF

2 views (last 30 days)
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 Comments
jgg
jgg on 21 Apr 2016
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 on 21 Apr 2016
Edited: Alex Kurek on 21 Apr 2016
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

Sign in to comment.

Accepted Answer

Roger Stafford
Roger Stafford on 21 Apr 2016
Edited: Roger Stafford on 21 Apr 2016
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);

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!