Skip to content


Subversion checkout URL

You can clone with
Download ZIP


lognormal distribution returns negative numbers #3418

ysanders opened this Issue · 5 comments

4 participants


If I try to generate random variables from the lognorm distribution, I seem to get the logarithm of the random variables rather than the random variables. For example,

from scipy.stats import lognorm

returns an array of ten floats near zero, some of which are negative. Calculating the exponential of this array yields an array of ten floats near 1.

Perhaps this is intentional behaviour, but I doubt it.


I'm pretty sure the -1 is treated as a location parameter. See rv = lognorm(s, loc=0, scale=1). So lognorm(.1, -1).rvs(10) gives floats near 0, lognorm(.1, 0).rvs(10) gives floats near 1, and lognorm(.1, -10).rvs(10) gives floats near -9.


Just what Alex said:

>>> import numpy as np
>>> np.random.seed(123)
>>> lognorm.rvs(0.1, -1)
>>> np.random.seed(123)
>>> lognorm.rvs(0.1, loc=-1)

Not a bug, hence closing. Questions are most welcome in the scipy-user mailing list and/or stackoverflow.

@ev-br ev-br closed this
@rgommers rgommers added the invalid label

@ysanders scipy.stats generalizes continuous distributions to translated and to spread-out variants of the original distribution. The -1 argument in your function is a translation. So this changes the support. Any distribution supported on the positive real numbers can be translated in this way so that the support of its translated distribution can include negative numbers. If you want to sample from lognormal distributions with the original support (positive real numbers) then don't pass -1 as the location parameter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.