I'll be happy to erase this question hopefully after getting some tips. I am trying to follow this post to generate power-law distributed values following the equation from Wolfram MathWorld:
I used R, although the code could be easily translated into any other language:
x1 = 8
x0 = 0
n = 2.5
y = runif(1e5)
x = ((x1^(n+1) - x0^(n+1))*y + x0^(n+1))^(1/(n+1))
hist(x)
yielding a histogram symmetrical to what I expected.
What am I missing?
Aucun commentaire:
Enregistrer un commentaire