简体   繁体   English

如何在Python中获取600个值的均值为零且标准偏差为σ= 2 dB的对数正态分布(即以dB为单位的正态分布)?

[英]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. 换句话说,如果以对数单位指定musigma ,则样本将以线性单位表示。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 Python 中采样多元对数正态分布? - How can I sample a multivariate log-normal distribution in Python? 拟合对数正态分布(Python 图) - Fitting Log-normal distribution (Python plot) 使用 Python 澄清对数正态分布 - Clarification of log-normal distribution using Python 遵循对数正态分布或不使用 Python - Following a log-normal distribution or not using Python 在 Python 中指定对数正态分布的范围 - Specifiying range for log-normal distribution in Python 如何使用 Scipy 拟合对数正态分布? - How to fit a log-normal distribution with Scipy? 当在 python 中为正态分布绘制 pdf 并且标准偏差为 2 时,平均值是否仍然为零? - when plotting a pdf in python for a normal distribution and the standard deviation is 2, will the mean still be zero? 给定均值和标准差,如何计算正态分布的概率? - How to calculate probability in a normal distribution given mean & standard deviation? 如何从 python 中的对数正态分布概率密度 function 图中计算概率? - How can I calculate probability from the log-normal distribution probability density function graph in python? 使用python中的对数轴缩放和拟合对数正态分布 - Scaling and fitting to a log-normal distribution using a logarithmic axis in python
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM