sequince.steps.waste_free#
Waste-free resampling and chain retention around an existing mutation.
Classes#
Resample chain starts and retain a wrapped mutation's full chains. |
Module Contents#
- class sequince.steps.waste_free.WasteFreeResampleMove(mutation, *, chain_length)[source]#
Bases:
sequince.steps.base.SMCStepResample chain starts and retain a wrapped mutation’s full chains.
Implements the resampling and chain-retention portion of Algorithm 2 of Dau and Chopin [1]. With N particles and chain length P, resample M=N/P starts using the input weights, run P-1 transitions and keep all P states per chain. Starts and repeated states after rejection are retained. No further resampling occurs inside this step; the output has N uniform weights and preserves the input evidence estimate.
- Parameters:
mutation (sequince.steps.mutation.MutationStep) – A MutationStep supporting apply_with_n_steps() and stored chains, such as MetropolisHastingsMutation, BlackJAXMutation or MiniPCNMutation. It owns the target, proposal, transforms and transition logic. One complete block of P-1 steps is requested, overriding its default n_steps for this call only. Chain storage is temporarily enabled and its previous setting restored even if mutation fails.
chain_length (int) – Number P of retained states per chain, INCLUDING the start. Must be a positive integer dividing N. P=1 only resamples; mutation is not called.
Examples
With 1000 input particles, run 20 chains with 50 retained states each:
>>> mutation = MetropolisHastingsMutation(target, GaussianRandomWalk(0.5)) >>> step = WasteFreeResampleMove(mutation, chain_length=50)
References
- mutation: sequince.steps.mutation.MutationStep#
- apply(state, context, rng)[source]#
- Parameters:
state (sequince.state.ParticleState)
context (sequince.steps.base.StepContext)
rng (orng.RandomGenerator)
- Return type:
tuple[sequince.state.ParticleState, sequince.steps.base.StepContext, dict[str, Any]]
- load_state_dict(state)[source]#
Restore the wrapped mutation’s checkpoint state.
- Parameters:
state (collections.abc.Mapping[str, Any])
- Return type:
None