BarkerSampler¶
The Barker Metropolis-Hastings sampler is a useful fallback if HMC-type samplers (eg NUTS) diverge on some geometry, but will typically be slower, especially on high-dimensional problems.
The sampler trades robustness for speed by using a skewed proposal distribution according to the gradient of the log posterior. As such, this is a middle ground between classic Metropolis-Hastings and Hamiltonian Monte Carlo both in terms of sampling efficiency and sensitivity to bad geometry, but is mainly suitable for low to medium dimensional problems. The implementation is based on "The Barker proposal: combining robustness and efficiency in gradient-based MCMC" (2022). More Info... Version 1.0.0
Ports/Properties¶
mass_matrix_shape¶
The shape of the inverse mass matrix. Uncorrelated uses a simplifying diagonal approximation, while all-to-all uses a full-rank ("dense") mass matrix. The latter can in principle handle correlated posterior variables more efficiently, but there are tradeoffs in terms of compute cost and required samples for convergence. Block-diagonal mass matrices as in the other samplers are not currently supported.
- verbose name: Mass Matrix Shape
- default value: uncorrelated
- port type: EnumPort
- value type: str (can be None)
desired_accept_prob¶
The desired acceptance probability when performing step-size adaptation. The method will adjust the step size such that on average a step is accepted (within the posterior distribution) with this probability. Note that this is lower than in HMC due to the different sampling strategy. Typical values are 0.2-0.4 for high-dimensional problems and 0.4-0.7 for low-dimensional problems.
- verbose name: Desired Accept Prob
- default value: 0.4
- port type: FloatPort
- value type: float (can be None)
step_size¶
The initial step size used by the Barker proposal. This normally does not need to be touched unless step size adaptation is disabled, or the adaptation diverges immediately even when using conservative choices for the init strategy in the inference node. The step size is often tuned based on the desired acceptance probability of the sampler (see parameter above for guidance as to what constitutes a good acceptance rate).
- verbose name: Step Size
- default value: 1.0
- port type: FloatPort
- value type: float (can be None)
adapt_step_size¶
Whether to adapt the step size during warmup. This uses a dual averaging scheme.
- verbose name: Adapt Step Size
- default value: True
- port type: BoolPort
- value type: bool (can be None)
adapt_mass_matrix¶
Whether to adapt the mass matrix during warmup. This uses the Welford scheme.
- verbose name: Adapt Mass Matrix
- default value: True
- port type: BoolPort
- value type: bool (can be None)
set_breakpoint¶
Set a breakpoint on this node. If this is enabled, your debugger (if one is attached) will trigger a breakpoint.
- verbose name: Set Breakpoint (Debug Only)
- default value: False
- port type: BoolPort
- value type: bool (can be None)
metadata¶
User-definable meta-data associated with the node. Usually reserved for technical purposes.
- verbose name: Metadata
- default value: {}
- port type: DictPort
- value type: dict (can be None)