README.md (1265B)
1 # speedy-slice 2 3 Speedy slice sampling, as per [Neal, 2003](http://people.ee.duke.edu/~lcarin/slice.pdf). 4 5 This implementation of the slice sampling algorithm uses `lens` as a means to 6 operate over generic indexed traversable functors, so you can expect it to 7 work if your target function takes a list, vector, map, sequence, etc. as its 8 argument. 9 10 Additionally you can sample over anything that's an instance of both `Num` and 11 `Variate`, which is useful in the case of discrete parameters. 12 13 Exports a `mcmc` function that prints a trace to stdout, a `chain` function for 14 working with results in memory, and a `slice` transition operator that can be 15 used more generally. 16 17 import Numeric.MCMC.Slice 18 import Data.Sequence (Seq, index, fromList) 19 20 bnn :: Seq Double -> Double 21 bnn xs = -0.5 * (x0 ^ 2 * x1 ^ 2 + x0 ^ 2 + x1 ^ 2 - 8 * x0 - 8 * x1) where 22 x0 = index xs 0 23 x1 = index xs 1 24 25 main :: IO () 26 main = withSystemRandom . asGenIO $ mcmc 10000 1 (fromList [0, 0]) bnn 27 28  29 30 *speedy-slice* is a member of the [declarative][decl] suite of libraries, 31 containing a bunch of MCMC algorithms that play nicely together. 32 33 [decl]: https://github.com/jtobin/declarative