[英]Plotting resulting fitted curve with scipy
According to this , what about if I want to overplot the fitted curve over the data points? 根据这个 ,一下如果我想overplot内的数据点的拟合曲线是什么? Should I define the fitting function again?
我应该再次定义拟合函数吗?
Leastsq method has lacking documentation and examples, and I have some troubles in understanding the arguments it needs. Leastsq方法缺少文档和示例,并且在理解其所需参数时遇到一些麻烦。
According to that, if I define: 据此,如果我定义:
def optm(l, x, y):
return skew(x, l[0], l[1], l[2]) - y
Then, is it correct to fit in the following way: 然后,以以下方式拟合是否正确:
out_param = leastsq(optm, v1[:], args = (x_values, y_values), maxfev = 100000, full_output = 1)
(where v1[:]
is the vector with the initial guess parameters)? (其中
v1[:]
是带有初始猜测参数的向量)? And then, again, how can I plot the resulting curve? 然后,我又如何绘制结果曲线?
I am still trying to understand so any suggestion is really appreciated. 我仍在尝试理解,因此任何建议都非常感谢。
I have solved in the following way: The string code reported in the question was correct. 我已通过以下方式解决:问题中报告的字符串代码正确。 Then I saved the best-fit parameters in another vector:
然后,我将最佳拟合参数保存在另一个向量中:
p = out_param[0]
Then, I used the skew function to obtain the new (fitted) y_values: 然后,我使用了偏斜函数来获得新的(拟合的)y_values:
new_y_val = skew(x_values, p[0], p[1], p[2])
And finally I can make a plot with these new vectors: 最后,我可以用这些新向量作图:
plot(time1, pl)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.