我在stackoverflow中看到了几个关于如何适应的问题log-normal distribution.我还需要知道两个澄清.
我有一个样本数据,其对数遵循正态分布.所以我可以使用scipy.stats.lognorm.fit(即a log-normal distribution)拟合数据
适合工作正常,也给我标准偏差.这是我的一段代码与结果.
sample = np.log10(data) #taking the log10 of the data
scatter,loc,mean = stats.lognorm.fit(sample) #Gives the paramters of the fit
x_fit = np.linspace(13.0,15.0,100)
pdf_fitted = stats.lognorm.pdf(x_fit,scatter,loc,mean) #Gives the PDF
print "scatter for data is %s" %scatter
print "mean of data is %s" %mean
Run Code Online (Sandbox Code Playgroud)
结果
scatter for data is 0.186415047243
mean for data is 1.15731050926
Run Code Online (Sandbox Code Playgroud)
From the image you can clearly see that the mean is around 14.2, but what I get …
- - 样本 - -
我有一个数据集(示例),其中包含 1维数组中的 1 000 个损坏值(这些值非常小 <1e-6)(请参阅随附的 .json 文件)。样本似乎遵循对数正态分布:

--- 问题和我已经尝试过的东西 ---
我尝试了这篇文章中的建议,用 Scipy (Python) 将经验分布拟合到理论分布?和这篇文章Scipy:对数正态拟合通过对数正态分布拟合我的数据。这些都不起作用。:(
我总是在 Y 轴上得到一些非常大的东西,如下所示:
这是我在 Python 中使用的代码(data.json文件可以从这里下载):
from matplotlib import pyplot as plt
from scipy import stats as scistats
import json
with open("data.json", "r") as f:
sample = json.load(f) # load data: a 1000 * 1 array with many small values( < 1e-6)
fig, axis = plt.subplots() …Run Code Online (Sandbox Code Playgroud)