【问题标题】:How to fit powerlaw to a histogram with matplotlib如何使用 matplotlib 将幂律拟合到直方图
【发布时间】:2011-12-09 04:06:21
【问题描述】:

我正在尝试将幂律拟合到直方图(更精确的帕累托分布)。我用我自己的函数来做,在那里我检查最小的差平方和。但这意味着我需要循环抛出所有的系数,这可能需要一些时间。另一个问题是我需要制作自己的数据列表,以便获得直方图数据。

所以我正在寻找一个函数,它可以返回由 matplotlib.pyplot.hist() 生成的数据列表,而不仅仅是一张图片,而且我想用帕累托分布拟合这些数据比循环这么多次更快并获得coefitions。

【问题讨论】:

标签: python curve-fitting power-law


【解决方案1】:

我认为您正在寻找值和 bin 大小。

matplotlib.pyplot.hist() 函数返回一个带有 (n, bins, patch) 的元组

For more information about this function click this link

例如绘制一些“数据”,150 个箱:

import matplotlib.pyplot as plt
hist = plt.hist(data,150)
binsize = hist[0]
value = hist[1]
print binsize
print ''
print value

【讨论】:

    猜你喜欢
    • 2021-06-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-01
    • 1970-01-01
    • 2017-04-27
    相关资源
    最近更新 更多