README.md (2000B)
1 # flat-mcmc 2 3 [![Hackage Version](https://img.shields.io/hackage/v/flat-mcmc.svg)](http://hackage.haskell.org/package/flat-mcmc) 4 [![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/jtobin/flat-mcmc/blob/master/LICENSE) 5 6 *flat-mcmc* is a Haskell library for painless, efficient, general-purpose 7 sampling from continuous distributions. 8 9 *flat-mcmc* uses an ensemble sampler that is invariant to affine 10 transformations of space. It wanders a target probability distribution's 11 parameter space as if it had been "flattened" or "unstretched" in some sense, 12 allowing many particles to explore it locally and in parallel. 13 14 In general this sampler is useful when you want decent performance without 15 dealing with any tuning parameters or local proposal distributions. Check out 16 the paper describing the algorithm 17 [here](http://msp.org/camcos/2010/5-1/camcos-v5-n1-p04-p.pdf), and a paper on 18 some potential limitations [here](http://arxiv.org/abs/1509.02230), authored 19 by my friends David Huijser and [Brendon 20 Brewer](https://www.stat.auckland.ac.nz/~brewer/). There is also also a robust 21 Python implementation [here](http://dan.iel.fm/emcee/current/) authored by [Dan 22 Foreman-Mackey](http://dan.iel.fm), a very nice dude who I once moved some 23 furniture with. 24 25 *flat-mcmc* exports an 'mcmc' function that prints a trace to stdout, as well 26 as a 'flat' transition operator that can be used more generally. 27 28 ``` haskell 29 import Numeric.MCMC.Flat 30 import qualified Data.Vector.Unboxed as U (unsafeIndex) 31 32 rosenbrock :: Particle -> Double 33 rosenbrock xs = negate (5 * (x1 - x0 ^ 2) ^ 2 + 0.05 * (1 - x0) ^ 2) where 34 x0 = U.unsafeIndex xs 0 35 x1 = U.unsafeIndex xs 1 36 37 origin :: Ensemble 38 origin = ensemble [ 39 particle [negate 1.0, negate 1.0] 40 , particle [negate 1.0, 1.0] 41 , particle [1.0, negate 1.0] 42 , particle [1.0, 1.0] 43 ] 44 45 main :: IO () 46 main = withSystemRandom . asGenIO $ mcmc 12500 origin rosenbrock 47 ``` 48 49 ![trace](http://jtobin.ca/flat-mcmc/img/Rosenbrock_AIE.png) 50