mcmc-samplers-0.1.1.1: Combinators for MCMC sampling

Safe HaskellNone
LanguageHaskell2010

MCMC.Combinators

Contents

Synopsis

Target combinators

mixTargets :: HasDensity t a => [(t a, Double)] -> Target a

Create a mixture target distribution from a list of distribution-weight pairs.

The input distributions can be of any type in the HasDensity class, which includes Proposal and Target. The output is a Target containing a Density.

The input weights are meant to be relative, not required to be normalized.

Proposal combinators

mixProposals :: [(Proposal a, Double)] -> Proposal a

Create a mixture proposal distribution from a list of distribution-weight pairs.

The input weights are meant to be relative, not required to be normalized.

chooseProposal :: Int -> (Int -> Proposal a) -> Proposal a

Create a uniform mixture of proposals based on the mapping function. The first argument is the total number of proposals in the mixture.

This is a convenience function for cases where there are a large number of index-based proposals (such as the case where there is a unique proposal for updating each dimension in a high-dimensional state).

mixCondProposals :: [(a -> Proposal a, Double)] -> a -> Proposal a

Create a mixture of conditional proposal distributions. The result is a mixture of proposal distributions that are all conditioned on the same starting state.

The input weights are meant to be relative, not required to be normalized.

updateNth

Arguments

:: Eq a 
=> Int

The dimension index

-> (a -> Proposal a)

A conditional proposal to focus on that dimension

-> [a] -> Proposal [a]

A conditional proposal that updates only one dimension

Update the nth dimension of a multi-dimensioanl state represented using a list.

updateBlock

Arguments

:: Eq a 
=> Int

The start dimension of the block

-> Int

The end dimension of the block

-> ([a] -> Proposal [a])

A conditional proposal to focus on the block

-> [a] -> Proposal [a]

A conditional proposal that updates only that block

Update a contiguous block of dimensions of a multi-dimensional state represented using a list.

updateFirst

Arguments

:: Eq b 
=> (a -> Proposal a)

A conditional proposal to focus on the first element

-> (a, b) -> Proposal (a, b) 

Update the first element of a multi-dimensional state represented as a tuple.

updateSecond

Arguments

:: Eq a 
=> (b -> Proposal b) 
-> (a, b) -> Proposal (a, b)

A conditional proposal to focus on the second element

Update the second element of a multi-dimensional state represented as a tuple.

Step combinators

mixSteps :: [(Step x, Double)] -> Step x

Create a mixture Step, representing a categorical distribution over multiple inference procedures.

The input weights are meant to be relative, not required to be normalized.

chooseStep

Arguments

:: Int

The total number of Steps in the mixture

-> (Int -> Target a)

The mapping function over targets

-> (Int -> a -> Proposal a)

The mapping function over conditional proposals

-> Kernel x a

The transition kernel to use across all Steps

-> Step x

The mixture step

The analogue of chooseProposal, to use a specific Step for each dimension of a multi-dimensional state.

The same Kernel value is used for creating each Step in the mixture.

cycleStep :: Kernel x a -> Target a -> [a -> Proposal a] -> Step x

Create a cycled transition kernel. This combinator applies the provided transition kernel to the target, and to the conditional proposals in the order that they appear in the list. Each application generates an intermediate state that is passed to the next conditional proposal in the list.

Action combinators

execute :: Monad m => Action x m a b -> x -> m (Action x m a b)

Execute the action once, given the current state in the Markov chain.

every :: Monad m => Int -> Action x m a b -> Action x m (a, Int) b

Execute the action once every n times, where n is the first argument.