sequince.steps.mutation.emcee#
Attributes#
Classes#
Run emcee ensemble MCMC moves to rejuvenate particles. |
Functions#
|
Construct a named emcee move. |
|
Resolve an emcee move object, named move, preset, or weighted schedule. |
Module Contents#
- sequince.steps.mutation.emcee.logger#
- sequince.steps.mutation.emcee.EMCEE_MOVES#
- sequince.steps.mutation.emcee.get_emcee_move(name, **kwargs)[source]#
Construct a named emcee move.
- Parameters:
name (str)
kwargs (Any)
- Return type:
Any
- sequince.steps.mutation.emcee.resolve_emcee_moves(spec)[source]#
Resolve an emcee move object, named move, preset, or weighted schedule.
- Parameters:
spec (Any)
- Return type:
Any
- class sequince.steps.mutation.emcee.EmceeMutation(log_prob_fn, *, n_steps=1, move=None, run_kwargs=None, transform=None, transform_refit='always', store_chains=False, metrics=(), **kwargs)[source]#
Bases:
sequince.steps.mutation.base.MutationStepRun emcee ensemble MCMC moves to rejuvenate particles.
Transforms requiring walker-specific auxiliary data are currently unsupported. emcee evaluates internally selected walker subsets, but its standard log-probability callback does not expose the original walker selection or context. Such auxiliary is rejected because Sequince cannot guarantee that the correct entry would be supplied to each walker.
- Parameters:
log_prob_fn (Callable[..., sequince.typing.Array | float] | sequince.target.Target) – Function to compute the log-probability of a particle position, or a Target instance.
n_steps (int) – Number of emcee steps to perform.
move (Any) – An emcee Move instance, named move configuration, weighted move list, or preset to use for proposing new positions. If
None(default), usesStretchMove.run_kwargs (dict[str, Any] | None) – Additional keyword arguments to pass to the
emcee.EnsembleSampler.run_mcmcmethod.transform (sequince.transforms.ParticleTransform | None) – A ParticleTransform instance to apply to the particles before mutation.
store_chains (bool) – Whether to store the entire mutation chain in the metadata. Default is False.
**kwargs – Additional keyword arguments to pass to the
emcee.EnsembleSamplertransform_refit (sequince.steps.mutation.base.TransformRefit)
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, dict[str, object]]
- 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, dict[str, object], sequince.steps.mutation.metrics.MutationStepState | None]