使用optimize.curve_fit拟合时如何修复参数?
我想使用optimize.curve_fit修复参数。 这是我的代码:
def sinefunction2(x, a, b, c, phi, omega):
return a+ b * np.sin(omega*x + phi) + c*(np.sin(omega*x + phi))**2
phi = how to fix?
x= scan_no
y= fwhm_r
p0=[0.05, 0.1, 0.01, phi, 0.12]
params2, params_covariance2 = optimize.curve_fit(sinefunction2, scan_no, \
fwhm_r, p0, sigma=error_r, absolute_sigma=True)
如何修复 phi 参数?
谢谢。
I would like to fix a parameter using optimize.curve_fit.
This is my code:
def sinefunction2(x, a, b, c, phi, omega):
return a+ b * np.sin(omega*x + phi) + c*(np.sin(omega*x + phi))**2
phi = how to fix?
x= scan_no
y= fwhm_r
p0=[0.05, 0.1, 0.01, phi, 0.12]
params2, params_covariance2 = optimize.curve_fit(sinefunction2, scan_no, \
fwhm_r, p0, sigma=error_r, absolute_sigma=True)
How can I fix phi param?
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需将其作为变量包含在函数中并将其设置为常量值,以便每次调用该函数时,它都会具有该值。另外,从函数中删除
phi
作为参数。Just include it as a variable inside your function and set it to a constant value, so that every time the function is called, it will have that value. Also, remove
phi
as an argument from the function.