Safe Haskell | None |
---|---|

Language | Haskell2010 |

- type Rand = GenIO
- type Density a = a -> Double
- type Sample a = Rand -> IO a
- data Target a
- viewTarget :: Target a -> TargetView a
- newtype TargetView a = Target (Density a)
- makeTarget :: Density a -> Target a
- data Proposal a
- viewProposal :: Proposal a -> ProposalView a
- data ProposalView a = Proposal (Density a) (Sample a)
- makeProposal :: Density a -> Sample a -> Proposal a
- type Step x = Rand -> x -> IO x
- type Kernel x a = Target a -> (a -> Proposal a) -> Step x
- type Act x m a = x -> a -> m a
- data Action x m a b
- viewAction :: Action x m a b -> ActionView x m a b
- data ActionView x m a b = Action (Act x m a) (a -> m b) a
- makeAction :: Act x m a -> (a -> m b) -> a -> Action x m a b

# Targets and Proposals

The probability density function used in both target and proposal distributions. Given an input point, this method returns a probability density.

A procedure that, given a source of randomness, returns an action that produces a sample. The type itself is read as a verb, i.e, "to sample".

data Target a

The type for target distributions that can be used in any MCMC sampler.

HasDensity Target a | Get the probability density at a point for any target distribution. |

viewTarget :: Target a -> TargetView a

newtype TargetView a

makeTarget :: Density a -> Target a

Method for constructing custom target distributions.

Target distributions need only a density method.

data Proposal a

The type for proposal distributions that can be used in any MCMC sampler.

HasDensity Proposal a | Get the probability density at a point for any proposal distribution. |

viewProposal :: Proposal a -> ProposalView a

data ProposalView a

makeProposal :: Density a -> Sample a -> Proposal a

Method for constructing custom proposal distributions.

Proposal distributions need both a density and a sampling method.

# Transition kernels

type Step x = Rand -> x -> IO x

The type for one step in the random walk.
A value of type

is a function that takes a source of randomness and a
current state and returns an action producing a subsequent state.`Step`

a

type Kernel x a = Target a -> (a -> Proposal a) -> Step x

The type for MCMC transition kernels.

The input arguments are the target
distribution (to be modeled) and a *conditional* proposal distribution.

The result is a `Step`

that will make one move in the random walk based
on the current state.
In general, an MCMC kernel consists of using:

- the conditioned proposal to make a hypothesis move, and then
- the semantics of the specific
`Kernel`

at hand to either accept this hypothesis (and move to the new state), or reject the hypothesis (and stay at the current state).

Type parameter definitions:

`x`

- The kernel-state. This is the type for each state in the
*Markov chain*. `a`

- The distribution-state. This is the domain of the target distribution as well as the type of values sampled from the proposal distribution.

In general, we need different types to represent the kernel-state and
distribution-state because the
kernel-state may hold extra information that gets updated with each step.
Look at `simulatedAnnealing`

for
an example where `x`

differs from `a`

.

# Actions

type Act x m a = x -> a -> m a

data Action x m a b

Type parameter definitions:

`x`

- The kernel-state (see
`Kernel`

) `a`

- The action-state, specific to the action being performed
`m`

- The monad in which the action is performed
`b`

- The final returned state type

viewAction :: Action x m a b -> ActionView x m a b

data ActionView x m a b