Generating integer random numbers from power-law distribution

조회 수: 2 (최근 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.

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 CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by