以高值为中心的对数正态随机数 [英] Lognormal Random Numbers Centered around a high value
问题描述
我正在尝试使用numpy/scipy从对数正态分布中创建随机数.
I am trying to create random numbers from a lognormal distribution using numpy/scipy.
平均值为2000,σ为800.
The mean is given as 2000 and sigma as 800.
如果我使用numpy.random.lognormal创建平均值(均值= 2000,sigma = 800,size = 10000) 我得到的是非常高或inf的数字.
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?
推荐答案
注意:mean
和sigma
自变量对应于lognormal
分布的对数的分布;分布的实际算术平均值为exp(mean + sigma**2/2)
,当mean=2000
和sigma=800
时,在标准双精度浮点中的计算结果为inf
.
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
.
请参阅 http://docs.scipy .org/doc/numpy/reference/genic/numpy.random.lognormal.html#numpy.random.lognormal 和 http://en.wikipedia.org/wiki/Log-normal_distribution 有关更多详细信息.
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.
这篇关于以高值为中心的对数正态随机数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!