MATLAB: Random numbers drawn from power law with certain mean

power lawrandom number generator

I want to draw random numbers from a power law. These numbers should all be positive and have a mean value of 0.002. I saw that I can generate random numbers from a power law by: b*rand^(-D)
and that these numbers are all positive. However how can I get a mean of 0.002?
Thanks in advance,
Leslie

Best Answer

You are correct that the distribution can by generated by
b*rand(n,1).^(-D)
where b and D are positive parameters. The mean value would be be
mu = b/(1-D)
for your b and D, and for this to be meaningful, D should be less than 1. You would still have one degree of freedom in selecting the parameters with a given mean value.
Note: If you limit your values to 0.01, you no longer have a power law distribution.