Exercise Numpy/Scipy

3. Parameter fitting

You have been provided with an experimenal time-course measurement of the X and Y species. The data has the form of a numpy array with the first column representing the experimental time (in seconds), column 2 the measurement of X (in mM) and column 3 Y.

  • modify the dSdt function from above, such that a parameter vector p$= [k1, k2, k3]$ can be passed in addition to S and t

  • define an objective function obj_fct( p, S_exp, t_exp ) which computes the squared distance between the experimental data and a model simulation for the parameters p$= [k1, k2, k3]$ for the time point vector t_exp (assume that the initial conditions are known and as defined above), (hint: additional arguments can be passed to the function integrated by scipy.optimize.odeint using the args = (p,) argument. Dont forget the comma in the tuple!

  • try to identify the parameters of the reaction system using this objective function and the sicipy.optimize.fmin minimization algorithm. Fit only parameters k2 and k3 and keep k1 at 1.5. Use the parameters given above as starting values.

  • plot a simulation of t


In [4]:
# Load experimental data 

import numpy as np
import scipy as sp
import pickle
import scipy.optimize
from matplotlib import pyplot as plt
plt.style.use('ggplot')
%matplotlib inline


experimental_data = pickle.load( open( "experimental_data.p", "rb" ) )
plt.plot( experimental_data[:,0], experimental_data[:,1:])


Out[4]:
[<matplotlib.lines.Line2D at 0x7f0f43ba9e10>,
 <matplotlib.lines.Line2D at 0x7f0f43ba9fd0>]

In [ ]: