[英]Fitting distribution with fixed parameters in SciPy
Is it possible to fix parameters while fitting distributions in SciPy?在 SciPy 中拟合分布时是否可以修复参数? For example, this code:例如,这段代码:
import scipy.stats as st
xx = st.expon.rvs(size=100)
print st.expon.fit(xx, loc=0)
results in non-zero location ( loc
).导致非零位置 ( loc
)。
When some parameter is provided to the fit
function it is considered as an initial guess.当某些参数提供给fit
函数时,它被视为初始猜测。 And if it is provided to the constructor ( st.expon(loc=0)
) the distribution becomes "frozen" and can not be used for fitting.如果它被提供给构造函数( st.expon(loc=0)
),分布就会“冻结”并且不能用于拟合。
To fix loc
, use the argument floc
:要修复loc
,请使用参数floc
:
print st.expon.fit(xx, floc=0)
Eg例如
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)
Some related questions:一些相关问题:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.