Time dependent parameters in ODEs

I have read a related post but no solution was provided I believe because the question was not clear. I will try to explain clearly what I am asking here.
The point is that in the code you have to specify something like this:
dx_dt = x*theta[1]
But what if I know that the parameter theta[1] has different values at different time points?
For instance, let’s imagine I know that it has 2 different values, then I could use to 2 parameters doing something like this:
where k can be fixed or even another parameter.
Is this possible?


I believe what you propose is - at least technically - possible. Do you have any issues implementing it? I would however worry that if the derivative is not continuous at k, it could give the solver a hard time, so I would suggest that you interpolate smoothly between the values.

Does that make sense?

Also note that you can use backticks (`) to mark code in your post making it more legible - I’ve edited the post for you.

1 Like