Power-law random generator

So you want to generate random numbers distributed along a power-law, uh?

Suppose your target distribution is:

P(y) \sim y^{-n}

you will use:

y = x^{1/(1-n)}

where x is a random variable distributed uniformly and n>1.
This formula comes from the differential equality:

p(x)dx=p(y)dy

which becomes:

\frac{dx}{dy}=p(y)

in case x is distributed uniformly. For example, suppose you want to generate numbers which are distributed exponentially, you will use:

\frac{dx}{dy}=e^y

\Rightarrow x=e^y

which finally gives:

y=log(x)

Advertisement


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.