非线性回归法

时间:2020-10-22 09:48:51

标签: python scipy

我有以下问题:

enter image description here

使用非线性回归方法确定方阱势模型?,?,?的势参数。

?= 2 / 3? 3 [1-(?3-1)(?? /??-1)]

import numpy 
from scipy.optimize import curve_fit
import pylab
Texp = [91,95,100,106,111,115,120,124,131,136,140,145,151,156,160,165,169,176,181,185,190]
Bexp = [-528.2,-472.2,-416.4,-364.2,-329.4,-305.9,-280.5,-262.8,-236.3,-220.1,-208.5,-195.3,-181.2,-170.7,-162.9,-154.0,-147.3,-136.6,-129.7,-124.5,
    -118.4]
k=1.381*10**-23
Na=6.02*10**23
x=Texp
y=Bexp
def squarewell(Temp,?,?,?):
    n=21
    B=numpy.zeros(n)
    for i in range(n):
        B[i]=2/3*numpy.pi*Na*?**3*(1-(?**3-1)*(numpy.e**(?/k/Temp[i])-1))
    return B


popt, pcov = curve_fit(squarewell,x,y)
yfit = squarewell(x,popt[0],popt[1],popt[2])
pylab.plot(x,y,'o',x,yfit)
pylab.xlabel('temperature')
pylab.ylabel('B')
pylab.show()
print('numerical values fo parameters ?,?,? :\n\n?=%f,?=%f,?=%f'%(popt[0],popt[1],popt[2]))`

运行时错误不断发生。我的解决方案有问题吗?

0 个答案:

没有答案