-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Speedy traversal through parameter space.
--   
--   Gradient-based traversal through parameter space.
--   
--   This implementation of HMC algorithm uses <a>lens</a> 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 <a>ad</a> library for automatic differentiation.
--   
--   Exports a <a>mcmc</a> function that prints a trace to stdout, a
--   <a>chain</a> function for collecting results in memory, and a
--   <a>hamiltonian</a> transition operator that can be used more
--   generally.
--   
--   <pre>
--   import Numeric.AD (grad)
--   import Numeric.MCMC.Hamiltonian
--   
--   target :: RealFloat a =&gt; [a] -&gt; a
--   target [x0, x1] = negate ((x0 + 2 * x1 - 7) ^ 2 + (2 * x0 + x1 - 5) ^ 2)
--   
--   gTarget :: [Double] -&gt; [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
--   </pre>
@package hasty-hamiltonian
@version 1.3.2


-- | This implementation performs Hamiltonian Monte Carlo using an identity
--   mass matrix.
--   
--   The <a>mcmc</a> function streams a trace to stdout to be processed
--   elsewhere, while the <tt>slice</tt> transition can be used for more
--   flexible purposes, such as working with samples in memory.
--   
--   See <a>Neal, 2012</a> for the definitive reference of the algorithm.
module Numeric.MCMC.Hamiltonian

-- | Trace <tt>n</tt> iterations of a Markov chain and stream them to
--   stdout.
--   
--   <pre>
--   &gt;&gt;&gt; withSystemRandom . asGenIO $ mcmc 10000 0.05 20 [0, 0] target
--   </pre>
mcmc :: (MonadIO m, PrimMonad m, Num (IxValue (t Double)), Show (t Double), Traversable t, FunctorWithIndex (Index (t Double)) t, Ixed (t Double), IxValue (t Double) ~ Double) => Int -> Double -> Int -> t Double -> Target (t Double) -> Gen (PrimState m) -> m ()

-- | Trace <tt>n</tt> iterations of a Markov chain and collect the results
--   in a list.
--   
--   <pre>
--   &gt;&gt;&gt; results &lt;- withSystemRandom . asGenIO $ chain 1000 0.05 20 [0, 0] target
--   </pre>
chain :: (PrimMonad m, Traversable f, FunctorWithIndex (Index (f Double)) f, Ixed (f Double), IxValue (f Double) ~ Double) => Int -> Double -> Int -> f Double -> Target (f Double) -> Gen (PrimState m) -> m [Chain (f Double) b]

-- | A Hamiltonian transition operator.
hamiltonian :: (Num (IxValue (t Double)), Traversable t, FunctorWithIndex (Index (t Double)) t, Ixed (t Double), PrimMonad m, IxValue (t Double) ~ Double) => Double -> Int -> Transition m (Chain (t Double) b)

-- | A <tt>Target</tt> consists of a function from parameter space to the
--   reals, as well as possibly a gradient.
--   
--   Most implementations assume a <i>log</i>-target, so records are named
--   accordingly.
data Target a
Target :: a -> Double -> Maybe a -> a -> Target a
[lTarget] :: Target a -> a -> Double
[glTarget] :: Target a -> Maybe a -> a

-- | Create a generator for variates using a fixed seed.
create :: PrimMonad m => m Gen PrimState m

-- | Seed a PRNG with data from the system's fast source of pseudo-random
--   numbers. All the caveats of <a>withSystemRandom</a> apply here as
--   well.
createSystemRandom :: IO GenIO

-- | Seed a PRNG with data from the system's fast source of pseudo-random
--   numbers ("<tt>/dev/urandom</tt>" on Unix-like systems or
--   <tt>RtlGenRandom</tt> on Windows), then run the given action.
--   
--   This is a somewhat expensive function, and is intended to be called
--   only occasionally (e.g. once per thread). You should use the
--   <a>Gen</a> it creates to generate many random numbers.
withSystemRandom :: PrimBase m => Gen PrimState m -> m a -> IO a

-- | Constrain the type of an action to run in the <a>IO</a> monad.
asGenIO :: () => GenIO -> IO a -> GenIO -> IO a
