Generating integer random numbers from power-law distribution

1 回表示 (過去 30 日間)
Sunstar
Sunstar 2013 年 12 月 13 日
回答済み: Weijia Chen 2019 年 9 月 18 日
Is there a code to generate integer random numbers through power-law distribution of the form p(x)=x^-(alpha+1)?
thanks in advance

採用された回答

Image Analyst
Image Analyst 2013 年 12 月 13 日
Try this: RANDRAW

その他の回答 (3 件)

Miguel Ángel
Miguel Ángel 2013 年 12 月 13 日
編集済み: Miguel Ángel 2013 年 12 月 13 日
I don't know if round,ceil or floor is correct, but in case this may be a way
n=1000;
p=rand(1,n);
alpha=0.1;
%inverse of distribution
%properties of logs %LOGa(n) = LOGb(N) / LOGb(a)
%~round/ceil/floor
x=round(log(p)/log(alpha+1));
  1 件のコメント
Sunstar
Sunstar 2013 年 12 月 13 日
Thank you for your reply. Unfortunately, I cannot simply round or floor or ceil. I need to generate real integers.

サインインしてコメントする。


Roger Stafford
Roger Stafford 2013 年 12 月 13 日
The distribution you mention is equivalent to the zeta distribution with alpha+1 replaced by s. See the website
http://en.wikipedia.org/wiki/Zeta_distribution
As Image Analyst has mentioned, there is a File Exchange contribution called 'randraw' which is located at:
http://www.mathworks.com/matlabcentral/fileexchange/7309-randraw
which claims to generate random numbers in accordance with fifty various distributions including the zeta distribution. It might be what you need.
  1 件のコメント
Sunstar
Sunstar 2013 年 12 月 13 日
Thank you! I am also considering Zipf generators.

サインインしてコメントする。


Weijia Chen
Weijia Chen 2019 年 9 月 18 日
I also meet the same problem. The minimum integer that zeta distribution can generate seems to be 1, but I hope 0 can be generated. Is there any other distributin can do this? Thank you

カテゴリ

Help Center および File ExchangeRandom Number Generation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by