sequince.steps.mutation.blocked#

Blocked Metropolis-Hastings mutation kernels and steps.

Classes#

MetropolisBlock

Configuration for one Metropolis-within-Gibbs parameter block.

BlockedMetropolisHastingsMutation

Apply sequential Metropolis-Hastings updates to parameter blocks.

Module Contents#

class sequince.steps.mutation.blocked.MetropolisBlock[source]#

Configuration for one Metropolis-within-Gibbs parameter block.

name: str#
kernel: sequince.steps.mutation.kernels.MutationKernel | sequince.steps.mutation.metropolis.MutationKernelFactory#
n_steps: int = 1#
class sequince.steps.mutation.blocked.BlockedMetropolisHastingsMutation(log_prob_fn, blocks, *, transform=None, transform_refit='always', store_chains=False, metrics=())[source]#

Bases: sequince.steps.base.SMCStep

Apply sequential Metropolis-Hastings updates to parameter blocks.

Each block targets the complete log probability while its kernel changes only a subset of coordinates. The composition is therefore a valid Metropolis-within-Gibbs rejuvenation step.

Coordinate indices refer to the space in which the kernels operate. When a transform is supplied, it should preserve the requested block structure (for example, a coordinate-wise bounds transform rather than a dense whitening transform).

Example

>>> from sequince import steps, transforms
>>> from sequince.steps.mutation import kernels
>>> blocks = [
...     steps.mutation.MetropolisBlock(
...         name="block1",
...         kernel=kernels.AdaptiveMaskedGaussianRandomWalk(
...             indices=[0, 1],
...             scale=0.1,
...         ),
...         n_steps=2,
...     ),
...     steps.mutation.MetropolisBlock(
...         name="block2",
...         kernel=kernels.AdaptiveMaskedGaussianRandomWalk(
...             indices=[2, 3],
...             scale=0.2,
...         ),
...         n_steps=3,
...     ),
... ]
... step = steps.BlockedMetropolisHastingsMutation(
...     log_prob_fn=posterior.log_prob,
...     blocks=blocks,
... )
Parameters:
metrics#
apply(state, context, rng)[source]#
Parameters:
Return type:

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