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: aseyboldt/sunode.
\[\dfrac{dy}{dt} = f(y,t,p) \quad y(t_0) = y_0\]- Parameters:
- func
callable() Function specifying the differential equation. Must take arguments y (n_states,), t (scalar), p (n_theta,)
- times
array Array of times at which to evaluate the solution of the differential equation.
- n_states
int 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_theta
int Number of parameters in the differential equation.
- t0
float Time corresponding to the initial condition
- func
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.
DifferentialEquation.grad(inputs, output_grads)Construct a graph for the gradient with respect to each input variable.
DifferentialEquation.infer_shape(fgraph, ...)Try to return a version of self that tries to inplace in as many as allowed_inplace_inputs.
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_outputAn
intthat specifies which outputOp.__call__()should return.destroy_mapA
dictthat maps output indices to the input indices upon which they operate in-place.itypesotypesview_mapA
dictthat maps output indices to the input indices of which they are a view.