Build a sampler from transition functions

Share:

Description

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

Usage

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

Arguments

step.functions

A list of transition functions; see details.

name

A character string naming the sampler.

name.expr

A character string naming the sampler in plotmath notation.

Details

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”.

Value

A sampler function.

See Also

compare.samplers

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.