superstats.transition.deterministic#
Deterministic transition models for latent time-varying parameters.
- class superstats.transition.deterministic.DeterministicTransition(bounds=None, initial_prior=None)[source]#
Bases:
ABCBase class for deterministic transition models.
Subclasses implement deterministic dynamics for a single scalar latent parameter. Subclasses must implement sample to generate complete trajectories from resolved parameter values.
- Parameters:
- bounds
tupleornp.ndarrayorNone,optional, default:None Lower and upper bounds for the latent state, applied via scaled_sigmoid. Falls back to DEFAULT_BOUNDS if not provided.
- initial_prior
PriororNone,optional, default:None Prior used to draw the initial latent state. Falls back to DEFAULT_INITIAL_PRIOR if not provided.
- bounds
- Attributes:
- bounds
np.ndarray Resolved lower and upper bounds for the latent state.
- initial_prior
Prior Resolved prior used to draw initial latent states.
- hyper_specs
dict Mapping from parameter names to either a Prior (sampled per batch), a scalar fixed value, or None to use a deterministic default. Subclasses populate this mapping.
- transition_name
str Short model name, such as
"linear".
- bounds
- Parameters:
- dtype#
alias of
float32
- abstract sample(batch_size, num_steps)[source]#
Generate batch_size latent trajectories of length num_steps.
- Parameters:
- Returns:
- result
dict-dictionarywithkeysdeterministic_params, hyper_params, and fixed_params. deterministic_params is an ndarray of shape (batch_size, steps).
- result
- Parameters:
- Return type:
- sample_from_parameters(params, batch_size, num_steps)[source]#
Generate trajectories from already-resolved transition parameters.
Subclasses used with posterior predictive resimulation should override this method.
paramscontains the subclass’s own hyperparameter names, independent of any name used by aJointPrior.
- class superstats.transition.deterministic.Linear(bounds=None, intercept=None, beta=None, normalize_steps=True)[source]#
Bases:
DeterministicTransitionDeterministic linear transition with an intercept and slope.
- Parameters:
- boundssequence
oftwofloatsorNone,optional, default:None Lower and upper bounds for the deterministic trajectory. Tuples and lists are accepted.
- intercept
float,Prior,orNone,optional, default:None Starting value of the trajectory. A Prior samples one intercept per trajectory; None uses the deterministic default prior.
- beta
float,Prior,orNone,optional, default:None Change across the trajectory when normalize_steps=True. A Prior samples one slope per trajectory; None uses the deterministic default prior.
- normalize_stepsbool,
optional, default:True If True, use a time axis from 0 to 1. If False, use integer step indices, so the slope is applied at every step.
- boundssequence
- Parameters:
Notes
The sample method returns a dict with keys deterministic_params, hyper_params, and fixed_params. Trajectory values are clipped to bounds.
- sample_from_parameters(params, batch_size, num_steps)[source]#
Generate trajectories from already-resolved transition parameters.
Subclasses used with posterior predictive resimulation should override this method.
paramscontains the subclass’s own hyperparameter names, independent of any name used by aJointPrior.
- class superstats.transition.deterministic.Polynomial(bounds=None, intercept=None, betas=None, degree=2, normalize_steps=True)[source]#
Bases:
DeterministicTransitionDeterministic polynomial transition with an intercept and beta weights.
- Parameters:
- boundssequence
oftwofloatsorNone,optional, default:None Lower and upper bounds for the deterministic trajectory. Tuples and lists are accepted.
- intercept
float,Prior,orNone,optional, default:None Constant term of the polynomial. A Prior samples one intercept per trajectory; None uses the deterministic default prior.
- betas
float,Prior, sequenceoffloat/Prior/None,orNone Polynomial coefficients for the non-constant terms. If a single scalar or Prior is provided, the same specification is used for every beta. If a sequence is provided, it must have length degree and each element is used for the corresponding beta weight.
- degree
int,optional, default: 2 Number of polynomial terms beyond the intercept. For example, degree=1 reproduces a linear model, while the default degree=2 gives a quadratic model.
- normalize_stepsbool,
optional, default:True If True, use a time axis from 0 to 1. If False, use integer step indices, so higher-order terms are evaluated on raw step numbers.
- boundssequence
- Parameters:
Notes
The sample method returns a dict with keys deterministic_params, hyper_params, and fixed_params. Trajectory values are clipped to bounds.
Modules
Base interface and shared helpers for deterministic transitions. |
|
Linear deterministic transition. |
|
Polynomial deterministic transition. |