Lukas Mosser
Lukas Mosser

Reputation: 71

Lognormal Random Numbers Centered around a high value

I am trying to create random numbers from a lognormal distribution using numpy/scipy.

The mean is given as 2000 and sigma as 800.

If I create my random valus using numpy.random.lognormal(mean=2000, sigma=800, size=10000) all I get is very high or inf numbers.

Is there a way to work around this?

Upvotes: 4

Views: 1697

Answers (1)

Warren Weckesser
Warren Weckesser

Reputation: 114956

Be careful: the mean and sigma arguments correspond to the distribution of the log of the lognormal distribution; the actual arithmetic mean of the distribution is exp(mean + sigma**2/2), which evaluates to inf in standard double precision floating point when mean=2000 and sigma=800.

See http://docs.scipy.org/doc/numpy/reference/generated/numpy.random.lognormal.html#numpy.random.lognormal and http://en.wikipedia.org/wiki/Log-normal_distribution for more details.

Upvotes: 6

Related Questions