Safe Haskell | Safe-Infered |
---|
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.
- data Config = Config {}
- data AffineTransform a
- data Trace a
- runChain :: Vector v Word32 => Int -> ([Double] -> Double) -> Config -> v Word32 -> AffineTransform Int -> (Config, Trace Double)
- initializeEnsemble :: PrimMonad m => Int -> Int -> m Config
- defaultSeed :: Vector Word32
- prune :: Int -> Trace Double -> Trace Double
Data structures
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.
Eq a => Eq (AffineTransform a) | |
Read a => Read (AffineTransform a) |
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
.