README.md (1101B)
1 # hasty-hamiltonian 2 3 Speedy, gradient-based traversal through parameter space. 4 5 Exports a `mcmc` function that prints a trace to stdout, a `chain` function for 6 collecting results in memory, and a `hamiltonian` transition operator that can 7 be used more generally. 8 9 If you don't want to calculate your gradients by hand you can use the handy 10 [ad](https://hackage.haskell.org/package/ad) library for automatic 11 differentiation. 12 13 import Numeric.AD (grad) 14 import Numeric.MCMC.Hamiltonian 15 16 target :: RealFloat a => [a] -> a 17 target [x0, x1] = negate ((x0 + 2 * x1 - 7) ^ 2 + (2 * x0 + x1 - 5) ^ 2) 18 19 gTarget :: [Double] -> [Double] 20 gTarget = grad target 21 22 booth :: Target [Double] 23 booth = Target target (Just gTarget) 24 25 main :: IO () 26 main = withSystemRandom . asGenIO $ mcmc 10000 0.05 20 [0, 0] booth 27 28 ![trace](https://dl.dropboxusercontent.com/spa/u0s6617yxinm2ca/h6ty39dl.png) 29 30 *hasty-hamiltonian* 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