flat-mcmc

Painless, efficient, general-purpose sampling from continuous distributions.
git clone git://git.jtobin.io/flat-mcmc.git
Log | Files | Refs | README | LICENSE

Main.hs (542B)


      1 {-# OPTIONS_GHC -fno-warn-type-defaults #-}
      2 
      3 module Main where
      4 
      5 import Numeric.MCMC.Flat
      6 import qualified Data.Vector.Unboxed as U (unsafeIndex)
      7 
      8 bnn :: Particle -> Double
      9 bnn xs = -0.5 * (x0 ^ 2 * x1 ^ 2 + x0 ^ 2 + x1 ^ 2 - 8 * x0 - 8 * x1) where
     10   x0 = U.unsafeIndex xs 0
     11   x1 = U.unsafeIndex xs 1
     12 
     13 origin :: Ensemble
     14 origin = ensemble [
     15     particle [negate 1.0, negate 1.0]
     16   , particle [negate 1.0, 1.0]
     17   , particle [1.0, negate 1.0]
     18   , particle [1.0, 1.0]
     19   ]
     20 
     21 main :: IO ()
     22 main = withSystemRandom . asGenIO $ mcmc 10000 origin bnn
     23