How to simulate CDF and PDF of Random varible 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))$$
 A: 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 

edit
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;

figure(1);
plot(CDFx,eCDFy,CDFx,tCDFy);
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;

figure(2);
plot(PDFx,ePDFy,PDFx,tPDFy);
legend('PDF from random numbers', 'exact PDF')

