pymc.ode.DifferentialEquation#

class pymc.ode.DifferentialEquation(func, times, *, n_states, n_theta, t0=0)[source]#

Specify an ordinary differential equation

Due to the nature of the model (as well as included solvers), the process of ODE solution may perform slowly. A faster alternative library based on PyMC–sunode–has implemented Adams’ method and BDF (backward differentation formula). More information about sunode is available at: https://github.com/aseyboldt/sunode.

$\dfrac{dy}{dt} = f(y,t,p) \quad y(t_0) = y_0$
Parameters
funccallable()

Function specifying the differential equation. Must take arguments y (n_states,), t (scalar), p (n_theta,)

timesarray

Array of times at which to evaluate the solution of the differential equation.

n_statesint

Dimension of the differential equation. For scalar differential equations, n_states=1. For vector valued differential equations, n_states = number of differential equations in the system.

n_thetaint

Number of parameters in the differential equation.

t0float

Time corresponding to the initial condition

Examples

def odefunc(y, t, p):
#Logistic differential equation
return p[0] * y[0] * (1 - y[0])

times = np.arange(0.5, 5, 0.5)

ode_model = DifferentialEquation(func=odefunc, times=times, n_states=1, n_theta=1, t0=0)


Methods

 DifferentialEquation.L_op(inputs, outputs, ...) Construct a graph for the L-operator. DifferentialEquation.R_op(inputs, eval_points) Construct a graph for the R-operator. DifferentialEquation.__init__(func, times, ...) DifferentialEquation.add_tag_trace(thing[, ...]) Add tag.trace to a node or variable. Determine whether or not constant folding should be performed for the given node. Try to get parameters for the Op when Op.params_type is set to a ParamsType. DifferentialEquation.grad(inputs, output_grads) Construct a graph for the gradient with respect to each input variable. DifferentialEquation.infer_shape(fgraph, ...) DifferentialEquation.make_node(y0, theta) Construct an Apply node that represent the application of this operation to the given inputs. DifferentialEquation.make_py_thunk(node, ...) Make a Python thunk. DifferentialEquation.make_thunk(node, ...[, ...]) Create a thunk. DifferentialEquation.perform(node, ...) Calculate the function on the inputs and put the variables in the output storage. DifferentialEquation.prepare_node(node, ...) Make any special modifications that the Op needs before doing Op.make_thunk().

Attributes

 default_output An int that specifies which output Op.__call__() should return. destroy_map A dict that maps output indices to the input indices upon which they operate in-place. itypes otypes params_type view_map A dict that maps output indices to the input indices of which they are a view.