[英]How to get log-normal distribution (i.e. a normal distribution in dB) with a zero mean and a standard deviation of σ = 2 dB for 600 values in python?
I tried looking at the following option. 我尝试查看以下选项。
numpy.random.lognormal(0, 2, 600) - My doubts in this method is that, are the input parameters in dB? numpy.random.lognormal(0,2,600)-我对这种方法的怀疑是,输入参数的单位是dB? If so, mu = 0, and sigma = 2. If the input parameters are supposed to be in linear values, the input parameters should be mu = 1, sigma = 10^0.2.
如果是,则mu = 0,并且sigma =2。如果假定输入参数为线性值,则输入参数应为mu = 1,sigma = 10 ^ 0.2。 Another question is, are the resulting random value in linear or in dB?
另一个问题是,结果随机值是线性的还是dB的? If they are in linear, I need to take a 10*math.log10() of these values.
如果它们是线性的,则需要取这些值的10 * math.log10()。
The documentation in http://docs.scipy.org/doc/numpy-1.10.1/reference/generated/numpy.random.lognormal.html does not give any information regarding the input parameters being linear or in dB or neither about the nature of the output results. http://docs.scipy.org/doc/numpy-1.10.1/reference/generated/numpy.random.lognormal.html中的文档未提供有关输入参数是线性或dB或与输入参数无关的任何信息。输出结果的性质。
If x
is log-normally distributed then log(x)
will be normally distributed. 如果
x
是对数正态分布的,那么log(x)
将是正态分布的。 If you're unsure what the parameters refer to then you could just draw some samples, take the log of them and then compute the mean and standard deviation: 如果不确定参数指的是什么,则可以绘制一些样本,取它们的对数,然后计算均值和标准差:
import numpy as np
np.random.seed(0)
mu, sigma = 1, 2
x = np.random.lognormal(mu, sigma, 10000)
logx = np.log(x)
print(logx.mean(), logx.std())
# 0.963132559683 1.97511313635
So np.random.lognormal(mu, sigma, ...)
draws samples from a random variable whose logarithm is normally distributed with mean mu
and standard deviation sigma
. 因此
np.random.lognormal(mu, sigma, ...)
从一个对数正态分布为均值mu
和标准偏差sigma
的随机变量中抽取样本。 In other words, if mu
and sigma
are specified in logarithmic units then the samples will be in linear units. 换句话说,如果以对数单位指定
mu
和sigma
,则样本将以线性单位表示。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.