不明白为什么会发生这种浮动问题

时间:2019-01-17 01:09:07

标签: python numpy

我一直收到相同的错误消息,不知道为什么。

def function_to_fit(x, a, b):
    return (a*x) + b

fit_guess = np.array([ 2., 0.])

popt, pcov = curve_fit(function_to_fit, x, y, sigma=y_err, p0=fit_guess)
print("Fit Parameters:", popt)
print("Fit Parameter Uncertainties:", np.sqrt(np.diag(pcov)))

# calculate chi^2 and reduced chi^2
chi2 = np.sum(((y-function_to_fit(x, *popt))/y_err)**2)
print("chi^2:", chi2)
print("Reduced chi^2:", chi2/(len(x) - len(fit_guess)))
TypeError: can't multiply sequence by non-int of type 'numpy.float64'

0 个答案:

没有答案