compounded.sampler: Build a sampler from transition functions

Description Usage Arguments Details Value See Also

View source: R/00dist-util.R


Defines a probability distribution object for use with compare.samplers.


compounded.sampler(step.functions, name, name.expr=NULL)



A list of transition functions; see details.


A character string naming the sampler.


A character string naming the sampler in plotmath notation.


compounded.sampler builds an MCMC sampler following the conventions of compare.samplers from a list of transition functions. The returned sampler has four arguments: target.dist, x0, sample.size, and limit. Further arguments, including the standard argument tuning, are passed to every transition function. The first three arguments transition functions are passed are target.dist, a vector state x to transition from, and the log density at that state, y. They should return a list containing four elements: x, y, evals, and grads. x is the state transitioned to, y is the log density at that state, and evals and grads are the number of log density and gradient calls made in that transition.

Each MCMC iteration, the first transition function is called with the current state of the chain. The state it returns is passed to the second transition function, whose returned state is passed to the third, and so on. The state returned by the final transition function is taken to be the state of the chain as a whole at the end of the iteration.

This way, transition functions that provide complementary features, such as fast mixing in different coordinates, can be combined without modifying their internal structure. The transition_fn interface provides a similar mechanism for samplers implemented in C. It is documented in the vignette, “R/C Glue in SamplerCompare”.


A sampler function.

See Also


SamplerCompare documentation built on Oct. 22, 2021, 9:14 a.m.