0

我有数据 in.csv 文件,它包含 2 列 x 和 y 轴。轴是从 .csv 文件中读取的,然后使用拉伸指数函数拟合数据,但显示错误。请解决错误。

我的函数是 f(x) = a。exp (-bt) ^ c + d。(拉伸指数拟合)

我的编码是,

# Reading datas from file
data = np.genfromtxt('filename.csv', delimiter=',', skiprows=5)
x=data[:, 0]
y=data[:, 1]
# Fitting Streched Exponential Decay Curve
smoothx = np.linspace(x[0], x[-1], (5*x[-1]))
guess_a, guess_b, guess_c, guess_d = 4000, -0.005, 4, 4000
guess = [guess_a, guess_b, guess_c, guess_d]
f_theory1 = lambda t, a, b, c, d: a * np.exp((b*t)^(c)) + d
p, cov = curve_fit(f_theory1, x, y, p0=np.array(guess))
f_fit1 = lambda t: p[0] * np.exp((p[1] * t)^((p[2]))) + p[3]
plt.show()

在这里,我只展示了我的程序的猜测和拟合部分。

请纠正我的代码中的错误。提前致谢。

4

0 回答 0