简体   繁体   English

使用scipy绘制所得拟合曲线

[英]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.

相关问题 使用 scipy curve_fit 拟合指数曲线(拟合曲线确实匹配真实曲线) - Using scipy curve_fit to fit exponential curve (fitted curve does match real curve) Scipy curve_fit:如何绘制拟合曲线超出数据点? - Scipy curve_fit: how to plot the fitted curve beyond the data points? 使用 scipy.optimize.curve_fit 绘制图形 - Plotting graph using scipy.optimize.curve_fit 有没有办法固定多个变量并适合 SciPy curve_fit function? - Is there a way to have multiple variables fixed and fitted for the SciPy curve_fit function? 在scipy上的曲线拟合线上绘制一个sigma误差条 - Plotting one sigma error bars on a curve fit line in scipy 拟合指数曲线误差 - Fitted Exponential Curve Error statsmodels-绘制拟合分布 - statsmodels - plotting the fitted distribution 当拟合参数之一更改xdata输入数组值时,是否可以在python中使用scipy.curve fit? - Can I use scipy.curve fit in python when one of the fitted parameters changes the xdata input array values? 使用ReportLab在图表上拟合曲线 - Fitted curve on chart using ReportLab Scipy 非常适合并创建了多个拟合曲线,这不应该是这种情况,我知道曲线拟合不会返回多条曲线 - Scipy fits very weirdly and creates multiple fitted curves which shouldn't be the case and I know curve fitting doesn't return multiple curves
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM