我使用scipy.optimize来拟合实验数据曲线和模型以及2个参数。我的代码是:
def capvoltage(time, v1, tau):
return v1*(1-np.e**(-time[i]/tau)) #time constant charging equation
pcap0 = [4, 5.6*10**-5] #initial guesses
popt, pcov = curve_fit(capvoltage, time, vcap, pcap0, sigma=udata, absolute_sigma=True)
我定义了我的函数和参数,并尝试拟合曲线:
ValueError Traceback (most recent call last)
<ipython-input-66-71cef837be6f> in <module>()
1 pcap0 = [4, 5.6*10**-5]
----> 2 popt, pcov = curve_fit(capvoltage, time, vcap, pcap0, sigma=np.fabs(udata), absolute_sigma=True) #scipy optimize
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/scipy/optimize/minpack.py in curve_fit(f, xdata, ydata, p0, sigma, absolute_sigma, check_finite, bounds, method, jac, **kwargs)
721 raise ValueError("`sigma` must be positive definite.")
722 else:
--> 723 raise ValueError("`sigma` has incorrect shape.")
724 else:
725 transform = None
ValueError: `sigma` has incorrect shape.
其中udata是我的实验不确定性。我收到以下错误消息:
BackGround(Context context,Class mIntentclass) {
this.ctx=context;
this.mIntentclass = mIntentclass;
}
我的西格玛值有什么问题/这是什么意思?