4

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?

Peter O.
  • 32,158
  • 14
  • 82
  • 96
Lukas Mosser
  • 71
  • 1
  • 8

1 Answers1

6

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.

Warren Weckesser
  • 110,654
  • 19
  • 194
  • 214