python - 来自 scipy.optimize 的 python 中 curve_fit 和 leastsq 之间的区别

标签 python scipy curve-fitting

我有一个函数包含: 自变量 X, 因变量 Y
两个固定参数a和b。

使用相同的实验数据,curve_fitleastsq 函数都可以拟合到具有相似结果的函数。

使用 curve_fit 我有: [ 2.50110215e-04 , 7.80730380e-05] 用于固定参数 a 和 b。

使用 leastsq 我有: [ 2.50110267e-04 , 7.80730843e-05] 用于固定参数 a 和 b。

我想知道这两者是否有区别,如果有,什么情况下应该使用curve_fit,什么情况下应该使用leastsq?

最佳答案

curve-fit 使用 leastsq 进行计算,因此它们应该始终给出相同的结果。您看到的微小差异可能是某处舍入误差的结果。直接调用 leastsq 应该可以消除这种情况。

来自 curve_fit 的文档:

The algorithm uses the Levenberg-Marquardt algorithm through leastsq. Additional keyword arguments are passed directly to that algorithm.

关于python - 来自 scipy.optimize 的 python 中 curve_fit 和 leastsq 之间的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21205468/

相关文章:

python - 如何测量python中每个代码部分的RAM使用情况?

php - 如何在线制作 Pygame 游戏可执行文件?

python - 模块 'scipy.stats' 没有属性 'nanmean'

r - 如何在 R 中为我的数据拟合平滑曲线?

python - python中的割线法函数

python - python中有没有可以控制每次迭代的数值求解器?

python - 如何计算 Python 中 2 个等高线之间的面积?

scipy - 值错误 : unrecognized engine zarr must be one of: ['scipy' , 'store' ]

python - 平滑信号并找到峰值

python - 有没有办法通过分散的 X、Y 坐标绘制 'tight' 最佳拟合线?