RWKernel#

class liesel.goose.rw.RWKernel(position_keys, initial_step_size=1.0, da_target_accept=0.234, da_gamma=0.05, da_kappa=0.75, da_t0=10)[source]#

Bases: liesel.goose.kernel.ModelMixin, liesel.goose.kernel.TransitionMixin[liesel.goose.rw.RWKernelState, liesel.goose.kernel.DefaultTransitionInfo]

A random walk kernel.

Uses Gaussian proposals, Metropolis-Hastings correction and dual averaging. Implements the Kernel protocol.

The kernel uses a default Metropolis-Hastings target acceptance probability of 0.234, which is optimal for a random walk sampler (in a certain sense). See Gelman et al. (1997) Weak convergence and optimal scaling of random walk Metropolis algorithms: https://doi.org/10.1214/aoap/1034625254.

Methods

end_epoch(prng_key, kernel_state, ...)

Sets the step size as found by the dual averaging algorithm.

end_warmup(prng_key, kernel_state, ...)

Currently does nothing.

has_model()

Whether the model interface is set.

init_state(prng_key, model_state)

Initializes the kernel state.

log_prob_fn(model_state)

Returns the log-probability function with the position as the only argument.

position(model_state)

Extracts the position from a model state.

set_model(model)

Sets the model interface.

start_epoch(prng_key, kernel_state, ...)

Resets the state of the dual averaging algorithm.

transition(prng_key, kernel_state, ...)

Handles one transition.

tune(prng_key, kernel_state, model_state, epoch)

Currently does nothing.

Attributes

error_book

Dict of error codes and their meaning.

identifier

Kernel identifier, set by EngineBuilder

model

Returns the model interface if it is set.

needs_history

Whether this kernel needs its history for tuning.

position_keys

Tuple of position keys handled by this kernel.