【发布时间】:2020-02-28 07:05:59
【问题描述】:
我使用以下代码将 Weibull 分布拟合到我的数据:
# -- set up the figure and axis
fig, ax = plt.subplots(figsize=(10, 7))
# Set bins:
bins = np.arange(0, 40+0.5, 1)
# -- make a histogram
ax.hist(af_farm_w_speed, bins=bins, density=True, alpha = 1, align='left', zorder=0, rwidth=0.7, color='grey')
ax.set_xlabel("Wind Speed [knots]", fontsize=15)
ax.set_ylabel("Frequency [%]", fontsize=15)
ax.set_title('Wind Speed Distribution and Weibull fit', fontsize=18)
(scale, a, shape, c) = stats.exponweib.fit(af_farm_w_speed, f0=1, floc=0)
ax.plot(bins, stats.exponweib.pdf(bins, *stats.exponweib.fit(af_farm_w_speed, f0=1, floc=0)), zorder=1, color = "black", linewidth=1.6, label="Post-Farm Weibull Fit (a={:.4g}, c={:.5g})".format(a, c))
ax.legend()
但是,如输出所示,我的拟合不是一条平滑的线。有人知道如何解决这个问题吗?enter image description here
【问题讨论】:
标签: python histogram curve-fitting weibull