sequince.steps.mutation.minipcn#

Attributes#

Classes#

MiniPCNOutput

MiniPCN results with block acceptance in metrics.acceptance.

MiniPCNMutation

Run MiniPCN MCMC moves to rejuvenate particles.

Module Contents#

sequince.steps.mutation.minipcn.logger#
class sequince.steps.mutation.minipcn.MiniPCNOutput[source]#

Bases: collections.abc.Mapping[str, Any]

MiniPCN results with block acceptance in metrics.acceptance.

acceptance_by_step contains the backend’s accepted fraction per step.

acceptance_by_step: Any#
step_fn: str#
steps: int#
chain: Any#
metrics: Any = None#
class sequince.steps.mutation.minipcn.MiniPCNMutation(log_prob_fn, *, n_steps=1, step_fn='tpcn', verbose=False, transform=None, transform_refit='always', store_chains=False, metrics=(), **kwargs)[source]#

Bases: sequince.steps.mutation.base.MutationStep

Run MiniPCN MCMC moves to rejuvenate particles.

By default uses the ‘tpcn’ step function and targets an acceptance rate of 0.234. Also sets ‘verbose’ to False by default.

Wrap with AdaptiveMiniPCNMutation for tuning between fixed mutation blocks. The backend adaptive=True option instead tunes rho inside sampling and cannot be combined with that wrapper.

Parameters:
apply(state, context, rng)[source]#
Parameters:
Return type:

tuple[sequince.state.ParticleState, sequince.steps.context.StepContext, MiniPCNOutput]

apply_with_mutation_state(state, context, rng, *, n_steps, mutation_state=None)[source]#

Run transitions within a block without finalizing metrics.

Pass mutation_state=None to initialize a new block; otherwise pass the state returned by the preceding call. The state holds individual metric states and cumulative acceptance bookkeeping. It must belong to the same metric configuration and mutation coordinate space.

Returns (state, context, output, mutation_state). The output’s metrics remain unset, including on the first and zero-step calls. Concrete mutations prepare existing metrics on entry, update state for each transition, and return it explicitly without calling metric.result(). Runtime state must never be stored on the mutation object.

Use apply or apply_with_n_steps for a complete standalone block. RepeatedMutationStep uses this method to continue across rounds and finalizes metrics once after the complete block.

Parameters:
Return type:

tuple[sequince.state.ParticleState, sequince.steps.context.StepContext, MiniPCNOutput, sequince.steps.mutation.metrics.MutationStepState | None]

apply_functional(state, context, random_state)[source]#

Run MiniPCN while explicitly threading backend random state.

Parameters:
Return type:

tuple[sequince.state.ParticleState, sequince.steps.context.StepContext, Any, MiniPCNOutput]