我正在尝试将以下ODE模型与实验数据拟合: 当前,我正在使用emcee查找适合模型的参数。以下代码是使用scipy.odeint的ODE模型。
class IFFL:
def __init__(self, m_production, m_degradation, s_production,
s_degradation, ms_degradation, k_p, k_i, LacI):
self.m_production = m_production #mf-Lon
self.m_degradation = m_degradation
self.s_production = s_production #m-Scarlet
self.s_degradation = s_degradation
self.ms_degradation = ms_degradation #m-Scarlet degradation by mf-Lon
self.k_p = k_p #dissociation constant for LacI and pLac
self.k_i = k_i #dissociation constant for IPTG and LacI
self.LacI = LacI
self.IPTG = []
def inducer(self, T, P, D):
sw = np.zeros(len(T))
iterate = 0
sw[iterate] = 0
iterate += 1
while iterate < (len(T)):
for i in range(int(D)):
if iterate >= len(T):
return sw
sw[iterate] = 100000
iterate += 1
for i in range(int(P - D)):
if iterate >= len(T):
return sw
sw[iterate] = 0
iterate += 1
return sw
def model(self, z, t, IPTG):
x = z[0]
r = z[1]
dxdt = self.m_production/(1 + self.LacI/self.k_p/(1+(IPTG/self.k_i)**2)) - self.m_degradation*x #x dot
drdt = self.s_production/(1 + self.LacI/self.k_p/(1+(IPTG/self.k_i)**2)) - self.ms_degradation*(x**2/(x**2 + 1))*r - self.s_degradation*r #r dot
dzdt = [dxdt,drdt]
return dzdt
def runmodel(self, m, s, t, P, D):
z0 = [m,s]
self.IPTG = self.inducer(t, P, D)
print(self.IPTG)
mr = np.empty_like(t)
sr = np.empty_like(t)
mr[0] = z0[0]
sr[0] = z0[1]
for i in range(1, len(t)):
tspan = [t[i-1],t[i]]
z = odeint(self.model,z0,tspan,args = (self.IPTG[i],), full_output = 0)
mr[i] = z[1][0]/(self.m_production/self.m_degradation) #normalized
sr[i] = z[1][1]/(self.s_production/self.s_degradation)
z0 = z[1]
#plt.plot(mr, sr) #uncomment for solution trajectory
return [mr, sr]
长话短说,我有五个参数需要与实验数据拟合,这些参数是:
我尝试遵循emcee的代码,但是看来我需要“最佳猜测”参数值。我该如何解决这个问题?