How to solve ODEs with a parameter that changes over time.

79 Views Asked by At

I have the following coupled ODEs: $$ \begin{cases} \frac{dA}{dt} & = k_{1}\text{activity} - k_{2}A\\ \frac{dB}{dt} & = k_{3}A - k_{4}B \end{cases} $$ with $k_1 = 1.0, k_2 = 0.1, k_3 = 0.1, k_4 = 1$. The value of $\text{activity}$ changes over time and it can be randomly either $0$ or $1$. How can I solve it ? I am using the Python solve odeint.

P.S. In order to answer to the questions:

Could you closer specify what "changes randomly over time" means? And what are the desired results from the simulation of this stochastic process?

For each point of the time, activity can be either 0 or 1. For example, if time is between 0 and 100 or, said in Pythonic words time = np.linspace(0, 100, 100), activity is a numpy array that has the same length of time and with elements that are 0 or 1 (like array(0,0,0,1,1,1,...)).

As regards the desired results, I would like to obtain the trend of A and B over time in the situation that I have described.