sequince.state#
Classes#
Container for particle locations, log weights, and auxiliary information. |
|
Equal-sized particle batches retained from historical targets. |
Functions#
|
Return normalized log weights and their array scalar normalizer. |
Module Contents#
- sequince.state.normalize_log_weights(log_weights, *, xp=None)[source]#
Return normalized log weights and their array scalar normalizer.
- Parameters:
log_weights (Any)
xp (Any | None)
- class sequince.state.ParticleState(particles, log_weights=None, log_normalizing_constant=0.0, initial_ancestor_indices=None, evaluation=None, metadata=None)[source]#
Container for particle locations, log weights, and auxiliary information.
log_normalizing_constantis the accumulated estimate oflog Zfor the SMC target sequence. For Bayesian posterior SMC this is the log evidence; for particle filtering it is the log marginal likelihood of the observation sequence.- Parameters:
particles (sequince.typing.Array)
log_weights (sequince.typing.Array | numbers.Real | None)
log_normalizing_constant (float)
initial_ancestor_indices (sequince.typing.Array | None)
evaluation (sequince.target.TargetEvaluation | None)
metadata (MutableMapping[str, Any] | None)
- particles: sequince.typing.Array#
- log_weights: sequince.typing.Array#
- initial_ancestor_indices: sequince.typing.Array#
- evaluation: sequince.target.TargetEvaluation | None = None#
- property weights: sequince.typing.Array#
Return normalized weights.
- Return type:
sequince.typing.Array
- with_updates(**kwargs)[source]#
Return a copy of the state with selective updates applied.
- Parameters:
kwargs (Any)
- Return type:
- replace_particles(particles, *, evaluation=None, **updates)[source]#
Replace particles and explicitly provide their evaluation.
- Parameters:
particles (sequince.typing.Array)
evaluation (sequince.target.TargetEvaluation | None)
updates (Any)
- Return type:
- resample(indices)[source]#
Return a resampled state using the provided ancestor indices.
- Parameters:
indices (sequince.typing.Array)
- Return type:
- classmethod from_dict(payload)[source]#
Reconstruct a state from
to_dict()output.- Parameters:
payload (collections.abc.Mapping[str, Any])
- Return type:
- class sequince.state.PersistentParticleState(particles, betas, log_normalizing_constants, batch_size, *, log_weights=None, log_normalizing_constant=None, initial_ancestor_indices=None, evaluation=None, metadata=None)[source]#
Bases:
ParticleStateEqual-sized particle batches retained from historical targets.
log_normalizing_constantscontains normalizing-constant estimates for targets which generated archived batches. The scalarlog_normalizing_constantfollows the ordinaryParticleStateinterface and may instead describe a new target toward which the archive has just been weighted.- Parameters:
particles (sequince.typing.Array)
betas (sequince.typing.ArrayLike)
log_normalizing_constants (sequince.typing.ArrayLike)
batch_size (int)
log_weights (sequince.typing.Array | None)
log_normalizing_constant (Any | None)
initial_ancestor_indices (sequince.typing.Array | None)
evaluation (sequince.target.TargetEvaluation | None)
metadata (MutableMapping[str, Any] | None)
- betas: sequince.typing.Array#
- log_normalizing_constants: sequince.typing.Array#
- property log_evidences: sequince.typing.Array#
Alias for
log_normalizing_constants.- Return type:
sequince.typing.Array
- classmethod from_state(state, *, beta, log_normalizing_constant)[source]#
Create a one-batch history from an active particle state.
- Parameters:
state (ParticleState)
beta (sequince.typing.ArrayLike)
log_normalizing_constant (sequince.typing.ArrayLike)
- Return type:
- with_updates(**kwargs)[source]#
Return a copy with non-structural fields updated.
Historical particles and their batch metadata can only change through
append(). Persistent weighting steps may updatelog_weights; callers may also replace compatible evaluations or metadata.- Parameters:
kwargs (Any)
- Return type:
- append(state, *, beta, log_normalizing_constant)[source]#
Return a new history with one equal-sized batch appended.
Ancestor indices are concatenated without offsets because every batch retains its genealogy relative to the same initial active population.
- Parameters:
state (ParticleState)
beta (sequince.typing.ArrayLike)
log_normalizing_constant (sequince.typing.ArrayLike)
- Return type:
- classmethod from_dict(payload)[source]#
Reconstruct a persistent state from
to_dict()output.- Parameters:
payload (collections.abc.Mapping[str, Any])
- Return type: