sequince.steps.mutation.minipcn#
Attributes#
Classes#
MiniPCN results with block acceptance in |
|
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_stepcontains the backend’s accepted fraction per step.- acceptance_by_step: Any#
- 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.MutationStepRun 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
AdaptiveMiniPCNMutationfor tuning between fixed mutation blocks. The backendadaptive=Trueoption instead tunes rho inside sampling and cannot be combined with that wrapper.- Parameters:
log_prob_fn (collections.abc.Callable[..., sequince.typing.Array | float] | sequince.target.Target)
n_steps (int)
step_fn (str)
verbose (bool)
transform (sequince.transforms.ParticleTransform | None)
transform_refit (sequince.steps.mutation.base.TransformRefit)
store_chains (bool)
metrics (tuple[sequince.steps.mutation.metrics.MutationMetric, ...] | list[sequince.steps.mutation.metrics.MutationMetric])
- apply(state, context, rng)[source]#
- Parameters:
state (sequince.state.ParticleState)
context (sequince.steps.context.StepContext)
rng (orng.RandomGenerator)
- 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=Noneto 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
applyorapply_with_n_stepsfor a complete standalone block. RepeatedMutationStep uses this method to continue across rounds and finalizes metrics once after the complete block.- Parameters:
state (sequince.state.ParticleState)
context (sequince.steps.context.StepContext)
rng (orng.RandomGenerator)
n_steps (int)
mutation_state (sequince.steps.mutation.metrics.MutationStepState | None)
- 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:
state (sequince.state.ParticleState)
context (sequince.steps.context.StepContext)
random_state (Any)
- Return type:
tuple[sequince.state.ParticleState, sequince.steps.context.StepContext, Any, MiniPCNOutput]