Time dependant ODE parameters / functions

I got a bit lost at the part where you defined

    # Interpolate to find value of each input at time t
   input1 = np.interp(t, time_data, influent[:,2])

For my time-varying that worked within the DifferentialEquation function of PyMC , I defined several parameters in this way:

from pymc.ode import DifferentialEquation

def ode_model(state,t,params): 
     I_W_prime = I_Wa -   b(t,q = b_k)*I_W

mcmc_ode = DifferentialEquation(
    func=ode_model,
    times=tspan,
    n_states=...,
    n_theta=...,
    t0=t0
)

In this case, b(t,k=b_k) is time-varying. It is a partial function, which is define in this way:

from functools import partial
import numpy as np

def Logisticfunc(t,  q, t0 = 0):
    return 1 / (1 + np.exp(-q * (t - t0)))

b = partial(Logisticfunc, q=10.2)

Because it is a Python’s partial function, it is only evaluated when PyMC called this b(t) within the ode_model. The b_k is a parameter and go to params of def ode_model(state,t,params):