Skip to content
Speedy gradient-based traversal through parameter space.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Numeric/MCMC
test
.gitignore
.travis.yml
CHANGELOG
LICENSE
README.md
Setup.hs
hasty-hamiltonian.cabal
stack-travis.yaml
stack.yaml

README.md

hasty-hamiltonian

Build Status Hackage Version MIT License

Speedy, gradient-based traversal through parameter space.

Exports a mcmc function that prints a trace to stdout, a chain function for collecting results in memory, and a hamiltonian transition operator that can be used more generally.

If you don't want to calculate your gradients by hand you can use the handy ad library for automatic differentiation.

import Numeric.AD (grad)
import Numeric.MCMC.Hamiltonian

target :: RealFloat a => [a] -> a
target [x0, x1] = negate ((x0 + 2 * x1 - 7) ^ 2 + (2 * x0 + x1 - 5) ^ 2)

gTarget :: [Double] -> [Double]
gTarget = grad target

booth :: Target [Double]
booth = Target target (Just gTarget)

main :: IO ()
main = withSystemRandom . asGenIO $ mcmc 10000 0.05 20 [0, 0] booth

trace

hasty-hamiltonian is a member of the declarative suite of libraries, containing a bunch of MCMC algorithms that play nicely together.

You can’t perform that action at this time.