# ODE¶

This submodule contains tools used to perform inference on ordinary differential equations.

class pymc3.ode.DifferentialEquation(func, times, *, n_states, n_theta, t0=0)

Specify an ordinary differential equation

$\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)

make_node(self, y0, theta)

Create a “apply” nodes for the inputs in that order.

perform(self, node, inputs_storage, output_storage)

Required: Calculate the function on the inputs and put the variables in the output storage. Return None.

Parameters
nodeApply instance

Contains the symbolic inputs and outputs.

inputslist

Sequence of inputs (immutable).

output_storagelist

List of mutable 1-element lists (do not change the length of these lists)

Raises
MethodNotDefined

The subclass does not override this method.

Notes

The output_storage list might contain data. If an element of output_storage is not None, it has to be of the right type, for instance, for a TensorVariable, it has to be a Numpy ndarray, with the right number of dimensions, and the correct dtype. Its shape and stride pattern, can be arbitrary. It not is guaranteed that it was produced by a previous call to impl. It could be allocated by another Op impl is free to reuse it as it sees fit, or to discard it and allocate new memory.