Skip to content

Derivatives

sim.function(...) and sim.sensitivity(...) (methods of the simulator) return these. See Gradients and sensitivities.

tenqsp.gradients.Function

The simulation as a JAX function of the numbers named in wrt (see the module docstring). f.names: what each entry of x is; f.x0: their values in the scenario; f(x): {output: array (n_t, ...)}; f.unpack(x): x by name; f.status(x): "ok" or why the run at x failed (outputs NaN); f.steps(x): the most solver steps of that run between two doses or events; f.derivatives: "forward", "reverse" or False.

f(x, rtol=..., atol=...) runs that call at other tolerances than the simulator's (for checking that the tolerance is tight enough), with no new build or compile; see _tolerances.

__call__(x, *, rtol=None, atol=None, max_steps=None, with_steps=False)

{output: array} at x; rtol, atol, max_steps: this call's (None: the simulator's). with_steps=True: (outputs, steps), steps as self.steps gives it, from the same run (traceable: inside jax.jit too).

status(x, *, rtol=None, atol=None, max_steps=None)

"ok", or why the run at x failed (its outputs are NaN).

steps(x, *, rtol=None, atol=None, max_steps=None)

The most solver steps that the run of f(x) takes between two doses or events: the simulator's max_steps is a limit on this number. Counted also when the run fails. For setting max_steps from the work a run takes at reasonable values.

unpack(x)

x by name.

tenqsp.gradients.Sensitivity

d output / d each name in wrt at every output time, at the scenario's values: s["conc"]["CL"] (shape (n_t, ...)), s.t, s.values["conc"] (the outputs), s.table() (a pandas DataFrame). With relative=True each is d y / d theta x theta / y ("% change per % change"), NaN where y is 0.

table()

One row per output time, one column per (output, name): outputs with one value per time (an output over axes is in s[output]).