flat-mcmc

Painless, efficient, general-purpose sampling from continuous distributions.
Log | Files | Refs | README | LICENSE

commit fa1619cf31a70cb80ec457c905fa8b9a23d4b2d8
parent e9682dd04847450d088b0671a14982ec924d0f1f
Author: Jared Tobin <jared@jtobin.ca>
Date:   Wed,  6 Apr 2016 20:23:58 +0700

Add BNN test case.

Diffstat:
Mflat-mcmc.cabal | 12++++++++++++
Atest/BNN.hs | 22++++++++++++++++++++++
2 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/flat-mcmc.cabal b/flat-mcmc.cabal @@ -74,3 +74,15 @@ Test-suite rosenbrock , flat-mcmc , vector +Test-suite bnn + type: exitcode-stdio-1.0 + hs-source-dirs: test + main-is: BNN.hs + default-language: Haskell2010 + ghc-options: + -rtsopts -threaded + build-depends: + base < 5 + , flat-mcmc + , vector + diff --git a/test/BNN.hs b/test/BNN.hs @@ -0,0 +1,22 @@ +{-# OPTIONS_GHC -fno-warn-type-defaults #-} + +module Main where + +import Numeric.MCMC.Flat +import Data.Vector (Vector, toList, fromList) + +bnn :: Vector Double -> Double +bnn xs = -0.5 * (x0 ^ 2 * x1 ^ 2 + x0 ^ 2 + x1 ^ 2 - 8 * x0 - 8 * x1) where + [x0, x1] = toList xs + +ensemble :: Ensemble +ensemble = fromList [ + fromList [negate 1.0, negate 1.0] + , fromList [negate 1.0, 1.0] + , fromList [1.0, negate 1.0] + , fromList [1.0, 1.0] + ] + +main :: IO () +main = withSystemRandom . asGenIO $ mcmc 100 ensemble bnn +