【问题标题】:Python Scipy Optimization curve_fitPython Scipy 优化 curve_fit
【发布时间】:2014-09-05 21:56:48
【问题描述】:

我有两个 numpy 数组 x 和 y,并希望将曲线拟合到数据中。拟合函数是一个以 a 和 t 作为拟合参数的指数函数,以及另一个 numpy 数组 ex。

import numpy as np
import scipy
import scipy.optimize as op

k=1.38e-23
h=6.63e-34
c=3e8

def func(ex,a,t):
    return a*np.exp(-h*c/(ex*1e-9*kb*t))

t0=300 #initial guess
print op.curve_fit(func,x,y,t0)

【问题讨论】:

  • 您好,欢迎来到 SO。为了让我们能够为您提供帮助,请说明您的问题是什么以及您的问题是如何表现出来的。
  • 请查看curve_fit的文档。您的函数定义不正确。看看第一个例子,这正是你想要做的。
  • @user2993263 你检查下面的答案了吗

标签: python optimization numpy scipy curve-fitting


【解决方案1】:

您的初始猜测应该包含两个值,例如 t0=(300, 1.),因为您有两个拟合参数(at)。

你需要定义你想要拟合的点,即在调用curve_fit()之前定义xy

【讨论】:

    猜你喜欢
    • 2017-10-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-08
    • 1970-01-01
    相关资源
    最近更新 更多