On Sun, Jun 10, 2012 at 9:16 AM, wdg <
samue...@gmail.com> wrote:
> This is indeed nice. However, the degree sequence I need is a little
> bit more than that.
Then you will need to dive a bit in the code. The function
powerlaw_sequence is just:
def powerlaw_sequence(n,exponent=2.0):
"""
Return sample sequence of length n from a power law distribution.
"""
return [random.paretovariate(exponent-1) for i in range(n)]
I don't have access to the paper you linked, so I don't know exactly
what you want, but if the Wikipedia [1] is right about it, you want
something following $x^\alpha e^{-\beta x}$. So, your task would be to
cook a function that generates n random numbers following that
distribution.
Numpy has the function numpy.random.gamma [2] that, if I am not
mistaken, it is what you want. If your function is slightly different
and you cannot find them there, you would have to code your own
generating method, like rejection or the inverse method (both
explained marvelousely in [3] or in any basic numerical analysis
book).
[1]
http://en.wikipedia.org/wiki/Powerlaw#Power_law_with_exponential_cutoff
[2]
http://docs.scipy.org/doc/numpy/reference/generated/numpy.random.gamma.html#numpy.random.gamma
[3] W. Press et al, Numerical Recipes