【问题标题】:Fitting distribution with fixed parameters in SciPy在 SciPy 中使用固定参数拟合分布
【发布时间】:2014-03-03 19:39:41
【问题描述】:

在 SciPy 中拟合分布时是否可以修复参数?例如这段代码:

import scipy.stats as st
xx = st.expon.rvs(size=100)
print st.expon.fit(xx, loc=0)

产生非零位置 (loc)。

当某些参数被提供给fit 函数时,它被视为初始猜测。如果将其提供给构造函数 (st.expon(loc=0)),则分布将“冻结”,无法用于拟合。

【问题讨论】:

  • 请详细说明您的问题。
  • 问题很明确

标签: python scipy distribution exponential data-fitting


【解决方案1】:

要修复loc,请使用参数floc

print st.expon.fit(xx, floc=0)

例如

In [33]: import scipy.stats as st

In [34]: xx = st.expon.rvs(size=100)

In [35]: print(st.expon.fit(xx, floc=0))
(0, 0.77853895325584932)

一些相关问题:

【讨论】:

    猜你喜欢
    • 2018-05-30
    • 2019-07-01
    • 2021-02-15
    • 2013-07-03
    • 2021-05-13
    • 1970-01-01
    • 2016-02-19
    • 2013-03-15
    • 2011-03-15
    相关资源
    最近更新 更多