Handlers¶
dynestyx is built using effectful, which operates using a primitive called a handler. The details of this can be abstracted away from the typical user experience, but impacts the implementation of the sample primitive. The long story short is that the basic implementation of sample is empty, and it is actually "interpreted" by context. For example,
with Filter(EKFConfig()):
dsx.sample("f", dynamical_model, obs_times=obs_times, obs_values=obs_values)
will implement the dsx.sample primitive using an extended Kalman filter. For more details, see the corresponding developer API page.
Contains the sample primitive and effectful utilities for dynestyx.
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. |