最佳拟合分布图

时间:2020-10-22 15:05:30

标签: python scipy curve-fitting

我绘制了df1的线性图,并想创建df1的分布拟合图。我使用了以下代码:

import matplotlib.pyplot as plt
import scipy
import scipy.stats

x = scipy.arange(df1)
y = scipy.int_(scipy.round_(scipy.stats.vonmises.rvs(5,size=size)*47))
h = plt.hist(y, bins=range(48))

dist_names = ['gamma', 'beta', 'rayleigh', 'norm', 'pareto']

for dist_name in dist_names:
    dist = getattr(scipy.stats, dist_name)
    param = dist.fit(y)
    pdf_fitted = dist.pdf(x, *param[:-2], loc=param[-2], scale=param[-1]) * size
    plt.plot(pdf_fitted, label=dist_name)
    plt.xlim(0,47)
plt.legend(loc='upper right')
plt.show()

不幸的是,运行此代码后,我收到以下错误:

TypeError: unsupported operand type(s) for -: 'str' and 'int'

请帮助我。 TQ

enter image description here

enter image description here

0 个答案:

没有答案
相关问题