How to obtain Nakagami random variable from CDF plot?
4 views (last 30 days)
Show older comments
zBin = [0:0.01:7];
w = 1;
m=1;
syms zBin;
pzTheory = 2*((m/w)^m)*(zBin.^(2*m-1)).*exp(-(zBin.^2)*m/w)/gamma(m);
F= int(pzTheory,zBin,0,zBin);
F1=abs(F)
ezplot(F, [0, 3]);hold on;
cdfinv=inv(F1);
%ezplot(cdfinv,[0 3]);hold on
%axis([0 3 0.5 -1 2]);
grid on
xlabel('z');
title('Cumulative Distribution function of Nakagami-m' )
I am able to get a cdf curve of Nakagami distribution,now how do i get a random variable from this plot. I need to use this random variable with BPSK. Please Help... Thanks in advance
0 Comments
Accepted Answer
Tom Lane
on 13 Sep 2012
The inv function computes a matrix inverse. If you want to invert the function using the Symbolic Toolbox, something like this might work:
solve('p = 1 - exp(-zBin^2)','zBin')
a = sym('(-log(1 - p))^(1/2)') % got this from result of previous
b = subs(a,'p',rand(500,1));
If you have the Statistics Toolbox, that supports the Nakagama distribution directly. For example:
c = random('naka',1,1,1000,1); % parameters (1,1), size 1000-by-1
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!