affine-invariant-ensemble-mcmc-0.1.0.0: General-purpose sampling

Safe HaskellSafe-Infered

Numeric.MCMC.AffineInvariantEnsemble

Contents

Description

A Haskell implementation of Goodman & Weare (2010)'s affine invariant ensemble MCMC, a family of Markov Chain Monte Carlo methods that can efficiently sample from highly skewed or anisotropic distributions.

See runChain for an overview of use, and http://msp.berkeley.edu/camcos/2010/5-1/p04.xhtml for details of the general sampling routine.

Synopsis

Data structures

data Config Source

A data type holding the configuration of the Markov chain at any given epoch. ensemble accesses the IntMap constituting the current ensemble, while accepts records the number of proposals that have been accepted up to the current epoch.

Constructors

Config 

Fields

ensemble :: !(IntMap [Double])
 
accepts :: !Int
 

data AffineTransform a Source

A data type representing the affine transformation to be used on particles in an ensemble. The general-purpose stretch and walk transformations described in Goodman and Weare (2010) are supported.

Constructors

Stretch 
Walk a 

Instances

data Trace a Source

A data type holding a chain's trace.

Instances

Chain management

runChain :: Vector v Word32 => Int -> ([Double] -> Double) -> Config -> v Word32 -> AffineTransform Int -> (Config, Trace Double)Source

Typical use:

   runChain steps target initConfig seed xform

Run the Markov chain for steps epochs. The chain will wander over target's parameter space such that, after "long enough", the points it visits will effectively be independent samples from the distribution proportional to target. The Markov chain procedes by possibly applying an affine transformation to each of the particles contained in ensemble initConfig, sequentially.

This function will return a tuple contanining 1) the Config corresponding to the final epoch of the chain, and 2) the chain's Trace. The Trace can be used, for example, to approximate integrals of the target function.

The target must be a function with type [Double] -> Double. Functions using more complicated data structures internally can simply be curried to this type.

Examples of use can be found at http://github.com/jtobin/affine-invariant-ensemble-mcmc/Numeric/MCMC/Examples.

initializeEnsemble :: PrimMonad m => Int -> Int -> m ConfigSource

Naively initialize an ensemble. Creates a Config containing nw walkers, each of dimension nd, and initializes accepts at 0. Each dimensional element is drawn randomly from (0,1] (using a different seed than defaultSeed).

If this is expected to be a region of low density, you'll probably want to specify your own initial configuration.

defaultSeed :: Vector Word32Source

The default seed provided by the library. This seed is different from the one used internally in initializeEnsemble.

prune :: Int -> Trace Double -> Trace DoubleSource

Prune some initial epochs (i.e. suspected burn-in) from a Trace.