【发布时间】:2017-02-01 07:23:09
【问题描述】:
这是我的代码:
for i in range(-area,area):
stDev1= []
for j in range(-area,area):
stDev0 = stDev[i+i0][j+j0]
stDev1.append(stDev0)
slices[i] = stDev1
fitV = []
xV = []
for l in range(-area,area):
y = np.asarray(slices[l])
x = np.arange(0,2*area,1)
for m in range(-area,area):
fitV.append(slices[m][l])
xV.append(l)
fit = np.polyfit(xV,fitV,4)
yfit = function(fit,area)
x100 = np.arange(0,100,1)
plt.plot(xV,fitV,'.')
plt.savefig("fits1.png")
def function(fit,area):
yfit = []
for x in range(-area,area):
yfit.append(fit[0]+fit[1]*x+fit[2]*x**2+fit[3]*x**3+fit[4]*x**4)
return(yfit)
i0 = 400
j0 = 400
area = 50
stdev = 2d np.array([1300][800]) #just an image of "noise" feel free to add any image // 2d np array you like.
显然这是完全错误的? 我想我想念理解 polyfit 的概念?从文档中,要求是我用两个形状为 x[i] y[i] 的数组来喂它?我的价值观在
xV = [ x_1_-50,x_1_-49,...,x_1_49,x_2_-50,...,x_49_49]
我是:
fitV = [y_1_-50,y_1_-49,...,y_1_49,...y_2_-50,...,y_2_49]
【问题讨论】:
-
能否提供输入数据?
-
我们不知道
area、stDev、i0、j0
标签: python numpy data-fitting