| Copyright | (c) 2015 Jared Tobin |
|---|---|
| License | MIT |
| Maintainer | Jared Tobin <jared@jtobin.ca> |
| Stability | unstable |
| Portability | ghc |
| Safe Haskell | None |
| Language | Haskell2010 |
Numeric.MCMC.Metropolis
Contents
Description
This implementation uses spherical Gaussian proposals to implement a reliable and computationally inexpensive sampling routine. It can be used as a baseline from which to benchmark other algorithms for a given problem.
The mcmc function streams a trace to stdout to be processed elsewhere,
while the metropolis transition can be used for more flexible purposes,
such as working with samples in memory.
- mcmc :: (Traversable f, Show (f Double)) => Int -> Double -> f Double -> (f Double -> Double) -> Gen RealWorld -> IO ()
- metropolis :: (Traversable f, PrimMonad m) => Double -> Transition m (Chain (f Double) b)
- module Data.Sampling.Types
- create :: PrimMonad m => m (Gen (PrimState m))
- createSystemRandom :: IO GenIO
- withSystemRandom :: PrimBase m => (Gen (PrimState m) -> m a) -> IO a
- asGenIO :: (GenIO -> IO a) -> GenIO -> IO a
Documentation
mcmc :: (Traversable f, Show (f Double)) => Int -> Double -> f Double -> (f Double -> Double) -> Gen RealWorld -> IO () Source #
Trace n iterations of a Markov chain and stream them to stdout.
>>>let rosenbrock [x0, x1] = negate (5 *(x1 - x0 ^ 2) ^ 2 + 0.05 * (1 - x0) ^ 2)>>>withSystemRandom . asGenIO $ mcmc 3 1 [0, 0] rosenbrock0.5000462419822702,0.5693944056267897 0.5000462419822702,0.5693944056267897 -0.7525995304580824,1.2240725505283248
metropolis :: (Traversable f, PrimMonad m) => Double -> Transition m (Chain (f Double) b) Source #
A generic Metropolis transition operator.
Re-exported
module Data.Sampling.Types
createSystemRandom :: IO GenIO #
Seed a PRNG with data from the system's fast source of pseudo-random
numbers. All the caveats of withSystemRandom apply here as well.
withSystemRandom :: PrimBase m => (Gen (PrimState m) -> m a) -> IO a #
Seed a PRNG with data from the system's fast source of
pseudo-random numbers ("/dev/urandom" on Unix-like systems or
RtlGenRandom 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 Gen
it creates to generate many random numbers.