Core modules#
Top-level API#
Sequential Monte Carlo driver#
Reconstruct a runner with SequentialMonteCarlo.from_config(smc.config).
This preserves runner settings and shares the referenced steps, callbacks, and
checkpoint writers. It does not clone mutable component state or resume a run;
use the checkpoint APIs to restore runtime state.
Particle state and results#
- class sequince.state.ParticleState(particles, log_weights=None, log_normalizing_constant=0.0, initial_ancestor_indices=None, evaluation=None, metadata=None)[source]#
Bases:
objectContainer 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:
- classmethod from_dict(payload)[source]#
Reconstruct a state from
to_dict()output.- Parameters:
- Return type:
- initial_ancestor_indices: Array#
- classmethod load(h5_file_or_group, path='state')[source]#
Load a built-in state from
pathin an open HDF5 handle.
- log_weights: Array#
- particles: Array#
- replace_particles(particles, *, evaluation=None, **updates)[source]#
Replace particles and explicitly provide their evaluation.
- Parameters:
particles (Array)
evaluation (TargetEvaluation | None)
updates (Any)
- Return type:
- resample(indices)[source]#
Return a resampled state using the provided ancestor indices.
- Parameters:
indices (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:
- 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:
- Return type:
- betas: Array#
- classmethod from_dict(payload)[source]#
Reconstruct a persistent state from
to_dict()output.- Parameters:
- Return type:
- classmethod from_state(state, *, beta, log_normalizing_constant)[source]#
Create a one-batch history from an active particle state.
- Parameters:
- Return type:
- log_normalizing_constants: Array#
- 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: