我有以下数据集
angles =np.arange(-90,91,15)
n_col_cnts =([ 0.08692008,0.46557143,0.7282595,0.89681908,0.97057961,1.,0.99488705,0.91823478,0.84187586, 0.73110934,0.53363229,0.25338418,0.01328528])
我想使用optimize.leastsq()
from对这些数据进行高斯拟合,scipy
但遇到了一个绊脚石。这是我从这里尝试过的
fitfunc = lambda p, x: p[0]*math.exp(-((x-p[1])/p[2])**2) #Target function
errfunc = lambda p, x, y: fitfunc(p, x) - y # Distance to the target function
p0 = [1., 0., 30.] # Initial guess for the parameters
fit, success = optimize.leastsq(errfunc, p0[:], args=(angles,n_col_cnts))
但是我收到错误消息
TypeError: only length-1 arrays can be converted to Python scalars
我不明白。我做错了什么?