In may wireless communication they dirive a CDF and PDF then they conferme the theorical result with simulation My question how the sumulat. For example suppose we have 3 random varibles $h_i$ wish are zero-mean, independent, circularly symmetric complex Gaussian random variables with variances $\delta^2_i$. $|h_i|^2$ is expontial with parametre $\beta_i$. We want to drive PDF and CDF of random varible $$z=\max\{|h_1|^2,|h_2|^2,|h_3|^2\}$$.

the CDF of $z$ is $$F_Z(z)=(1-e^{(-\beta z)})^3$$ and pdf $$ P_Z(z)=3\beta e^{(-\beta z)}(1-e^{(-\beta z)})^2 $$. My question how to plot the theorical CDF and PDF in matlab and do simulation. In matlab we generate $h$ as follow $$h=(randn(1,Nsym)+1j*randn(1,Nsym))$$


First off you want to generate samples of the max of three so do

h = max(abs(randn(3,N)+ j * randn(3,N)).^2);

Now $h$ is the $1\times N$ vector you want the sample statistics of. For the empirical CDF, you can do

CDFx = sort(h);
CDFy = (1 : length(h)) / length(h);

There's also a builtin ecdf function in newer versions.

For the empirical PDF, there's a few options... there's Kernel densities which have a matlab builtin you can search for. The most straightforward 'by hand' is just doing a normalized histogram

[pdfy, pdfx] = hist(h,nbins);
pdfy = pdfy/trapz(pdfx,pdfy); % normalize 


More detail:

N = 10000;
nbins = 50;

h = max(abs(randn(3,N)+ j * randn(3,N)).^2);

CDFx = sort(h);
eCDFy = (1 : length(h)) / length(h);
tCDFy = (1-exp(-.5*CDFx)).^3;

legend('CDF from random numbers', 'exact CDF')

[ePDFy, PDFx] = hist(h,nbins);
ePDFy = ePDFy/trapz(PDFx,ePDFy);
tPDFy = 3 * .5 * exp(-.5 * PDFx).*(1-exp(-.5 * PDFx)).^2;

legend('PDF from random numbers', 'exact PDF')
  • $\begingroup$ hi spaceisdarkgreen i will try your code. thank you but what about theorical $\endgroup$ – Mokhtar Mar 29 '18 at 23:58
  • $\begingroup$ @Mokhtar That's just a matter of plotting the functional forms you derived (which, for what it's worth, look correct to me). And I guess if you don't want to worry about making a grid for the x values, just using pdfx or cdfx will be fine if they are dense enough. $\endgroup$ – spaceisdarkgreen Mar 30 '18 at 0:06
  • $\begingroup$ Hi spaceisdarkgreen again i will add figure to understand me $\endgroup$ – Mokhtar Mar 30 '18 at 0:16
  • $\begingroup$ i Have add the figuer the analisis of cdf and pdf is very complicated however i want to now how the use simulation and get exact the theorical graph. Thank you. $\endgroup$ – Mokhtar Mar 30 '18 at 0:23
  • $\begingroup$ @Mokhtar What do you mean by 'do the simulation'. Do you mean by drawing the random numbers as in $h=...$ above? It's not at all clear from the plots you posted what is being plotted. I added code that will test plot the empirical distributions out of the random number generator and also plot the exact functional forms you derived. $\endgroup$ – spaceisdarkgreen Mar 30 '18 at 0:48

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.