mighty-metropolis

The classic Metropolis algorithm.
git clone git://git.jtobin.io/mighty-metropolis.git
Log | Files | Refs | README | LICENSE

BNN.hs (425B)


      1 {-# OPTIONS_GHC -fno-warn-type-defaults #-}
      2 
      3 module Main where
      4 
      5 import Numeric.MCMC.Metropolis
      6 import Data.Sequence (Seq, fromList, index)
      7 
      8 bnn :: Seq Double -> Double
      9 bnn xs = -0.5 * (x0 ^ 2 * x1 ^ 2 + x0 ^ 2 + x1 ^ 2 - 8 * x0 - 8 * x1) where
     10   x0 = index xs 0
     11   x1 = index xs 1
     12 
     13 main :: IO ()
     14 main = withSystemRandom . asGenIO $ \gen -> do
     15   _ <- chain 50 1 (fromList [0, 0]) bnn gen
     16   mcmc 50 1 (fromList [0, 0]) bnn gen
     17