Handlers¶
Contains the sample primitive and effectful utilities for dynestyx.
HandlesSelf
¶
Mixin class that allows an object to act as an interpretation and its own handler.
This is used by most inference and simulation objects in dynestyx, allowing them to provide
an object interpretation of the sample operation whilst still being used directly as a handler.
Note
This is unidiomatic for effectful code, but it simplifies our documentation and development process.
In particular, it is not straightforward to define a decorator that automates interpretation handling whilst keeping IDE-friendly docstrings.
sample(name: str, dynamics: DynamicalModel, *, obs_times: jax.Array, obs_values: jax.Array | None = None, ctrl_times: jax.Array | None = None, ctrl_values: jax.Array | None = None, **kwargs) -> FunctionOfTime
¶
Samples from a dynamical model. This is the main primitive of dynestyx.
The sample primitive is meant to mimic the numpyro.sample primitive in usage,
but using a DynamicalModel instead of a Distribution.
The sample method calls _sample_intp, which is defined as a defop in effectful.
This is where any real "work" is done, after input validation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name of the sample site. |
required |
dynamics
|
DynamicalModel
|
Dynamical model to sample from. |
required |
obs_times
|
Array
|
Times at which to sample the observations. |
required |
obs_values
|
Array | None
|
Values of the observations at the given times. |
None
|
ctrl_times
|
Array | None
|
Times at which to sample the controls. |
None
|
ctrl_values
|
Array | None
|
Values of the controls at the given times. |
None
|
**kwargs
|
Additional keyword arguments. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
FunctionOfTime |
FunctionOfTime
|
A function of time that samples from the dynamical model. |