“”“ 将数学导入为m
将matplotlib.pyplot导入为plt
将numpy导入为np
从scipy.optimize导入cf。
Kuv = 1.1 * 10 **-4
w = 3.8
Cuv = 4.9
Cir = 5 * 10 ** 11
Kir = 48
data = np.genfromtxt('dataset1.csv',delimiter =',',dtype = float)
datax =数据[:,0]
datay =数据[:,1]
def func(X,A,B,Aa,Xa,Sa,A1,X1,S1,A2,X2,S2,A3,X3,S3,A4,X4,S4,A5,X5,S5):< / p>
返回(A * X **-4 + B)+ Kir np.exp(-Cir / X)+ Kuv w np.exp(Cuv / X)+ Aa < /em>np.exp(-(X-Xa)**2/2*Sa^2)+ A1 * np.exp(-(X-X1)** 2/2 * S1 ^ 2)+ A2 * np .exp(-(X-X2)^ 2/2 * S2 ^ 2)+ A3 * np.exp(-(X-X3)^ 2/2 * S3 ^ 2)+ A4 * np.exp(-(X -X4)^ 2/2 * S4 ^ 2)+ A5 * np.exp(-(X-X5)^ 2/2 * S5 ^ 2)
popt,pcov = cf(func,datax,datay)
plt.plot(datax,datay) plt.plot(datax,func(datax,* popt))