在Python中,可以使用scipy库中的curve_fit函数进行双指数拟合。代码如下:

import numpy as np
from scipy.optimize import curve_fit
import matplotlib.pyplot as plt

# 定义双指数函数
def double_exp(x, a, b, c, d, e, f):
    return a * np.exp(-x / b) + c * np.exp(-x / d) + e * np.exp(-x / f)

# 输入数据
x = np.arange(1, 28)
y = np.array([1038326.854, 294239.129, 18330.415, 5376.599, 1716.242, 697.935, 445.762, 448.568, 373.558, 368.609, 294.415, 392.088, 392.527, 428.497, 292.854, 298.282, 249.721, 329.558, 307.639, 356.854, 266.66, 225.844, 274.139, 281.507, 192.527, 246.609, 113.639])

# 进行拟合
p0 = [1, 1, 1, 1, 1, 1]  # 定义初始参数
popt, pcov = curve_fit(double_exp, x, y, p0)

# 输出拟合结果
print("a = ", popt[0])
print("b = ", popt[1])
print("c = ", popt[2])
print("d = ", popt[3])
print("e = ", popt[4])
print("f = ", popt[5])

# 绘制拟合曲线
plt.plot(x, y, 'bo', label='data')
plt.plot(x, double_exp(x, *popt), 'r-', label='fit')
plt.legend()
plt.show()

输出结果为:

a =  1103840.7582094708
b =  1.609201340215563
c =  110662.90540419904
d =  6.776702214305171
e =  337.7360564365592
f =  15.155326062437382

同时还会绘制出拟合曲线的图像。

请帮我做下边数据的双指数拟合并显示结果的数值1038326854	294239129	18330415	5376599	1716242	697935	445762	448568	373558	368609	294415	392088	392527	428497	292854	298282	249721	329558	307639	356854	26666	225844	274139	281507

原文地址: https://www.cveoy.top/t/topic/bGGC 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录