power law distribution, How could I generate random variables from the truncated power -law distribution and its PDf?

 Risposta accettata

You need to use inverse transform sampling. I attached a demo where I use it to get random numbers from a Rayleigh distribution.

11 Commenti

unable to find CDF and PDF for Power law distribution ?
I mean in terms of normal distribution all we need is sgm and mu but in this case how could I find aplha?
Thanks
Huh? I think you've forgotten to supply some information, such as your equation. I don't know what alpha is. Maybe you'd like to just use RANDRAW: http://www.mathworks.com/matlabcentral/fileexchange/7309-randraw
If I following inverse transform sampling I need to define my probability function for power law distribution and for that I need value of aplha [can be any value] but I' wondering if this parameter is same as let say normal distribuion needs mu and sgma. Is there any formulation to find out alpha?
Thanks
If you have the formula, you can use it. Otherwise generate a distribution with the PDF formula and numerically integrate to get the CDF with cumsum(). You can use the cumsum() output as a lookup table if you don't have the exact formula for the CDF.
what if my PDF is f(x) = (aplpha-1/xmin)(x/xmin)^-alpha
i followed your code but at the end if I plot histogram of resultant distribution im not getting exactly power law dist instead Im getting double exponential.
What is the range of x you're putting in. And what are some typical values for xmin and alpha that you're using?
I'm using following :
n=1000;
x=rand(1,n);
for i = 1:1000
a = 2.5;
P(i) = ((a - 1)/min(y))*(y(i)/min(y)^(-a))% this PDF
end
jay, that's not right. You didn't follow the recipe. See my attached demo (below the plots) for a full illustration.
Hi Thanks,
It turns out if I have to use your inverse transformation then I need to integrate PDF to get CDF and then I can consider CDF as uniform number apply your technique. Thanks for this code it solved my problem.
Regards Jay
You're welcome. Since I solved your problem, could you go ahead and mark the Answer as "Accepted" so I get credit for it? Thanks in advance.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Mathematics in Centro assistenza e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by