Seaborn distplot:具有一些固定参数的拟合分布

时间:2017-12-16 17:09:22

标签: python matplotlib seaborn data-fitting

我想将一些分布(例如gamma)拟合到给定的数据数组x,并绘制相应的密度函数。我可以通过seaborn.distplotscipy.stats轻松完成此操作:

sns.distplot(x, fit = stats.gamma)

但是,让我们说我希望此发行版的某些参数保持固定,例如loc。当我使用来自fit的{​​{1}}函数并使用固定scipy.stats时,我将其写为

loc

有没有办法在stats.gamma.fit(x, floc = 0) 函数中将loc=0传递给fit并获得相同的结果?

2 个答案:

答案 0 :(得分:0)

sns.distplot(x, fit = stats.gamma)确实会显示合理情节且stats.gamma.fit(x, loc = 0)会提供所需统计数据的条件下,您可以通过fit_kws提供参数:

sns.distplot(x, fit = stats.gamma, fit_kws={"loc" : 0})

[此答案基于阅读the documentation并且未经测试,因为问题中没有给出用例。]

答案 1 :(得分:0)

最简单的方法是不使用distplot绘制拟合,而是使用in this post描述的方法。提供简单示例:

localextensions.xml

这会产生类似...... not enough rep to embed

相关问题