pymc.ode.DifferentialEquation#

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

指定一个常微分方程

由于模型的性质(以及包含的求解器),ODE 求解过程可能会执行得很慢。基于 PyMC 的替代库 sunode 实现了 Adams 方法和 BDF(向后微分公式)。有关 sunode 的更多信息,请访问:aseyboldt/sunode

\[\dfrac{dy}{dt} = f(y,t,p) \quad y(t_0) = y_0\]
参数:
funccallable()

指定微分方程的函数。必须接受参数 y (n_states,)、t (标量)、p (n_theta,)

times数组

用于评估微分方程解的时间数组。

n_statesint

微分方程的维度。对于标量微分方程,n_states=1。对于向量值微分方程,n_states = 系统中微分方程的数量。

n_thetaint

微分方程中的参数数量。

t0float

对应于初始条件的时间

示例

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)

方法

DifferentialEquation.L_op(inputs, outputs, ...)

为 L-算子构建一个图。

DifferentialEquation.R_op(inputs, eval_points)

为 R-operator 构建一个图。

DifferentialEquation.__init__(func, times, ...)

DifferentialEquation.add_tag_trace(thing[, ...])

为节点或变量添加 tag.trace。

DifferentialEquation.do_constant_folding(...)

确定是否应为给定节点执行常量折叠。

DifferentialEquation.get_params(node)

尝试在 Op.params_type 设置为 ParamsType 时获取 Op 的参数。

DifferentialEquation.grad(inputs, output_grads)

为每个输入变量构建梯度的图。

DifferentialEquation.infer_shape(fgraph, ...)

DifferentialEquation.make_node(y0, theta)

构建一个 Apply 节点,表示将此操作应用于给定的输入。

DifferentialEquation.make_py_thunk(node, ...)

生成一个 Python thunk。

DifferentialEquation.make_thunk(node, ...[, ...])

创建一个 thunk。

DifferentialEquation.perform(node, ...)

计算输入上的函数并将变量放入输出存储中。

DifferentialEquation.prepare_node(node, ...)

在对 Op.make_thunk() 进行操作之前,进行 Op 所需的任何特殊修改。

属性

default_output

一个 int ,指定 Op.__call__() 应该返回哪个输出。

destroy_map

一个 dict ,它将输出索引映射到它们就地操作的输入索引。

itypes

otypes

params_type

view_map

一个 dict ,它将输出索引映射到它们所视图的输入索引。