pymc.step_methods.BinaryMetropolis#

class pymc.step_methods.BinaryMetropolis(*args, **kwargs)[source]#

Metropolis-Hastings optimized for binary variables.

Unlike BinaryGibbsMetropolis, this step sampler proposes an update for all variable dimensions at once.

This will perform a single logp evaluation per step, at the expense of a lower acceptance rate when the posteriors of the binary variables are highly correlated.

The BinaryGibbsMetropolis (not this one) is the default step sampler for binary variables

Parameters:
vars: list

List of value variables for sampler

scaling: scalar or array

Initial scale factor for proposal. Defaults to 1.

tune: bool

Flag for tuning. Defaults to True.

tune_interval: int

The frequency of tuning. Defaults to 100 iterations.

model: PyMC Model

Optional model for sampling step. Defaults to None (taken from context).

rng: RandomGenerator

An object that can produce be used to produce the step method’s Generator object. Refer to pymc.util.get_random_generator() for more information.

Methods

BinaryMetropolis.__init__(vars, *[, ...])

BinaryMetropolis.astep(apoint, *args)

Perform a single sample step in a raveled and concatenated parameter space.

BinaryMetropolis.competence(var)

BinaryMetropolis is only suitable for binary (bool) and Categorical variables with k=1.

BinaryMetropolis.set_rng(rng)

BinaryMetropolis.step(point)

Perform a single step of the sampler.

BinaryMetropolis.stop_tuning()

Attributes

name

sampling_state

stats_dtypes

A list containing <=1 dictionary that maps stat names to dtypes.

stats_dtypes_shapes

Maps stat names to dtypes and shapes.

vars

Variables that the step method is assigned to.