Gradient-based traversal through parameter space.
This implementation of HMC algorithm uses 'lens' as a means to operate over generic indexed traversable functors, so you can expect it to work if your target function takes a list, vector, map, sequence, etc. as its argument.
If you don't want to calculate your gradients by hand you can use the handy <https://hackage.haskell.org/package/ad ad> library for automatic differentiation.
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.
> import Numeric.AD (grad) > import Numeric.MCMC.Hamiltonian > > target :: RealFloat a => [a] -> a > target [x0, x1] = negate ((x0 + 2 * x1 - 7) ^ 2 + (2
> > booth :: Target [Double] > booth = Target target (Just gTarget) > > main :: IO () > main = withSystemRandom . asGenIO $ mcmc 10000 0.05 20 [0, 0] booth.
Package Version | Update ID | Released | Package Hub Version | Platforms | Subpackages |
---|---|---|---|---|---|
1.3.0-bp150.2.3 info | GA Release | 2018-08-01 | 15 |
|
|
1.3.0-bp150.2.6 info | GA Release | 2018-07-31 | 15 |
|
|
1.3.0-bp150.2.5 info | GA Release | 2018-07-30 | 15 |
|
|